- OID: Object Identifier, a standardized dot-notated string used to map objects such as algorithms.
- KEM: Key Encapsulation Mechanism, a method to securely transmit encryption keys.
- MAC: Message Authentication Code, a mechanism to ensure message integrity and authenticity.
The design decisions follow closely the cryptography library for easier migration. This design ensures:
- Flexibility for users who may not wish to use
pyasn1while still allowing PQ key usage. - Simpler updates to existing workflows, such as creating a CSR (Certificate Signing Request).
An alternative solution for the design of the Composite and the PQ-Keys would be to use this approach:
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
from cryptography.hazmat.primitives import hashes
prehashed_algorithm = Prehashed(hashes.SHA256())
prehashed_algorithm._algorithm.nameThis is the approach, which the cryptography library is
possible using, because the same can be done for ECDSA.
The implementation of PQ keys follows a specific set of design principles. Below are the current considerations:
- Falcon: If someone wants to set it up in pure python: https://github.com/tprest/falcon.py (reason for not included: deprecated)
- ML-DSA: Does not support signing with context.
- SLH-DSA: Not yet supported, though OIDs are defined. Integration is planned for future versions.
- FN-DSA: Currently unstandardized and thus not considered. Updates will follow as the standard develops.
- FrodoKem: Uses OIDs defined by OQS.
- Stateful hash signatures: XMSS, XMSSMT, and HSS share a common interface in
pq_logic/keys/stateful_sig_keys.py. HSS support builds on bothpyhsslmsfor LMS/LMOTS parameter set handling. Such ashss_lms_sha256_m32_h5_lmots_sha256_n32_w8.
To add a new key, follow these steps:
-
Abstract Corresponding Class:
- For KEM, use the
PQKEMPrivateKeyclass. To improve typing, consider adding aPublicKeyclass. - If
.public_bytes()requires updates (e.g., for newer or unsupported versions), a RAW version can be used as an upper class.
- For KEM, use the
-
Example Implementation: Define the new class within
sign_keys.py. For instance, consider FN-DSA:
class FNDSAPublicKey(PQSignaturePublicKey):
def verify(self, data: bytes, signature: bytes, hash_alg: Optional[str] = None, ctx: Optional[bytes] = None):
# Implement custom logic for verification
pass
class FNDSAPrivateKey(PQSignaturePublicKey):
def sign(self, data: bytes, hash_alg: Optional[str] = None, ctx: Optional[bytes] = None):
# Implement custom logic for signing
pass
def public_key(self) -> FNDSAPublicKey:
return FNDSAPublicKey(self.name, self._raw_public_bytes)-
Default Encoding: The default encoding of private keys has been changed to use
OneAsymmetricKeyin version 2. -
Add
nameProperty: Thenameproperty should support different versions of the key type, avoiding the need for a new type for every version.
Hybrid cryptography combines traditional and post-quantum methods to enhance security. Below are key considerations:
-
Hybrid KEM:
- Modern designs use EC private keys as ephemeral keys, which means these keys are not stored in the certificate.
- The
KEMBasedMACclass supports a structure not described in draft 4213bis-15 (e.g., an absentinfoValue). This allows setting an OID to identify the hybrid method used.
-
Custom OIDs:
- As Chempat does not define OIDs, custom ones are currently implemented in
customoids.py.
- As Chempat does not define OIDs, custom ones are currently implemented in
The following mechanisms are supported using traditional cryptographic approaches:
- DHKEM (ECDH): The ciphertext is a serialized public key.
- DHKEM-RFC9180: Utilizes HKDF for key derivation.
- RSA-KEM: Standard RSA-based key encapsulation mechanism.
- RSA-OAEP-KEM: Described in Composite KEM, using OAEP padding.
The following post-quantum combined mechanisms are supported:
- Chempat: A hybrid cryptographic approach.
- XWing: Combines post-quantum KEM with traditional methods.
- Composite KEM: Merges traditional and PQ cryptography.
- Including FN-DSA, after the Standardization is finalized.
- Transition to standardized OIDs as they become available.
- Enhanced examples for integrating hybrid cryptography into existing workflows.
Please look at the SLHDSAPrivate, which is entirely from a different implementation.