@@ -341,6 +341,14 @@ impl MechanismType {
341341 val : CKM_SP800_108_DOUBLE_PIPELINE_KDF ,
342342 } ;
343343
344+ // ML-KEM
345+ /// ML-KEM key pair generation mechanism
346+ pub const ML_KEM_KEY_PAIR_GEN : MechanismType = MechanismType {
347+ val : CKM_ML_KEM_KEY_PAIR_GEN ,
348+ } ;
349+ /// ML-KEM encapsulation and decapsulation mechanism
350+ pub const ML_KEM : MechanismType = MechanismType { val : CKM_ML_KEM } ;
351+
344352 /// Create vendor defined mechanism
345353 ///
346354 /// # Arguments
@@ -735,6 +743,8 @@ impl MechanismType {
735743 CKM_SP800_108_DOUBLE_PIPELINE_KDF => {
736744 String :: from ( stringify ! ( CKM_SP800_108_DOUBLE_PIPELINE_KDF ) )
737745 }
746+ CKM_ML_KEM_KEY_PAIR_GEN => String :: from ( stringify ! ( CKM_ML_KEM_KEY_PAIR_GEN ) ) ,
747+ CKM_ML_KEM => String :: from ( stringify ! ( CKM_ML_KEM ) ) ,
738748 _ => format ! ( "unknown {mech:08x}" ) ,
739749 }
740750 }
@@ -822,6 +832,8 @@ impl TryFrom<CK_MECHANISM_TYPE> for MechanismType {
822832 CKM_SP800_108_COUNTER_KDF => Ok ( MechanismType :: SP800_108_COUNTER_KDF ) ,
823833 CKM_SP800_108_FEEDBACK_KDF => Ok ( MechanismType :: SP800_108_FEEDBACK_KDF ) ,
824834 CKM_SP800_108_DOUBLE_PIPELINE_KDF => Ok ( MechanismType :: SP800_108_DOUBLE_PIPELINE_KDF ) ,
835+ CKM_ML_KEM_KEY_PAIR_GEN => Ok ( MechanismType :: ML_KEM_KEY_PAIR_GEN ) ,
836+ CKM_ML_KEM => Ok ( MechanismType :: ML_KEM ) ,
825837 other => {
826838 error ! ( "Mechanism type {} is not supported." , other) ;
827839 Err ( Error :: NotSupported )
@@ -1052,6 +1064,12 @@ pub enum Mechanism<'a> {
10521064 /// NIST SP 800-108 KDF (aka KBKDF) mechanism in double pipeline-mode
10531065 KbkdfDoublePipeline ( kbkdf:: KbkdfParams < ' a > ) ,
10541066
1067+ // ML-KEM
1068+ /// ML-KEM key pair generation mechanism
1069+ MlKemKeyPairGen ,
1070+ /// ML-KEM key encacpsulation/decapsulation mechanism
1071+ MlKem ,
1072+
10551073 /// Vendor defined mechanism
10561074 VendorDefined ( VendorDefinedMechanism < ' a > ) ,
10571075}
@@ -1137,6 +1155,9 @@ impl Mechanism<'_> {
11371155 Mechanism :: KbkdfFeedback ( _) => MechanismType :: SP800_108_FEEDBACK_KDF ,
11381156 Mechanism :: KbkdfDoublePipeline ( _) => MechanismType :: SP800_108_DOUBLE_PIPELINE_KDF ,
11391157
1158+ Mechanism :: MlKemKeyPairGen => MechanismType :: ML_KEM_KEY_PAIR_GEN ,
1159+ Mechanism :: MlKem => MechanismType :: ML_KEM ,
1160+
11401161 Mechanism :: VendorDefined ( vm) => MechanismType {
11411162 val : vm. inner . mechanism ,
11421163 } ,
@@ -1237,7 +1258,9 @@ impl From<&Mechanism<'_>> for CK_MECHANISM {
12371258 | Mechanism :: Sha384KeyGen
12381259 | Mechanism :: Sha512KeyGen
12391260 | Mechanism :: GenericSecretKeyGen
1240- | Mechanism :: HkdfKeyGen => CK_MECHANISM {
1261+ | Mechanism :: HkdfKeyGen
1262+ | Mechanism :: MlKemKeyPairGen
1263+ | Mechanism :: MlKem => CK_MECHANISM {
12411264 mechanism,
12421265 pParameter : null_mut ( ) ,
12431266 ulParameterLen : 0 ,
0 commit comments