Convert Figma logo to code with AI

google logoboringssl

Mirror of BoringSSL

1,809
757
1,809
0

Top Related Projects

25,667

TLS/SSL and crypto library

LibreSSL Portable itself. This includes the build scaffold and compatibility layer that builds portable LibreSSL from the OpenBSD source code. Pull requests or patches sent to tech@openbsd.org are welcome.

2,325

The wolfSSL library is a small, fast, portable implementation of TLS/SSL for embedded devices to the cloud. wolfSSL supports up to TLS 1.3 and DTLS 1.3!

5,304

An open source, portable, easy to use, readable and flexible TLS library, and reference implementation of the PSA Cryptography API. Releases are on a varying cadence, typically around 3 - 6 months between releases.

4,521

An implementation of the TLS/SSL protocols

Fast Elliptic Curve Cryptography in plain javascript

Quick Overview

BoringSSL is a fork of OpenSSL created by Google for use in their own products. It's designed to be a more streamlined and secure version of OpenSSL, with a focus on modern cryptographic standards and improved maintainability. BoringSSL is not intended as a general-purpose cryptographic library for wide use but rather as a specialized tool for Google's needs.

Pros

  • Improved security with regular audits and removal of deprecated features
  • Faster development cycle and more frequent updates
  • Simplified API and reduced codebase compared to OpenSSL
  • Strong focus on modern cryptographic standards and algorithms

Cons

  • Not intended for general use, which may limit its applicability for some projects
  • Potential compatibility issues with software expecting standard OpenSSL behavior
  • Less extensive documentation compared to OpenSSL
  • Smaller community and ecosystem compared to more widely-used cryptographic libraries

Code Examples

  1. Initializing a TLS context:
#include <openssl/ssl.h>

SSL_CTX *ctx = SSL_CTX_new(TLS_method());
if (!ctx) {
    // Handle error
}
  1. Creating an SSL connection:
SSL *ssl = SSL_new(ctx);
if (!ssl) {
    // Handle error
}

if (SSL_set_fd(ssl, socket_fd) != 1) {
    // Handle error
}

if (SSL_connect(ssl) != 1) {
    // Handle error
}
  1. Performing a cryptographic operation (SHA-256 hash):
#include <openssl/sha.h>

unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256;
SHA256_Init(&sha256);
SHA256_Update(&sha256, data, data_len);
SHA256_Final(hash, &sha256);

Getting Started

To use BoringSSL in your project:

  1. Clone the repository:

    git clone https://github.com/google/boringssl.git
    
  2. Build the library:

    cd boringssl
    mkdir build
    cd build
    cmake ..
    make
    
  3. Include the necessary headers and link against the built libraries in your project.

  4. Use the BoringSSL API in your code, similar to how you would use OpenSSL, but be aware of potential differences in function names and behavior.

Competitor Comparisons

25,667

TLS/SSL and crypto library

Pros of OpenSSL

  • Wider adoption and community support
  • More comprehensive feature set and broader protocol support
  • Extensive documentation and resources available

Cons of OpenSSL

  • Larger codebase, potentially more complex to maintain
  • Historical security vulnerabilities due to legacy code
  • Slower release cycle for updates and patches

Code Comparison

OpenSSL:

EVP_PKEY *pkey = EVP_PKEY_new();
EVP_PKEY_assign_RSA(pkey, rsa);
X509 *x509 = X509_new();
X509_set_pubkey(x509, pkey);

BoringSSL:

bssl::UniquePtr<EVP_PKEY> pkey(EVP_PKEY_new());
EVP_PKEY_assign_RSA(pkey.get(), rsa);
bssl::UniquePtr<X509> x509(X509_new());
X509_set_pubkey(x509.get(), pkey.get());

The code snippets demonstrate key and certificate handling. BoringSSL uses smart pointers for better memory management, while OpenSSL relies on manual resource handling.

BoringSSL, developed by Google, focuses on simplicity and security for modern applications. It removes legacy code and APIs, resulting in a smaller, more maintainable codebase. However, it may lack some features and compatibility with older systems compared to OpenSSL.

OpenSSL remains the more widely used option, offering broader compatibility and a more extensive feature set. It's suitable for a wide range of applications but may require more careful handling of its complexities and legacy components.

LibreSSL Portable itself. This includes the build scaffold and compatibility layer that builds portable LibreSSL from the OpenBSD source code. Pull requests or patches sent to tech@openbsd.org are welcome.

Pros of LibreSSL

  • More focused on security and simplicity, with a cleaner codebase
  • Better compatibility with OpenSSL, making it easier to adopt in existing projects
  • Regular security audits and updates

Cons of LibreSSL

  • Smaller development community compared to BoringSSL
  • Less frequent updates and potentially slower adoption of new features
  • May lack some performance optimizations present in BoringSSL

Code Comparison

BoringSSL (error handling):

if (ERR_peek_error() != 0) {
  // Handle error
  ERR_clear_error();
}

LibreSSL (error handling):

unsigned long err;
while ((err = ERR_get_error()) != 0) {
  // Handle error
}

Both libraries aim to provide secure and efficient cryptographic implementations, but they have different focuses. BoringSSL is tailored for Google's needs and emphasizes performance, while LibreSSL prioritizes security and OpenSSL compatibility. The code comparison shows slight differences in error handling approaches, with LibreSSL using a more traditional OpenSSL-like method.

2,325

The wolfSSL library is a small, fast, portable implementation of TLS/SSL for embedded devices to the cloud. wolfSSL supports up to TLS 1.3 and DTLS 1.3!

Pros of wolfSSL

  • Smaller footprint and better suited for embedded systems
  • More extensive support for various cryptographic algorithms
  • Offers both open-source and commercial licensing options

Cons of wolfSSL

  • Less widely adopted compared to BoringSSL
  • May have fewer resources and community support
  • Potentially slower development cycle for new features

Code Comparison

wolfSSL:

int wolfSSL_Init(void) {
    WOLFSSL_ENTER("wolfSSL_Init");
    if (initRefCount == 0) {
        if (InitMutex() != 0)
            return WOLFSSL_FAILURE;
        if (InitRng() != 0)
            return WOLFSSL_FAILURE;
    }
    initRefCount++;
    return WOLFSSL_SUCCESS;
}

BoringSSL:

int CRYPTO_library_init(void) {
  CRYPTO_once(&once, do_library_init);
  return 1;
}

static void do_library_init(void) {
  CRYPTO_init_sysrand();
  ERR_init();
}

Both libraries provide initialization functions, but wolfSSL's implementation includes reference counting and more explicit error handling, while BoringSSL's approach is more concise and relies on a separate initialization function.

5,304

An open source, portable, easy to use, readable and flexible TLS library, and reference implementation of the PSA Cryptography API. Releases are on a varying cadence, typically around 3 - 6 months between releases.

Pros of Mbed-TLS

  • More portable and lightweight, suitable for embedded systems and IoT devices
  • Easier to integrate into existing projects due to its modular design
  • Extensive documentation and examples for various use cases

Cons of Mbed-TLS

  • Generally slower performance compared to BoringSSL
  • Less frequent updates and potentially slower security patch releases
  • Smaller community and fewer contributors compared to BoringSSL

Code Comparison

Mbed-TLS (initializing an SSL context):

mbedtls_ssl_context ssl;
mbedtls_ssl_config conf;

mbedtls_ssl_init(&ssl);
mbedtls_ssl_config_init(&conf);
mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT);

BoringSSL (initializing an SSL context):

SSL_CTX *ctx = SSL_CTX_new(TLS_method());
SSL *ssl = SSL_new(ctx);
BIO *bio = BIO_new_socket(sockfd, BIO_NOCLOSE);
SSL_set_bio(ssl, bio, bio);

Both libraries provide similar functionality for SSL/TLS operations, but BoringSSL's API is more closely aligned with OpenSSL, while Mbed-TLS has its own unique API design. BoringSSL is generally preferred for high-performance applications, while Mbed-TLS is better suited for resource-constrained environments.

4,521

An implementation of the TLS/SSL protocols

Pros of s2n-tls

  • Smaller codebase, making it easier to audit and maintain
  • Designed with a focus on simplicity and security
  • Optimized for performance in cloud environments

Cons of s2n-tls

  • Limited feature set compared to BoringSSL
  • Less widespread adoption and community support
  • Primarily tailored for AWS services, potentially limiting its versatility

Code Comparison

s2n-tls:

int s2n_init(void)
{
    if (s2n_is_initialized) {
        return 0;
    }
    s2n_is_initialized = 1;
    return 0;
}

BoringSSL:

int CRYPTO_library_init(void) {
  CRYPTO_once(&once, do_library_init);
  return 1;
}

Both libraries provide initialization functions, but s2n-tls uses a simpler approach with a boolean flag, while BoringSSL employs a more complex initialization mechanism using CRYPTO_once.

s2n-tls focuses on a streamlined implementation, prioritizing simplicity and security. BoringSSL, being a fork of OpenSSL, offers a broader feature set and wider compatibility but at the cost of increased complexity.

The choice between these libraries depends on specific project requirements, with s2n-tls being particularly suitable for AWS-centric applications and BoringSSL offering more versatility for general-purpose use.

Fast Elliptic Curve Cryptography in plain javascript

Pros of elliptic

  • Lightweight and focused specifically on elliptic curve cryptography
  • Pure JavaScript implementation, making it easily portable across platforms
  • Extensive support for various elliptic curves and algorithms

Cons of elliptic

  • Limited scope compared to BoringSSL's comprehensive cryptographic suite
  • May have lower performance for certain operations due to JavaScript implementation
  • Less extensive security auditing and backing compared to Google's resources

Code Comparison

BoringSSL (C):

EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
EC_KEY_generate_key(key);
ECDSA_sign(0, digest, 32, signature, &siglen, key);

elliptic (JavaScript):

const ec = new EC('p256');
const key = ec.genKeyPair();
const signature = key.sign(digest);

Both libraries provide similar functionality for elliptic curve operations, but BoringSSL offers a more comprehensive cryptographic toolkit while elliptic focuses specifically on elliptic curve cryptography in a JavaScript environment.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

BoringSSL

BoringSSL is a fork of OpenSSL that is designed to meet Google's needs.

Although BoringSSL is an open source project, it is not intended for general use, as OpenSSL is. We don't recommend that third parties depend upon it. Doing so is likely to be frustrating because there are no guarantees of API or ABI stability.

Programs ship their own copies of BoringSSL when they use it and we update everything as needed when deciding to make API changes. This allows us to mostly avoid compromises in the name of compatibility. It works for us, but it may not work for you.

BoringSSL arose because Google used OpenSSL for many years in various ways and, over time, built up a large number of patches that were maintained while tracking upstream OpenSSL. As Google's product portfolio became more complex, more copies of OpenSSL sprung up and the effort involved in maintaining all these patches in multiple places was growing steadily.

Currently BoringSSL is the SSL library in Chrome/Chromium, Android (but it's not part of the NDK) and a number of other apps/programs.

Project links:

To file a security issue, use the Chromium process and mention in the report this is for BoringSSL. You can ignore the parts of the process that are specific to Chromium/Chrome.

There are other files in this directory which might be helpful: