PRINCIPLE
Public key encryption using X.509 certificates allows securing data exchanges without requiring a pre-shared secret. The sender uses the recipient's public key (available in their X.509 certificate) to encrypt a temporary secret, which will then be used to encrypt the content with a high-performance symmetric algorithm.
TECHNICAL DETAILS
Encryption with X.509 certificate combines two types of cryptography:
- Asymmetric cryptography (or public key): used for secure exchange of the session key
- Symmetric cryptography: used for efficient data encryption
The application offers two symmetric encryption algorithms to choose from:
- AES-GCM (Advanced Encryption Standard in Galois/Counter Mode with AAD - Additional Authenticated Data)
- ChaCha20-Poly1305 (Combination of ChaCha20 stream cipher with Poly1305 authenticator)
ENCRYPTION PROCESS
- The sender retrieves the recipient's X.509 certificate containing their public key
- A random symmetric key (session key) is generated
- This session key is encrypted with the public key from the recipient's X.509 certificate
- The session key is used with the chosen algorithm (AES-GCM or ChaCha20-Poly1305) to encrypt the data
- The final message contains:
- The encrypted session key
- The encrypted data
- Information about the algorithm used
- Authentication metadata
CHARACTERISTICS OF SYMMETRIC ALGORITHMS
AES-GCM
- Uses the AES algorithm with a 256-bit key size
- GCM (Galois/Counter Mode) with AAD that ensures both confidentiality and authenticity
- Requires a unique initialization vector (IV) for each message
- Widely adopted and audited standard
- Excellent performance on processors with AES-NI instructions
ChaCha20-Poly1305
- Combines the ChaCha20 stream cipher (256 bits) with the Poly1305 authenticator
- Requires a unique nonce for each message
- Excellent performance on mobile devices and processors without AES-NI instructions
- Adopted in modern protocols such as TLS 1.3
CRYPTOGRAPHIC INDEPENDENCE
The two algorithms (AES-GCM and ChaCha20-Poly1305) are based on different cryptographic principles:
- AES-GCM uses block cipher encryption
- ChaCha20-Poly1305 uses stream cipher encryption
This independence presents an important security advantage: if a vulnerability were discovered in one of the algorithms, the other would normally not be affected by the same vulnerability. This provides additional security to the application, which can switch from one algorithm to the other if needed.