reqtls - a TLS and cryptographic foundation library designed based on BoringSSL
reqtls is a high-performance TLS and cryptographic foundation library designed for the reqrio ecosystem, offering comprehensive capabilities for encryption, signing, certificate handling, and encoding.
It focuses on security, scalability, and cross-platform support, making it suitable for building HTTPS clients, proxy services, certificate issuance systems, and custom secure communication protocols.
Design Objectives
- Lightweight Implementation: Only implements the TLS protocol and essential encryption components to avoid excessive dependencies and bloat
- High controllability: Developers can directly access the TLS record layer and handshake process
- Suitable for protocol development: Easy to use for network proxies, debugging tools, or protocol experiments
TLS Record Layer (TLS1.2)
`reqtls currently implements the core functionality of TLS 1.2 Record Layer, which is used to provide encrypted communication capabilities over TCP connections. This implementation is mainly aimed at Protocol research, network tools, and custom TLS client/proxy development.
Future versions are planned to gradually support TLS 1.3.
Supported password algorithms
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
- TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
- TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
- TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
- TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
- TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
- TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
- TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
- TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
- TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
- TLS_RSA_WITH_AES_128_GCM_SHA256
- TLS_RSA_WITH_AES_256_GCM_SHA384
- TLS_RSA_WITH_AES_128_CBC_SHA256
- TLS_RSA_WITH_AES_256_CBC_SHA256
- TLS_RSA_WITH_AES_128_CBC_SHA
- TLS_RSA_WITH_AES_256_CBC_SHA
Signature algorithm
- RSA_PSS_RSAE_SHA256
- RSA_PSS_RSAE_SHA384
- RSA_PSS_RSAE_SHA512
- ECDSA_SECP256R1_SHA256
- ECDSA_SECP384R1_SHA384
- ECDSA_SECP521R1_SHA512
- RSA_PKCS1_SHA1
- RSA_PKCS1_SHA256
- RSA_PKCS1_SHA384
- RSA_PKCS1_SHA512
Password Curve
- secp256r1
- secp385r1
- secp521r1
- x25519
Basic usage
`Developers can directly manipulate TCP data and encrypt/decrypt messages through Connection
Example:
- Communication key generation (after Client Exchange Key)
Connection::make_cipher(bool)
- Build record message
Connection::make_message(RecordType, out, int)
- Read record message
Connection::read_message(int,out)
For specific details, please refer to
Certificate related support
During the TLS handshake process, the server typically sends an X.509 Certificate Chain to the client to prove the server's identity and provide public key information to establish a secure connection.
Currently, reqtls is able to parse and extract certificate data from TLS handshakes to support key exchange and handshake processes. Some common root certificates are built-in in reqtls, so reqtls defaults to not trusting system root certificates:
Certificate reading/writing
use fs;
Certificate Issuance Example
Cryptography related support
AES/DES/RC4/RSA supported
- AES_128_CBC
- AES_192_CBC
- AES_256_CBC
- AES_128_ECB
- AES_192_ECB
- AES_256_ECB
- AES_128_CTR
- AES_192_CTR
- AES_256_CTR
- AES_128_GCM
- AES_192_GCM
- AES_256_GCM
- AES_128_OFB
- AES_192_OFB
- AES_256_OFB
- DES_CBC
- DES_ECB
- RC4
- RSA
- Cipher usage example
- Rsa Encryption and Decryption Example
Hash support
- SHA1
- SHA224
- SHA256
- SHA384
- SHA512
- MD5
- HMAC
- Usage example
Encoding support
- base64
- urlencoding
- hex
Compression support
- gzip
- deflate
- br
- zstd