#[non_exhaustive]pub enum KeyAlgorithm {
Show 13 variants
Rsa2048,
Rsa4096,
EcdsaP256,
EcdsaP384,
Ed25519,
MlDsa44,
MlDsa65,
MlDsa87,
MlKem512,
MlKem768,
MlKem1024,
Aes128,
Aes256,
}Expand description
Key algorithm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Rsa2048
RSA 2048-bit key.
Rsa4096
RSA 4096-bit key.
EcdsaP256
ECDSA with P-256 curve (secp256r1).
EcdsaP384
ECDSA with P-384 curve (secp384r1).
Ed25519
Ed25519 (EdDSA).
MlDsa44
ML-DSA-44, module-lattice signature at NIST security category 2 (FIPS 204).
MlDsa65
ML-DSA-65, module-lattice signature at NIST security category 3 (FIPS 204).
MlDsa87
ML-DSA-87, module-lattice signature at NIST security category 5 (FIPS 204).
MlKem512
ML-KEM-512, module-lattice KEM at NIST security category 1 (FIPS 203).
A KEM encapsulates, it does not sign. Such a key can receive a wrap and nothing else.
MlKem768
ML-KEM-768, module-lattice KEM at NIST security category 3 (FIPS 203).
MlKem1024
ML-KEM-1024, module-lattice KEM at NIST security category 5 (FIPS 203).
Aes128
AES 128-bit symmetric key.
Aes256
AES 256-bit symmetric key.
Implementations§
Source§impl KeyAlgorithm
impl KeyAlgorithm
Sourcepub fn default_sign_algorithm(self) -> Option<SignAlgorithm>
pub fn default_sign_algorithm(self) -> Option<SignAlgorithm>
The signature algorithm to use with this key unless told otherwise.
None for symmetric keys, which sign nothing.
A key algorithm does not always determine a signature algorithm: RSA keys work with both PKCS#1 v1.5 and PSS, and this picks v1.5 for interoperability. Everywhere else the pairing is forced, either by the curve’s matching digest strength (RFC 5480) or by the scheme naming its own digest (Ed25519, ML-DSA).
Sourcepub fn can_receive_wrap(self) -> bool
pub fn can_receive_wrap(self) -> bool
Whether a key of this algorithm can be the recipient of a wrap.
A recipient has to be able to receive a content-encryption key, by key transport, key agreement, or encapsulation. A signature algorithm can do none of the three, however good a key it otherwise is, and this answers the question before a ceremony reaches the wrap step.
Sourcepub fn is_symmetric(self) -> bool
pub fn is_symmetric(self) -> bool
Whether a key of this algorithm is one secret with no public half.
use rite_sdk::KeyAlgorithm;
assert!(KeyAlgorithm::Aes256.is_symmetric());
assert_eq!(KeyAlgorithm::Aes256.key_bytes(), Some(32));
assert!(!KeyAlgorithm::EcdsaP256.is_symmetric());
assert_eq!(KeyAlgorithm::EcdsaP256.key_bytes(), None);This is the discriminator for everything that assumes a keypair: there
is no public key to export, no SPKI to fingerprint, and no certificate
to issue. A backend answers for such a key with a
KeyCheckValue instead.