@@ -80,6 +80,14 @@ pub enum CipherSuite {
80
80
/// 4096 bit RSA with SHA512 and AES256
81
81
RSA4k ,
82
82
83
+ /// Composite signature algorithm MLDSA65+Ed25519, and composite
84
+ /// KEM MLKEM768+X25519.
85
+ MLDSA65 ,
86
+
87
+ /// Composite signature algorithm MLDSA78+Ed448, and composite
88
+ /// KEM MLKEM1024+X448.
89
+ MLDSA87 ,
90
+
83
91
// If you add a variant here, be sure to update
84
92
// CipherSuite::variants below.
85
93
}
@@ -96,7 +104,7 @@ impl CipherSuite {
96
104
pub fn variants ( ) -> impl Iterator < Item =CipherSuite > {
97
105
use CipherSuite :: * ;
98
106
99
- [ Cv25519 , RSA3k , P256 , P384 , P521 , RSA2k , RSA4k ]
107
+ [ Cv25519 , RSA3k , P256 , P384 , P521 , RSA2k , RSA4k , MLDSA65 , MLDSA87 ]
100
108
. into_iter ( )
101
109
}
102
110
@@ -150,6 +158,10 @@ impl CipherSuite {
150
158
check_curve ! ( Curve :: NistP521 ) ;
151
159
check_pk ! ( PublicKeyAlgorithm :: ECDH ) ;
152
160
} ,
161
+ MLDSA65 =>
162
+ check_pk ! ( PublicKeyAlgorithm :: MLDSA65_Ed25519 ) ,
163
+ MLDSA87 =>
164
+ check_pk ! ( PublicKeyAlgorithm :: MLDSA87_Ed448 ) ,
153
165
}
154
166
Ok ( ( ) )
155
167
}
@@ -211,6 +223,11 @@ impl CipherSuite {
211
223
. into ( ) ) ,
212
224
}
213
225
} ,
226
+
227
+ CipherSuite :: MLDSA65 | CipherSuite :: MLDSA87 =>
228
+ Err ( Error :: InvalidOperation (
229
+ "can't use algorithms for v4 keys" . into ( ) )
230
+ . into ( ) ) ,
214
231
}
215
232
}
216
233
@@ -273,6 +290,28 @@ impl CipherSuite {
273
290
. into ( ) ) ,
274
291
}
275
292
} ,
293
+
294
+ a @ CipherSuite :: MLDSA65 | a @ CipherSuite :: MLDSA87 =>
295
+ match ( sign, encrypt, a) {
296
+ ( true , false , CipherSuite :: MLDSA65 ) =>
297
+ Key6 :: generate_mldsa65_ed25519 ( ) ,
298
+ ( true , false , CipherSuite :: MLDSA87 ) =>
299
+ Key6 :: generate_mldsa87_ed448 ( ) ,
300
+ ( true , false , _) => unreachable ! ( ) ,
301
+ ( false , true , CipherSuite :: MLDSA65 ) =>
302
+ Key6 :: generate_mlkem768_x25519 ( ) ,
303
+ ( false , true , CipherSuite :: MLDSA87 ) =>
304
+ Key6 :: generate_mlkem1024_x448 ( ) ,
305
+ ( false , true , _) => unreachable ! ( ) ,
306
+ ( true , true , _) =>
307
+ Err ( Error :: InvalidOperation (
308
+ "Can't use key for encryption and signing" . into ( ) )
309
+ . into ( ) ) ,
310
+ ( false , false , _) =>
311
+ Err ( Error :: InvalidOperation (
312
+ "No key flags set" . into ( ) )
313
+ . into ( ) ) ,
314
+ } ,
276
315
}
277
316
}
278
317
}
@@ -1936,9 +1975,12 @@ mod tests {
1936
1975
for cs in CipherSuite :: variants ( )
1937
1976
. into_iter ( ) . filter ( |cs| cs. is_supported ( ) . is_ok ( ) )
1938
1977
{
1939
- assert ! ( CertBuilder :: new( )
1978
+ CertBuilder :: new ( )
1979
+ . set_profile ( crate :: Profile :: RFC9580 ) . unwrap ( )
1940
1980
. set_cipher_suite ( cs)
1941
- . generate( ) . is_ok( ) ) ;
1981
+ . add_transport_encryption_subkey ( )
1982
+ . generate ( )
1983
+ . unwrap ( ) ;
1942
1984
}
1943
1985
}
1944
1986
0 commit comments