- Main
- API Documentation
- Browse Source Code
- Change Log
- Project Goals
- On Naming Things
- Supported Crypto
- Roadmap and Status
- OOP in C
- API Overview
- X.509 Certificates
- Constant-Time Crypto
- Constant-Time Mul
- Speed Benchmarks
- Size Calculator
Code Size
The table below is a dynamic calculator for total compiled code size, depending on selected algorithms. BearSSL is pluggable, so what a given SSL client or server engine supports depends on which algorithms were configured into it. From a programming point of view, each algorithm is configured by setting a pointer to the relevant implementation into the engine context; referencing that implementation means that, at link time, the corresponding code will be pulled into the produced binary, along with all its dependencies.
By selecting some implementations below, one can observe the effect on final code size. Note that internally some code is shared; for instance, RSA public and private operations may use the same internal big-integer implementation, so selecting both results in a code size which is less than the sum of the size induced by each searately. The calculator below takes such code sharing into account.
The total code size is inferred by adding the sizes of the relevant object files, as reported by the size
utility (all platforms used for these benchmarks use ELF). Note that when linking, a few extra bytes may be added for alignment, or for some glue code in case of dynamic linking support.
To use the calculator below, first select an architecture, then some implementations. The calculator computes the total binary size, as well as the features (protocol versions and cipher suites) that can be used with the selected algorithms.
Note: this calculator uses Javascript.
Architecture
First select an architecture. The list of available code elements depends on that selection.
The x86 code was compiled with GCC 5.4.0 and options “-Os -fPIC
”. The POWER8 code was compiled with GCC 6.2.0 and options “-Os -fPIC
”. The ARM Cortex M0+ code was compiled with GCC 4.9.3 and options “-Os -mthumb -mcpu=cortex-m0plus
”.
In all sections below, check the code elements you want to include in the calculation. The total size and activated features (e.g. supported cipher suites) that correspond to the checked elements are then listed.
Hash Functions
Hash functions are used within the handshake, and also to support signature generation and verification (in particular in certificates). TLS 1.0 and 1.1 requires both MD5 and SHA-1. TLS 1.2 uses either SHA-256 or SHA-384, depending on the cipher suite.
MD5 | |
SHA-1 | |
SHA-224 | |
SHA-256 | |
SHA-384 | |
SHA-512 |
Elliptic Curves
Raw elliptic curve support is needed for ECDH and ECDHE cipher suites, and for ECDSA signature generation or verification.
P-256, P-384, P-521, Curve25519, with m15 or i15 code | |
P-256, P-384, P-521, Curve25519, with m31 or i31 code | |
Curve25519, with i15 code | |
Curve25519, with i31 code | |
Curve25519, with m15 code | |
Curve25519, with m31 code | |
P-256, with m15 code | |
P-256, with m31 code | |
P-256, P-384 and P-512, with i15 code | |
P-256, P-384 and P-512, with i31 code |
ECDSA
ECDSA signature generation and verification requires an elliptic curve implementation (that supports at least one of the NIST curves: P-256, P-384 and P-521), and an extra piece of code that performs the big integer computations specific to ECDSA (as opposed to ECDH).
ECDSA signature generation, with i15 code | |
ECDSA signature verification, with i15 code | |
ECDSA signature generation, with i31 code | |
ECDSA signature verification, with i31 code |
RSA Signatures
For ECDHE_RSA cipher suites, the server needs to compute an RSA signature, and the client needs to verify that signature. Signature verification is also needed for X.509 certificate validation (validation of the server’s certificate on the client).
For certificate-based client authentication (except for full static ECDH), the client needs to compute a signature, and the server verifies it.
RSA signature generation, with i15 code | |
RSA signature verification, with i15 code | |
RSA signature generation, with i31 code | |
RSA signature verification, with i31 code | |
RSA signature generation, with i32 code | |
RSA signature verification, with i32 code | |
RSA signature generation, with i62 code | |
RSA signature verification, with i62 code |
RSA Encryption
RSA cipher suites (not ECDH_RSA or ECDHE_RSA) use asymmetric encryption for key exchange. The client needs an RSA encryption engine, and the server requires an RSA decryption engine.
RSA decryption (private), with i15 code | |
RSA encryption (public), with i15 code | |
RSA decryption (private), with i31 code | |
RSA encryption (public), with i31 code | |
RSA decryption (private), with i32 code | |
RSA encryption (public), with i32 code | |
RSA decryption (private), with i62 code | |
RSA encryption (public), with i62 code |
AES
AES_CBC cipher suites need an AES/CBC encryption engine and an AES/CBC decryption engine. These need not use the same implementation, although this is usually a good idea since the encryption and decryption engines for a given implementation tend to share some code.
AES_GCM cipher suites need an AES/CTR engine.
The “big” and “small” implementations use tables and thus are not constant-time.
AES/CBC decryption, “big” (fast, uses tables) | |
AES/CBC encryption, “big” (fast, uses tables) | |
AES/CTR, “big” (fast, uses tables) | |
AES/CBC decryption, “small” (uses tables) | |
AES/CBC encryption, “small” (uses tables) | |
AES/CTR, “small” (uses tables) | |
AES/CBC decryption, “ct” (constant-time, for 32-bit architectures) | |
AES/CBC encryption, “ct” (constant-time, for 32-bit architectures) | |
AES/CTR, “ct” (constant-time, for 32-bit architectures) | |
AES/CBC decryption, “ct64” (constant-time, for 64-bit architectures) | |
AES/CBC encryption, “ct64” (constant-time, for 64-bit architectures) | |
AES/CTR, “ct64” (constant-time, for 64-bit architectures) | |
AES/CBC decryption, “pwr8” (with POWER8 crypto opcodes) | |
AES/CBC encryption, “pwr8” (with POWER8 crypto opcodes) | |
AES/CTR, “pwr8” (with POWER8 crypto opcodes) | |
AES/CBC decryption, “x86ni” (with AES-NI opcodes) | |
AES/CBC encryption, “x86ni” (with AES-NI opcodes) | |
AES/CTR, “x86ni” (with AES-NI opcodes) |
GHASH
A GHASH implementation is needed for AES/GCM cipher suites.
GHASH with 32→64 multiplications | |
GHASH with 32→32 multiplications | |
GHASH with 64→64 multiplications | |
GHASH with AES-NI opcodes (pclmulqdq) | |
GHASH with POWER8 crypto opcodes |
3DES
3DES cipher suites (“3DES_EDE_CBC”) need a 3DES/CBC encryption engine and a 3DES/CBC decryption engine. The “tab” implementation is faster than “ct”; however, “ct” is constant-time while “tab” is not.
3DES/CBC decryption, “tab” (uses tables) | |
3DES/CBC encryption, “tab” (uses tables) | |
3DES/CBC decryption, “ct” (constant-time) | |
3DES/CBC encryption, “ct” (constant-time) |
ChaCha20
ChaCha20+Poly1305 cipher suites require a ChaCha20 implementation.
ChaCha20, “ct” |
Poly1305
ChaCha20+Poly1305 cipher suites require a Poly1305 implementation.
Poly1305, “ctmul” (with 32→64 multiplications) | |
Poly1305, “ctmul32” (with 32→32 multiplications) | |
Poly1305, “ctmulq” (with 64→128 multiplications) | |
Poly1305, “i15” (with i15 big integer code) |
SSL Handshake
SSL client and server share a common processing engine, but each has specific code for handling handshake messages.
SSL client engine | |
SSL server engine |
SSL Records
The record processing code (encryption+MAC) depends on the type of encryption used.
SSL records with CBC+HMAC encryption/decryption | |
SSL records with ChaCha20+Poly1305 encryption/decryption | |
SSL records with GCM encryption/decryption |
PRF
TLS 1.0 and 1.1 use a PRF function that relies on MD5 and SHA-1.
TLS 1.2 uses a PRF that relies on either SHA-256 or SHA-384, depending on the cipher suite.
PRF for TLS 1.0 and 1.1 (uses MD5 and SHA-1) | |
PRF for TLS 1.2 with SHA-256 | |
PRF for TLS 1.2 with SHA-384 |
Certificate
The server must send a certificate that contains its public key, and use the corresponding private key. Similarly, when client certificates are used, the client must send a certificate and use the corresponding private key. The elements below contain the code that offers a single certificate chain and uses the private key.
SSL client certificate authentication (ECDH/ECDSA) | |
SSL client certificate authentication (RSA) | |
SSL server certificate (ECDH/ECDSA) | |
SSL server certificate (RSA) |
X.509 Validation
X.509 validation is used to extract the public key sent by the peer. Clients need an X.509 engine; if client certificates are used, then servers also need an X.509 engine.
The “knownkey” engine ignores the received certificate chain, and returns an hardcoded public key. The “minimal” engine performs basic chain validation, which entails verifying signatures; which signatures are supported depends on the configured hash functions and signature verification engines.
X.509 validation (pseudo: public key already known) | |
X.509 validation (single chain processing) |
Total
Total:
Supported cipher suites as SSL client:
-
TLS 1.0 and 1.1:
-
TLS 1.2:
Supported cipher suites as SSL server:
-
TLS 1.0 and 1.1:
-
TLS 1.2: