Skip to content

Commit 5e3d1ca

Browse files
committed
- mldsa-65 for test
1 parent cad5489 commit 5e3d1ca

File tree

2 files changed

+0
-887
lines changed

2 files changed

+0
-887
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
@@ -111,86 +111,6 @@ bool libspdm_fips_selftest_mldsa(void *fips_selftest_context)
111111
libspdm_mldsa_free(dsa_context_44);
112112
#endif/*LIBSPDM_ML_DSA_44_SUPPORT*/
113113

114-
#if LIBSPDM_ML_DSA_65_SUPPORT
115-
uint8_t signature_65[3309];
116-
size_t sig_size_65;
117-
void *dsa_context_65;
118-
119-
sig_size_65 = sizeof(signature_65);
120-
libspdm_zero_mem(signature_65, sig_size_65);
121-
122-
/* KAT Vectors */
123-
extern const uint8_t message_hash_65[84];
124-
extern const uint8_t priv_key_65[4032];
125-
extern const uint8_t public_key_65[1952];
126-
extern const uint8_t sign_context_65[24];
127-
extern const uint8_t expected_signature_65[3309];
128-
129-
dsa_context_65 = libspdm_mldsa_new(LIBSPDM_CRYPTO_NID_ML_DSA_65);
130-
if (dsa_context_65 == NULL) {
131-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "dsa_context_65 new failed \n"));
132-
result = false;
133-
goto update;
134-
}
135-
136-
result = libspdm_mldsa_set_pubkey(dsa_context_65, public_key_65, sizeof(public_key_65));
137-
if (!result) {
138-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "dsa_context_65 set public_key_65 failed \n"));
139-
libspdm_mldsa_free(dsa_context_65);
140-
result = false;
141-
goto update;
142-
}
143-
144-
result = libspdm_mldsa_set_privkey(dsa_context_65, priv_key_65, sizeof(priv_key_65));
145-
if (!result) {
146-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "dsa_context_65 set priv_key_65 failed \n"));
147-
libspdm_mldsa_free(dsa_context_65);
148-
result = false;
149-
goto update;
150-
}
151-
152-
/*mldsa KAT test*/
153-
result = libspdm_mldsa_sign_ex(dsa_context_65,
154-
sign_context_65, sizeof(sign_context_65),
155-
message_hash_65, sizeof(message_hash_65),
156-
signature_65, &sig_size_65,
157-
true);
158-
if (!result) {
159-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "ML-DSA-65 sign failed \n"));
160-
libspdm_mldsa_free(dsa_context_65);
161-
result = false;
162-
goto update;
163-
}
164-
165-
if (sig_size_65 != sizeof(expected_signature_65)) {
166-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "ML-DSA-65 KAT failed \n"));
167-
libspdm_mldsa_free(dsa_context_65);
168-
result = false;
169-
goto update;
170-
}
171-
172-
if (!libspdm_consttime_is_mem_equal(signature_65, expected_signature_65,
173-
sizeof(expected_signature_65))) {
174-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "ML-DSA-65 KAT failed \n"));
175-
libspdm_mldsa_free(dsa_context_65);
176-
result = false;
177-
goto update;
178-
}
179-
180-
result = libspdm_mldsa_verify(dsa_context_65,
181-
sign_context_65, sizeof(sign_context_65),
182-
message_hash_65, sizeof(message_hash_65),
183-
signature_65, sig_size_65);
184-
if (!result) {
185-
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "ML-DSA-65 selftest failed \n"));
186-
libspdm_mldsa_free(dsa_context_65);
187-
result = false;
188-
goto update;
189-
}
190-
191-
libspdm_mldsa_free(dsa_context_65);
192-
#endif/*LIBSPDM_ML_DSA_65_SUPPORT*/
193-
194114
update:
195115
/* mark it as tested*/
196116
context->tested_algo |= LIBSPDM_FIPS_SELF_TEST_ML_DSA;

0 commit comments

Comments
 (0)