Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions test/psa_server/psa_mldsa_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* 3. Import public key with bits=0 (inference from length); verify with it
* 4. Deterministic vs hedged: same message, deterministic produces identical
* signatures, hedged produces different ones
* 5. HashML-DSA(SHA-256): sign_message + verify_message; cross-path
* 5. HashML-DSA(SHA-384): sign_message + verify_message; cross-path
* verify_hash (caller-hashes) and sign_hash + verify_message
* 6. psa_sign_hash with PSA_ALG_ML_DSA -> PSA_ERROR_INVALID_ARGUMENT
* 7. Import seed with bits=0 -> PSA_ERROR_INVALID_ARGUMENT; with bits=192 ->
Expand Down Expand Up @@ -435,9 +435,9 @@ static int test_deterministic_vs_hedged(void)
}

/* -------------------------------------------------------------------------
* Case 5: HashML-DSA(SHA-256): cross-path interop
* Case 5: HashML-DSA(SHA-384): cross-path interop
* a) sign_message -> verify_message
* b) psa_hash_compute(SHA-256) -> verify_hash with the same sig
* b) psa_hash_compute(SHA-384) -> verify_hash with the same sig
* c) sign_hash -> verify_message
* ---------------------------------------------------------------------- */

Expand All @@ -448,7 +448,7 @@ static int test_hash_mldsa_interop(void)
return 0;
#else
static const psa_algorithm_t alg =
PSA_ALG_HASH_ML_DSA(PSA_ALG_SHA_256);
PSA_ALG_HASH_ML_DSA(PSA_ALG_SHA_384);
static const psa_key_usage_t usage =
PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE |
PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH;
Expand All @@ -459,7 +459,7 @@ static int test_hash_mldsa_interop(void)
uint8_t sig_msg[3309]; /* ML-DSA-65 max sig */
uint8_t sig_hash[3309];
size_t sig_msg_len = 0, sig_hash_len = 0;
uint8_t digest[32]; /* SHA-256 */
uint8_t digest[PSA_HASH_LENGTH(PSA_ALG_SHA_384)];
size_t digest_len = 0;
psa_status_t st;

Expand All @@ -483,9 +483,9 @@ static int test_hash_mldsa_interop(void)
}

/* 5b: compute digest, then verify_hash (caller-hashes path) */
st = psa_hash_compute(PSA_ALG_SHA_256, msg, sizeof(msg) - 1,
st = psa_hash_compute(PSA_ALG_SHA_384, msg, sizeof(msg) - 1,
digest, sizeof(digest), &digest_len);
if (check_status(st, "SHA-256 hash_compute for HashML-DSA") != 0) {
if (check_status(st, "SHA-384 hash_compute for HashML-DSA") != 0) {
(void)psa_destroy_key(key);
return 1;
}
Expand Down
18 changes: 9 additions & 9 deletions test/psa_server/psa_sign_context_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ static int test_overlong_context_rejected(void)

/*
* Test 6: HashML-DSA — psa_sign_hash_with_context / psa_verify_hash_with_context.
* - Key policy: PSA_ALG_HASH_ML_DSA(PSA_ALG_SHA_256).
* - Compute SHA-256 digest, sign_hash_with_context("abc").
* - Key policy: PSA_ALG_HASH_ML_DSA(PSA_ALG_SHA_384).
* - Compute SHA-384 digest, sign_hash_with_context("abc").
* - verify_hash_with_context same context → PSA_SUCCESS.
* - verify_hash_with_context different context → PSA_ERROR_INVALID_SIGNATURE.
*/
Expand All @@ -403,7 +403,7 @@ static int test_hash_mldsa65_context(void)
psa_status_t st;
uint8_t sig[MLDSA_65_SIG_SIZE];
size_t sig_len = 0;
uint8_t hash[PSA_HASH_LENGTH(PSA_ALG_SHA_256)];
uint8_t hash[PSA_HASH_LENGTH(PSA_ALG_SHA_384)];
size_t hash_len = 0;
static const uint8_t ctx[] = "abc";
static const uint8_t ctx_other[] = "xyz";
Expand All @@ -414,7 +414,7 @@ static int test_hash_mldsa65_context(void)
psa_set_key_usage_flags(&attrs,
PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH |
PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE);
psa_set_key_algorithm(&attrs, PSA_ALG_HASH_ML_DSA(PSA_ALG_SHA_256));
psa_set_key_algorithm(&attrs, PSA_ALG_HASH_ML_DSA(PSA_ALG_SHA_384));

st = psa_generate_key(&attrs, &key_id);
if (st == PSA_ERROR_NOT_SUPPORTED) {
Expand All @@ -424,8 +424,8 @@ static int test_hash_mldsa65_context(void)
if (expect_status("hash_mldsa65: generate_key", st, PSA_SUCCESS) != 0)
return 1;

/* Compute SHA-256 digest of the message */
st = psa_hash_compute(PSA_ALG_SHA_256,
/* Compute SHA-384 digest of the message */
st = psa_hash_compute(PSA_ALG_SHA_384,
g_msg, sizeof(g_msg) - 1,
hash, sizeof(hash), &hash_len);
if (expect_status("hash_mldsa65: psa_hash_compute", st,
Expand All @@ -436,7 +436,7 @@ static int test_hash_mldsa65_context(void)

/* Sign hash with context "abc" */
st = psa_sign_hash_with_context(key_id,
PSA_ALG_HASH_ML_DSA(PSA_ALG_SHA_256),
PSA_ALG_HASH_ML_DSA(PSA_ALG_SHA_384),
hash, hash_len,
ctx, sizeof(ctx) - 1,
sig, sizeof(sig), &sig_len);
Expand All @@ -448,7 +448,7 @@ static int test_hash_mldsa65_context(void)

/* Verify same context → OK */
st = psa_verify_hash_with_context(key_id,
PSA_ALG_HASH_ML_DSA(PSA_ALG_SHA_256),
PSA_ALG_HASH_ML_DSA(PSA_ALG_SHA_384),
hash, hash_len,
ctx, sizeof(ctx) - 1,
sig, sig_len);
Expand All @@ -460,7 +460,7 @@ static int test_hash_mldsa65_context(void)

/* Verify different context → INVALID_SIGNATURE */
st = psa_verify_hash_with_context(key_id,
PSA_ALG_HASH_ML_DSA(PSA_ALG_SHA_256),
PSA_ALG_HASH_ML_DSA(PSA_ALG_SHA_384),
hash, hash_len,
ctx_other, sizeof(ctx_other) - 1,
sig, sig_len);
Expand Down
Loading