Skip to content

Commit 489add3

Browse files
committed
- mldsa-44 for test
1 parent 5e3d1ca commit 489add3

File tree

2 files changed

+0
-648
lines changed

2 files changed

+0
-648
lines changed

library/spdm_crypt_lib/fips/libspdm_selftest_mldsa.c

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -31,86 +31,6 @@ bool libspdm_fips_selftest_mldsa(void *fips_selftest_context)
3131
return true;
3232
}
3333

34-
#if LIBSPDM_ML_DSA_44_SUPPORT
35-
uint8_t signature_44[2420];
36-
size_t sig_size_44;
37-
void *dsa_context_44;
38-
39-
sig_size_44 = sizeof(signature_44);
40-
libspdm_zero_mem(signature_44, sig_size_44);
41-
42-
/* KAT Vectors */
43-
extern const uint8_t message_hash_44[35];
44-
extern const uint8_t priv_key_44[2560];
45-
extern const uint8_t public_key_44[1312];
46-
extern const uint8_t sign_context_44[208];
47-
extern const uint8_t expected_signature_44[2420];
48-
49-
dsa_context_44 = libspdm_mldsa_new(LIBSPDM_CRYPTO_NID_ML_DSA_44);
50-
if (dsa_context_44 == NULL) {
51-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "dsa_context_44 new failed \n"));
52-
result = false;
53-
goto update;
54-
}
55-
56-
result = libspdm_mldsa_set_pubkey(dsa_context_44, public_key_44, sizeof(public_key_44));
57-
if (!result) {
58-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "dsa_context_44 set public_key_44 failed \n"));
59-
libspdm_mldsa_free(dsa_context_44);
60-
result = false;
61-
goto update;
62-
}
63-
64-
result = libspdm_mldsa_set_privkey(dsa_context_44, priv_key_44, sizeof(priv_key_44));
65-
if (!result) {
66-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "dsa_context_44 set priv_key_44 failed \n"));
67-
libspdm_mldsa_free(dsa_context_44);
68-
result = false;
69-
goto update;
70-
}
71-
72-
/*mldsa KAT test*/
73-
result = libspdm_mldsa_sign_ex(dsa_context_44,
74-
sign_context_44, sizeof(sign_context_44),
75-
message_hash_44, sizeof(message_hash_44),
76-
signature_44, &sig_size_44,
77-
true);
78-
if (!result) {
79-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "ML-DSA-44 sign failed \n"));
80-
libspdm_mldsa_free(dsa_context_44);
81-
result = false;
82-
goto update;
83-
}
84-
85-
if (sig_size_44 != sizeof(expected_signature_44)) {
86-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "ML-DSA-44 KAT failed \n"));
87-
libspdm_mldsa_free(dsa_context_44);
88-
result = false;
89-
goto update;
90-
}
91-
92-
if (!libspdm_consttime_is_mem_equal(signature_44, expected_signature_44,
93-
sizeof(expected_signature_44))) {
94-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "ML-DSA-44 KAT failed \n"));
95-
libspdm_mldsa_free(dsa_context_44);
96-
result = false;
97-
goto update;
98-
}
99-
100-
result = libspdm_mldsa_verify(dsa_context_44,
101-
sign_context_44, sizeof(sign_context_44),
102-
message_hash_44, sizeof(message_hash_44),
103-
signature_44, sig_size_44);
104-
if (!result) {
105-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "ML-DSA-44 selftest failed \n"));
106-
libspdm_mldsa_free(dsa_context_44);
107-
result = false;
108-
goto update;
109-
}
110-
111-
libspdm_mldsa_free(dsa_context_44);
112-
#endif/*LIBSPDM_ML_DSA_44_SUPPORT*/
113-
11434
update:
11535
/* mark it as tested*/
11636
context->tested_algo |= LIBSPDM_FIPS_SELF_TEST_ML_DSA;

0 commit comments

Comments
 (0)