Skip to content

Commit eab7426

Browse files
committed
Rename ML-DSA wc_PqcSignatureType entry
1 parent 44074fd commit eab7426

7 files changed

Lines changed: 39 additions & 33 deletions

File tree

src/ssl_api_pk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static int check_cert_key_dev(word32 keyOID, byte* privKey, word32 privSz,
122122
case DILITHIUM_LEVEL5k:
123123
#endif
124124
ret = wc_CryptoCb_PqcSignatureCheckPrivKey(pkey,
125-
WC_PQC_SIG_TYPE_DILITHIUM, pubKey, pubSz);
125+
WC_PQC_SIG_TYPE_MLDSA, pubKey, pubSz);
126126
break;
127127
#endif
128128
#if defined(HAVE_FALCON)

wolfcrypt/src/cryptocb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ int wc_CryptoCb_PqcKemGetDevId(int type, void* key)
11761176
return devId;
11771177

11781178
/* get devId */
1179-
if (type == WC_PQC_KEM_TYPE_KYBER) {
1179+
if (type == WC_PQC_KEM_TYPE_MLKEM) {
11801180
devId = ((KyberKey*) key)->devId;
11811181
}
11821182

@@ -1299,7 +1299,7 @@ int wc_CryptoCb_PqcSigGetDevId(int type, void* key)
12991299

13001300
/* get devId */
13011301
#if defined(HAVE_DILITHIUM)
1302-
if (type == WC_PQC_SIG_TYPE_DILITHIUM) {
1302+
if (type == WC_PQC_SIG_TYPE_MLDSA) {
13031303
devId = ((dilithium_key*) key)->devId;
13041304
}
13051305
#endif

wolfcrypt/src/wc_mldsa.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10146,7 +10146,7 @@ int wc_MlDsaKey_MakeKey(wc_MlDsaKey* key, WC_RNG* rng)
1014610146
#endif
1014710147
{
1014810148
ret = wc_CryptoCb_MakePqcSignatureKey(rng,
10149-
WC_PQC_SIG_TYPE_DILITHIUM, key->level, key);
10149+
WC_PQC_SIG_TYPE_MLDSA, key->level, key);
1015010150
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
1015110151
return ret;
1015210152
/* fall-through when unavailable */
@@ -10272,7 +10272,7 @@ int wc_MlDsaKey_SignCtx(wc_MlDsaKey* key, const byte* ctx, byte ctxLen,
1027210272
#endif
1027310273
{
1027410274
ret = wc_CryptoCb_PqcSign(msg, msgLen, sig, sigLen, ctx, ctxLen,
10275-
WC_HASH_TYPE_NONE, rng, WC_PQC_SIG_TYPE_DILITHIUM, key);
10275+
WC_HASH_TYPE_NONE, rng, WC_PQC_SIG_TYPE_MLDSA, key);
1027610276
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
1027710277
return ret;
1027810278
/* fall-through when unavailable */
@@ -10322,7 +10322,7 @@ int wc_MlDsaKey_Sign(wc_MlDsaKey* key, byte* sig, word32 *sigLen,
1032210322
#endif
1032310323
{
1032410324
ret = wc_CryptoCb_PqcSign(msg, msgLen, sig, sigLen, NULL, 0,
10325-
WC_HASH_TYPE_NONE, rng, WC_PQC_SIG_TYPE_DILITHIUM, key);
10325+
WC_HASH_TYPE_NONE, rng, WC_PQC_SIG_TYPE_MLDSA, key);
1032610326
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
1032710327
return ret;
1032810328
/* fall-through when unavailable */
@@ -10377,7 +10377,7 @@ int wc_MlDsaKey_SignCtxHash(wc_MlDsaKey* key, const byte* ctx, byte ctxLen,
1037710377
#endif
1037810378
{
1037910379
ret = wc_CryptoCb_PqcSign(hash, hashLen, sig, sigLen, ctx, ctxLen,
10380-
(word32)hashAlg, rng, WC_PQC_SIG_TYPE_DILITHIUM, key);
10380+
(word32)hashAlg, rng, WC_PQC_SIG_TYPE_MLDSA, key);
1038110381
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
1038210382
return ret;
1038310383
/* fall-through when unavailable */
@@ -10591,7 +10591,7 @@ int wc_MlDsaKey_VerifyCtx(wc_MlDsaKey* key, const byte* sig, word32 sigLen,
1059110591
#endif
1059210592
{
1059310593
ret = wc_CryptoCb_PqcVerify(sig, sigLen, msg, msgLen, ctx, ctxLen,
10594-
WC_HASH_TYPE_NONE, res, WC_PQC_SIG_TYPE_DILITHIUM, key);
10594+
WC_HASH_TYPE_NONE, res, WC_PQC_SIG_TYPE_MLDSA, key);
1059510595
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
1059610596
return ret;
1059710597
/* fall-through when unavailable */
@@ -10641,7 +10641,7 @@ int wc_MlDsaKey_Verify(wc_MlDsaKey* key, const byte* sig, word32 sigLen,
1064110641
#endif
1064210642
{
1064310643
ret = wc_CryptoCb_PqcVerify(sig, sigLen, msg, msgLen, NULL, 0,
10644-
WC_HASH_TYPE_NONE, res, WC_PQC_SIG_TYPE_DILITHIUM, key);
10644+
WC_HASH_TYPE_NONE, res, WC_PQC_SIG_TYPE_MLDSA, key);
1064510645
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
1064610646
return ret;
1064710647
/* fall-through when unavailable */
@@ -10696,7 +10696,7 @@ int wc_MlDsaKey_VerifyCtxHash(wc_MlDsaKey* key, const byte* sig, word32 sigLen,
1069610696
#endif
1069710697
{
1069810698
ret = wc_CryptoCb_PqcVerify(sig, sigLen, hash, hashLen, ctx, ctxLen,
10699-
(word32)hashAlg, res, WC_PQC_SIG_TYPE_DILITHIUM, key);
10699+
(word32)hashAlg, res, WC_PQC_SIG_TYPE_MLDSA, key);
1070010700
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
1070110701
return ret;
1070210702
/* fall-through when unavailable */
@@ -11010,7 +11010,7 @@ void wc_MlDsaKey_Free(wc_MlDsaKey* key)
1101011010
if (key->devId != INVALID_DEVID) {
1101111011
(void)wc_CryptoCb_Free(key->devId, WC_ALGO_TYPE_PK,
1101211012
WC_PK_TYPE_PQC_SIG_KEYGEN,
11013-
WC_PQC_SIG_TYPE_DILITHIUM,
11013+
WC_PQC_SIG_TYPE_MLDSA,
1101411014
(void*)key);
1101511015
/* always continue to software cleanup */
1101611016
}

wolfcrypt/src/wc_mlkem.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ int wc_MlKemKey_Free(MlKemKey* key)
582582
#if defined(WOLF_CRYPTO_CB) && defined(WOLF_CRYPTO_CB_FREE)
583583
if (key->devId != INVALID_DEVID) {
584584
(void)wc_CryptoCb_Free(key->devId, WC_ALGO_TYPE_PK,
585-
WC_PK_TYPE_PQC_KEM_KEYGEN, WC_PQC_KEM_TYPE_KYBER, (void*)key);
585+
WC_PK_TYPE_PQC_KEM_KEYGEN, WC_PQC_KEM_TYPE_MLKEM, (void*)key);
586586
/* always continue to software cleanup */
587587
}
588588
#endif
@@ -669,7 +669,7 @@ int wc_MlKemKey_MakeKey(MlKemKey* key, WC_RNG* rng)
669669
#else
670670
if (ret == 0) {
671671
#endif
672-
ret = wc_CryptoCb_MakePqcKemKey(rng, WC_PQC_KEM_TYPE_KYBER, key->type,
672+
ret = wc_CryptoCb_MakePqcKemKey(rng, WC_PQC_KEM_TYPE_MLKEM, key->type,
673673
key);
674674
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
675675
return ret;
@@ -1409,7 +1409,7 @@ int wc_MlKemKey_Encapsulate(MlKemKey* key, unsigned char* ct, unsigned char* ss,
14091409
if (ret == 0) {
14101410
#endif
14111411
ret = wc_CryptoCb_PqcEncapsulate(ct, ctlen, ss, WC_ML_KEM_SS_SZ, rng,
1412-
WC_PQC_KEM_TYPE_KYBER, key);
1412+
WC_PQC_KEM_TYPE_MLKEM, key);
14131413
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
14141414
return ret;
14151415
/* fall-through when unavailable */
@@ -1896,7 +1896,7 @@ int wc_MlKemKey_Decapsulate(MlKemKey* key, unsigned char* ss,
18961896
if (ret == 0) {
18971897
#endif
18981898
ret = wc_CryptoCb_PqcDecapsulate(ct, ctSz, ss, WC_ML_KEM_SS_SZ,
1899-
WC_PQC_KEM_TYPE_KYBER, key);
1899+
WC_PQC_KEM_TYPE_MLKEM, key);
19001900
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
19011901
return ret;
19021902
/* fall-through when unavailable */

wolfcrypt/src/wc_pkcs11.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4703,7 +4703,7 @@ static int Pkcs11PqcKemKeyGen(Pkcs11Session* session, wc_CryptoInfo* info)
47034703
int ret = 0;
47044704

47054705
switch (info->pk.pqc_kem_kg.type) {
4706-
case WC_PQC_KEM_TYPE_KYBER:
4706+
case WC_PQC_KEM_TYPE_MLKEM:
47074707
ret = Pkcs11MlKemKeyGen(session,
47084708
(MlKemKey*)info->pk.pqc_kem_kg.key);
47094709
break;
@@ -4720,7 +4720,7 @@ static int Pkcs11PqcKemEncapsulate(Pkcs11Session* session, wc_CryptoInfo* info)
47204720
int ret = 0;
47214721

47224722
switch (info->pk.pqc_encaps.type) {
4723-
case WC_PQC_KEM_TYPE_KYBER:
4723+
case WC_PQC_KEM_TYPE_MLKEM:
47244724
ret = Pkcs11MlKemEncapsulate(session, info);
47254725
break;
47264726
default:
@@ -4736,7 +4736,7 @@ static int Pkcs11PqcKemDecapsulate(Pkcs11Session* session, wc_CryptoInfo* info)
47364736
int ret = 0;
47374737

47384738
switch (info->pk.pqc_decaps.type) {
4739-
case WC_PQC_KEM_TYPE_KYBER:
4739+
case WC_PQC_KEM_TYPE_MLKEM:
47404740
ret = Pkcs11MlKemDecapsulate(session, info);
47414741
break;
47424742
default:
@@ -5426,7 +5426,7 @@ static int Pkcs11PqcSigKeyGen(Pkcs11Session* session, wc_CryptoInfo* info)
54265426
int ret = 0;
54275427

54285428
switch (info->pk.pqc_sig_kg.type) {
5429-
case WC_PQC_SIG_TYPE_DILITHIUM:
5429+
case WC_PQC_SIG_TYPE_MLDSA:
54305430
ret = Pkcs11MldsaKeyGen(session,
54315431
(wc_MlDsaKey*)info->pk.pqc_sig_kg.key);
54325432
break;
@@ -5451,7 +5451,7 @@ static int Pkcs11PqcSigSign(Pkcs11Session* session, wc_CryptoInfo* info)
54515451
int ret = 0;
54525452

54535453
switch (info->pk.pqc_sign.type) {
5454-
case WC_PQC_SIG_TYPE_DILITHIUM:
5454+
case WC_PQC_SIG_TYPE_MLDSA:
54555455
ret = Pkcs11MldsaSign(session, info);
54565456
break;
54575457
default:
@@ -5476,7 +5476,7 @@ static int Pkcs11PqcSigVerify(Pkcs11Session* session, wc_CryptoInfo* info)
54765476
int ret = 0;
54775477

54785478
switch (info->pk.pqc_verify.type) {
5479-
case WC_PQC_SIG_TYPE_DILITHIUM:
5479+
case WC_PQC_SIG_TYPE_MLDSA:
54805480
ret = Pkcs11MldsaVerify(session, info);
54815481
break;
54825482
default:
@@ -5502,7 +5502,7 @@ static int Pkcs11PqcSigCheckPrivKey(Pkcs11Session* session, wc_CryptoInfo* info)
55025502
int ret = 0;
55035503

55045504
switch (info->pk.pqc_sig_check.type) {
5505-
case WC_PQC_SIG_TYPE_DILITHIUM:
5505+
case WC_PQC_SIG_TYPE_MLDSA:
55065506
ret = Pkcs11MldsaCheckPrivKey(session, info);
55075507
break;
55085508
default:
@@ -6632,7 +6632,7 @@ int wc_Pkcs11_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
66326632
#ifdef HAVE_DILITHIUM
66336633
if (info->free.algo == WC_ALGO_TYPE_PK &&
66346634
info->free.type == WC_PK_TYPE_PQC_SIG_KEYGEN &&
6635-
info->free.subType == WC_PQC_SIG_TYPE_DILITHIUM) {
6635+
info->free.subType == WC_PQC_SIG_TYPE_MLDSA) {
66366636
ret = Pkcs11OpenSession(token, &session, readWrite);
66376637
if (ret == 0) {
66386638
ret = Pkcs11MldsaDeletePrivKey(&session,
@@ -6645,7 +6645,7 @@ int wc_Pkcs11_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
66456645
#ifdef WOLFSSL_HAVE_MLKEM
66466646
if (info->free.algo == WC_ALGO_TYPE_PK &&
66476647
info->free.type == WC_PK_TYPE_PQC_KEM_KEYGEN &&
6648-
info->free.subType == WC_PQC_KEM_TYPE_KYBER) {
6648+
info->free.subType == WC_PQC_KEM_TYPE_MLKEM) {
66496649
ret = Pkcs11OpenSession(token, &session, readWrite);
66506650
if (ret == 0) {
66516651
ret = Pkcs11MlKemDeletePrivKey(&session,

wolfcrypt/test/test.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72266,7 +72266,7 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
7226672266
#endif /* WOLFSSL_HAVE_SLHDSA */
7226772267
#ifdef WOLFSSL_HAVE_MLKEM
7226872268
if (info->pk.type == WC_PK_TYPE_PQC_KEM_KEYGEN) {
72269-
if ((info->pk.pqc_kem_kg.type == WC_PQC_KEM_TYPE_KYBER) &&
72269+
if ((info->pk.pqc_kem_kg.type == WC_PQC_KEM_TYPE_MLKEM) &&
7227072270
(info->pk.pqc_kem_kg.key != NULL)) {
7227172271
MlKemKey* key = (MlKemKey*)info->pk.pqc_kem_kg.key;
7227272272
int hashDevId = key->hash.devId;
@@ -72286,7 +72286,7 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
7228672286
}
7228772287
}
7228872288
else if (info->pk.type == WC_PK_TYPE_PQC_KEM_ENCAPS) {
72289-
if ((info->pk.pqc_encaps.type == WC_PQC_KEM_TYPE_KYBER) &&
72289+
if ((info->pk.pqc_encaps.type == WC_PQC_KEM_TYPE_MLKEM) &&
7229072290
(info->pk.pqc_encaps.key != NULL)) {
7229172291
MlKemKey* key = (MlKemKey*)info->pk.pqc_encaps.key;
7229272292
int hashDevId = key->hash.devId;
@@ -72309,7 +72309,7 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
7230972309
}
7231072310
}
7231172311
else if (info->pk.type == WC_PK_TYPE_PQC_KEM_DECAPS) {
72312-
if ((info->pk.pqc_decaps.type == WC_PQC_KEM_TYPE_KYBER) &&
72312+
if ((info->pk.pqc_decaps.type == WC_PQC_KEM_TYPE_MLKEM) &&
7231372313
(info->pk.pqc_decaps.key != NULL)) {
7231472314
MlKemKey* key = (MlKemKey*)info->pk.pqc_decaps.key;
7231572315
int hashDevId = key->hash.devId;
@@ -73051,7 +73051,7 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
7305173051
case WC_PK_TYPE_PQC_SIG_KEYGEN:
7305273052
{
7305373053
#ifdef HAVE_DILITHIUM
73054-
if (info->free.subType == WC_PQC_SIG_TYPE_DILITHIUM) {
73054+
if (info->free.subType == WC_PQC_SIG_TYPE_MLDSA) {
7305573055
dilithium_key* dil = (dilithium_key*)info->free.obj;
7305673056
dil->devId = INVALID_DEVID;
7305773057
wc_dilithium_free(dil);
@@ -73072,7 +73072,7 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
7307273072
#ifdef WOLFSSL_HAVE_MLKEM
7307373073
case WC_PK_TYPE_PQC_KEM_KEYGEN:
7307473074
{
73075-
if (info->free.subType == WC_PQC_KEM_TYPE_KYBER) {
73075+
if (info->free.subType == WC_PQC_KEM_TYPE_MLKEM) {
7307673076
MlKemKey* mlkem = (MlKemKey*)info->free.obj;
7307773077
mlkem->devId = INVALID_DEVID;
7307873078
mlkem->hash.devId = INVALID_DEVID;

wolfssl/wolfcrypt/types.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,11 +1591,14 @@ enum wc_PkType {
15911591
enum wc_PqcKemType {
15921592
WC_PQC_KEM_TYPE_NONE = 0,
15931593
#define _WC_PQC_KEM_TYPE_MAX WC_PQC_KEM_TYPE_NONE
1594-
WC_PQC_KEM_TYPE_KYBER = 1,
1594+
WC_PQC_KEM_TYPE_MLKEM = 1,
15951595
#undef _WC_PQC_KEM_TYPE_MAX
1596-
#define _WC_PQC_KEM_TYPE_MAX WC_PQC_KEM_TYPE_KYBER
1596+
#define _WC_PQC_KEM_TYPE_MAX WC_PQC_KEM_TYPE_MLKEM
15971597
WC_PQC_KEM_TYPE_MAX = _WC_PQC_KEM_TYPE_MAX
15981598
};
1599+
1600+
/* Pre-standardization name retained for backwards compatibility. */
1601+
#define WC_PQC_KEM_TYPE_KYBER WC_PQC_KEM_TYPE_MLKEM
15991602
#endif
16001603

16011604
#if defined(HAVE_DILITHIUM) || defined(HAVE_FALCON) || \
@@ -1605,9 +1608,9 @@ enum wc_PkType {
16051608
WC_PQC_SIG_TYPE_NONE = 0,
16061609
#define _WC_PQC_SIG_TYPE_MAX WC_PQC_SIG_TYPE_NONE
16071610
#if defined(HAVE_DILITHIUM)
1608-
WC_PQC_SIG_TYPE_DILITHIUM = 1,
1611+
WC_PQC_SIG_TYPE_MLDSA = 1,
16091612
#undef _WC_PQC_SIG_TYPE_MAX
1610-
#define _WC_PQC_SIG_TYPE_MAX WC_PQC_SIG_TYPE_DILITHIUM
1613+
#define _WC_PQC_SIG_TYPE_MAX WC_PQC_SIG_TYPE_MLDSA
16111614
#endif
16121615
#if defined(HAVE_FALCON)
16131616
WC_PQC_SIG_TYPE_FALCON = 2,
@@ -1621,6 +1624,9 @@ enum wc_PkType {
16211624
#endif
16221625
WC_PQC_SIG_TYPE_MAX = _WC_PQC_SIG_TYPE_MAX
16231626
};
1627+
1628+
/* Pre-standardization name retained for backwards compatibility. */
1629+
#define WC_PQC_SIG_TYPE_DILITHIUM WC_PQC_SIG_TYPE_MLDSA
16241630
#endif
16251631

16261632
#if defined(WOLFSSL_HAVE_LMS) || defined(WOLFSSL_HAVE_XMSS)

0 commit comments

Comments
 (0)