Skip to content

Commit 8b5d6a7

Browse files
eferolloromen
authored andcommitted
feat(nss/ssl): Add support for composite ML-DSA (MLDSA-Ed25519-SHA512) signature scheme in the SSL stack
Signed-off-by: Francesco Rollo <eferollo@gmail.com>
1 parent feb2756 commit 8b5d6a7

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

security/manager/ssl/nsNSSCallbacks.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,9 @@ nsCString getSignatureName(uint32_t aSignatureScheme) {
731731
case ssl_sig_mldsa87:
732732
signatureName = "ML-DSA-87"_ns;
733733
break;
734+
case ssl_sig_mldsa65_ed25519:
735+
signatureName = "MLDSA65-ED25519"_ns;
736+
break;
734737
// All other groups are not enabled in Firefox. See sEnabledSignatureSchemes
735738
// in nsNSSIOLayer.cpp.
736739
default:
@@ -1075,6 +1078,9 @@ void HandshakeCallback(PRFileDesc* fd, void* client_data) {
10751078
glean::ssl::auth_mldsa_key_size_full.AccumulateSingleSample(
10761079
NonECCKeySize(channelInfo.authKeyBits)); */
10771080
break;
1081+
case ssl_auth_mldsa65_ed25519:
1082+
/* TODO: metrics */
1083+
break;
10781084
default:
10791085
MOZ_CRASH("impossible auth algorithm");
10801086
break;

security/manager/ssl/nsNSSIOLayer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,7 @@ static PRFileDesc* nsSSLIOLayerImportFD(PRFileDesc* fd,
13011301
// Please change getSignatureName in nsNSSCallbacks.cpp when changing the list
13021302
// here. See NOTE at SSL_SignatureSchemePrefSet call site.
13031303
static const SSLSignatureScheme sEnabledSignatureSchemes[] = {
1304+
ssl_sig_mldsa65_ed25519,
13041305
ssl_sig_mldsa87,
13051306
ssl_sig_mldsa65,
13061307
ssl_sig_mldsa44,

security/nss/lib/ssl/ssl3con.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ static ssl3CipherSuiteCfg cipherSuites[ssl_V3_SUITES_IMPLEMENTED] = {
191191
* cipher suites just for consistency.
192192
*/
193193
static const SSLSignatureScheme defaultSignatureSchemes[] = {
194+
ssl_sig_mldsa65_ed25519,
194195
ssl_sig_mldsa87,
195196
ssl_sig_mldsa65,
196197
ssl_sig_mldsa44,
@@ -367,6 +368,7 @@ static const CK_MECHANISM_TYPE auth_alg_defs[] = {
367368
CKM_RSA_PKCS_PSS, /* ssl_auth_rsa_pss */
368369
CKM_NSS_HKDF_SHA256, /* ssl_auth_psk (just check for HKDF) */
369370
CKM_ML_DSA, /* ssl_auth_mldsa */
371+
CKM_MLDSA65_ED25519, /* ssl_auth_mldsa65_ed25519 */
370372
CKM_INVALID_MECHANISM /* ssl_auth_tls13_any */
371373
};
372374
PR_STATIC_ASSERT(PR_ARRAY_SIZE(auth_alg_defs) == ssl_auth_size);
@@ -765,7 +767,8 @@ ssl_HasCert(const sslSocket *ss, PRUint16 maxVersion, SSLAuthType authType)
765767
{
766768
PRCList *cursor;
767769
if (authType == ssl_auth_null || authType == ssl_auth_psk ||
768-
authType == ssl_auth_tls13_any || authType == ssl_auth_mldsa) {
770+
authType == ssl_auth_tls13_any || authType == ssl_auth_mldsa ||
771+
authType == ssl_auth_mldsa65_ed25519) {
769772
return PR_TRUE;
770773
}
771774
for (cursor = PR_NEXT_LINK(&ss->serverCerts);
@@ -1412,6 +1415,9 @@ ssl_VerifySignedHashesWithPubKey(sslSocket *ss, SECKEYPublicKey *key,
14121415
case ssl_sig_mldsa87:
14131416
encAlg = SEC_OID_MLDSA_87_SIGNATURE;
14141417
break;
1418+
case ssl_sig_mldsa65_ed25519:
1419+
encAlg = SEC_OID_MLDSA65_ED25519_SHA512_SIGNATURE;
1420+
break;
14151421
default:
14161422
PORT_SetError(SEC_ERROR_INVALID_ALGORITHM);
14171423
goto loser;
@@ -4452,6 +4458,7 @@ ssl_SignatureSchemeToHashType(SSLSignatureScheme scheme)
44524458
case ssl_sig_slhdsa_shake_192f:
44534459
case ssl_sig_slhdsa_shake_256s:
44544460
case ssl_sig_slhdsa_shake_256f:
4461+
case ssl_sig_mldsa65_ed25519:
44554462
break;
44564463
}
44574464
PORT_Assert(0);
@@ -4462,7 +4469,7 @@ static PRBool
44624469
ssl_SignatureSchemeMatchesSpkiOid(SSLSignatureScheme scheme, SECOidTag spkiOid)
44634470
{
44644471
if (scheme == ssl_sig_mldsa44 || scheme == ssl_sig_mldsa65 ||
4465-
scheme == ssl_sig_mldsa87) {
4472+
scheme == ssl_sig_mldsa87 || scheme == ssl_sig_mldsa65_ed25519) {
44664473
return PR_TRUE;
44674474
}
44684475

@@ -4732,6 +4739,7 @@ ssl_IsSupportedSignatureScheme(SSLSignatureScheme scheme)
47324739
case ssl_sig_mldsa44:
47334740
case ssl_sig_mldsa65:
47344741
case ssl_sig_mldsa87:
4742+
case ssl_sig_mldsa65_ed25519:
47354743
return PR_TRUE;
47364744
break;
47374745

@@ -4847,6 +4855,8 @@ ssl_SignatureSchemeToAuthType(SSLSignatureScheme scheme)
48474855
case ssl_sig_mldsa65:
48484856
case ssl_sig_mldsa87:
48494857
return ssl_auth_mldsa;
4858+
case ssl_sig_mldsa65_ed25519:
4859+
return ssl_auth_mldsa65_ed25519;
48504860

48514861
default:
48524862
PORT_Assert(0);
@@ -11777,6 +11787,11 @@ ssl_SetAuthKeyBits(sslSocket *ss, const SECKEYPublicKey *pubKey)
1177711787
minKey = ss->sec.authKeyBits;
1177811788
break;
1177911789

11790+
case mldsa65Ed25519Key:
11791+
/* Assume we only support mldsa keys we like */
11792+
minKey = ss->sec.authKeyBits;
11793+
break;
11794+
1178011795
default:
1178111796
FATAL_ERROR(ss, SEC_ERROR_LIBRARY_FAILURE, internal_error);
1178211797
return SECFailure;

security/nss/lib/ssl/sslt.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ typedef enum {
175175
ssl_sig_slhdsa_shake_256s = 0x091b,
176176
ssl_sig_slhdsa_shake_256f = 0x091c,
177177

178+
/*
179+
* Composite ML-DSA SignatureSchemes as defined in
180+
* https://datatracker.ietf.org/doc/draft-reddy-tls-composite-mldsa/04/
181+
*/
182+
ssl_sig_mldsa65_ed25519 = 0x090b,
183+
178184
/* The following value (which can't be used in the protocol), represents
179185
* the RSA signature using SHA-1 and MD5 that is used in TLS 1.0 and 1.1.
180186
* This is reported as a signature scheme when TLS 1.0 or 1.1 is used.
@@ -204,7 +210,8 @@ typedef enum {
204210
ssl_auth_rsa_pss = 8, /* RSA signing with a PSS key. */
205211
ssl_auth_psk = 9,
206212
ssl_auth_mldsa = 10,
207-
ssl_auth_tls13_any = 11,
213+
ssl_auth_mldsa65_ed25519 = 11,
214+
ssl_auth_tls13_any = 12,
208215
ssl_auth_size /* number of authentication types */
209216
} SSLAuthType;
210217

0 commit comments

Comments
 (0)