Skip to content

Commit 10022f2

Browse files
committed
crypto: Add 128 and 192 variants of SLH-DSA
1 parent 095922b commit 10022f2

File tree

3 files changed

+64
-3
lines changed

3 files changed

+64
-3
lines changed

lib/crypto/c_src/pkey.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,46 @@ struct pkey_type_t pkey_types[] = {
109109
},
110110
#endif
111111
#ifdef HAVE_SLH_DSA
112+
{
113+
.name.atom_str = "slh_dsa_shake_128s",
114+
.evp_pkey_id = EVP_PKEY_SLH_DSA_SHAKE_128S,
115+
.sign.alg_str = "SLH-DSA-SHAKE-128s"
116+
},
117+
{
118+
.name.atom_str = "slh_dsa_shake_128f",
119+
.evp_pkey_id = EVP_PKEY_SLH_DSA_SHAKE_128F,
120+
.sign.alg_str = "SLH-DSA-SHAKE-128f"
121+
},
122+
{
123+
.name.atom_str = "slh_dsa_sha2_128s",
124+
.evp_pkey_id = EVP_PKEY_SLH_DSA_SHA2_128S,
125+
.sign.alg_str = "SLH-DSA-SHA2-128s"
126+
},
127+
{
128+
.name.atom_str = "slh_dsa_sha2_128f",
129+
.evp_pkey_id = EVP_PKEY_SLH_DSA_SHA2_128F,
130+
.sign.alg_str = "SLH-DSA-SHA2-128f"
131+
},
132+
{
133+
.name.atom_str = "slh_dsa_shake_192s",
134+
.evp_pkey_id = EVP_PKEY_SLH_DSA_SHAKE_192S,
135+
.sign.alg_str = "SLH-DSA-SHAKE-192s"
136+
},
137+
{
138+
.name.atom_str = "slh_dsa_shake_192f",
139+
.evp_pkey_id = EVP_PKEY_SLH_DSA_SHAKE_192F,
140+
.sign.alg_str = "SLH-DSA-SHAKE-192f"
141+
},
142+
{
143+
.name.atom_str = "slh_dsa_sha2_192s",
144+
.evp_pkey_id = EVP_PKEY_SLH_DSA_SHA2_192S,
145+
.sign.alg_str = "SLH-DSA-SHA2-192s"
146+
},
147+
{
148+
.name.atom_str = "slh_dsa_sha2_192f",
149+
.evp_pkey_id = EVP_PKEY_SLH_DSA_SHA2_192F,
150+
.sign.alg_str = "SLH-DSA-SHA2-192f"
151+
},
112152
{
113153
.name.atom_str = "slh_dsa_shake_256s",
114154
.evp_pkey_id = EVP_PKEY_SLH_DSA_SHAKE_256S,

lib/crypto/src/crypto.erl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2443,7 +2443,9 @@ rand_seed_nif(_Seed) -> ?nif_stub.
24432443
-type mldsa() :: mldsa44 | mldsa65 | mldsa87.
24442444
-type mldsa_private() :: {seed | expandedkey, binary()}.
24452445
-type mldsa_public() :: binary().
2446-
-type slh_dsa() :: slh_dsa_shake_256s | slh_dsa_shake_256f | slh_dsa_sha2_256s | slh_dsa_sha2_256f.
2446+
-type slh_dsa() :: slh_dsa_shake_128s | slh_dsa_shake_128f | slh_dsa_sha2_128s | slh_dsa_sha2_128f
2447+
| slh_dsa_shake_192s | slh_dsa_shake_192f | slh_dsa_sha2_192s | slh_dsa_sha2_192f
2448+
| slh_dsa_shake_256s | slh_dsa_shake_256f | slh_dsa_sha2_256s | slh_dsa_sha2_256f.
24472449
-type slh_dsa_private() :: binary().
24482450
-type slh_dsa_public() :: binary().
24492451

@@ -2551,6 +2553,14 @@ pkey_sign_nif(_Algorithm, _Type, _Digest, _Key, _Options) -> ?nif_stub.
25512553

25522554
pkey_sign_heavy_nif(_Algorithm, _Type, _Digest, _Key, _Options) -> ?nif_stub.
25532555

2556+
is_heavy(slh_dsa_shake_128s) -> true;
2557+
is_heavy(slh_dsa_shake_128f) -> true;
2558+
is_heavy(slh_dsa_sha2_128s) -> true;
2559+
is_heavy(slh_dsa_sha2_128f) -> true;
2560+
is_heavy(slh_dsa_shake_192s) -> true;
2561+
is_heavy(slh_dsa_shake_192f) -> true;
2562+
is_heavy(slh_dsa_sha2_192s) -> true;
2563+
is_heavy(slh_dsa_sha2_192f) -> true;
25542564
is_heavy(slh_dsa_shake_256s) -> true;
25552565
is_heavy(slh_dsa_shake_256f) -> true;
25562566
is_heavy(slh_dsa_sha2_256s) -> true;

lib/crypto/test/crypto_SUITE.erl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ sign_verify_oqs(_Config) ->
12831283
true = lists:member(Alg, Supported),
12841284
sign_verify_oqs_do(Alg)
12851285
end
1286-
|| Alg <- mldsa_sign_ciphers()],
1286+
|| Alg <- quantum_sign_ciphers()],
12871287
ok
12881288
end.
12891289

@@ -1301,8 +1301,19 @@ sign_verify_oqs_do(Alg) ->
13011301
ok.
13021302

13031303
%% Supported by OpenSSL 3.5
1304-
mldsa_sign_ciphers() ->
1304+
quantum_sign_ciphers() ->
13051305
[mldsa44, mldsa65, mldsa87,
1306+
1307+
slh_dsa_shake_128s,
1308+
slh_dsa_shake_128f,
1309+
slh_dsa_sha2_128s,
1310+
slh_dsa_sha2_128f,
1311+
1312+
slh_dsa_shake_192s,
1313+
slh_dsa_shake_192f,
1314+
slh_dsa_sha2_192s,
1315+
slh_dsa_sha2_192f,
1316+
13061317
slh_dsa_shake_256s,
13071318
slh_dsa_shake_256f,
13081319
slh_dsa_sha2_256s,

0 commit comments

Comments
 (0)