diff --git a/tests/core/crypto/wycheproof/main.odin b/tests/core/crypto/wycheproof/main.odin index 654ac2a38..bfb4884cd 100644 --- a/tests/core/crypto/wycheproof/main.odin +++ b/tests/core/crypto/wycheproof/main.odin @@ -73,7 +73,7 @@ import "core:testing" // - crypto/legacy/md5 // - crypto/tuplehash -ARENA_SIZE :: 4 * 1024 * 1024 // There is no kill like overkill. +ARENA_SIZE :: 8 * 1024 * 1024 // There is no kill like overkill. BASE_PATH :: ODIN_ROOT + "tests/core/assets/Wycheproof" SUFFIX_TEST_JSON :: "_test.json" diff --git a/tests/core/crypto/wycheproof/pqc.odin b/tests/core/crypto/wycheproof/pqc.odin index d485f621f..07ce2d02c 100644 --- a/tests/core/crypto/wycheproof/pqc.odin +++ b/tests/core/crypto/wycheproof/pqc.odin @@ -494,6 +494,7 @@ test_mldsa :: proc(t: ^testing.T) { test_mldsa_sign :: proc(t: ^testing.T, test_vectors: ^Test_Vectors(Mldsa_Test_Group)) -> bool { FLAG_INTERNAL :: "Internal" + FLAG_RANDOMIZED :: "Randomized" dummy_rnd: [_mldsa.RNDBYTES]byte @@ -511,17 +512,31 @@ test_mldsa_sign :: proc(t: ^testing.T, test_vectors: ^Test_Vectors(Mldsa_Test_Gr priv_key: mldsa.Private_Key tg_len := len(test_group.tests) - if !testing.expectf( - t, - mldsa.private_key_set_bytes(&priv_key, params, seed), - "%s/Sign/%d: failed to set private key from seed: %s", - params_str, - tg_id, - test_group.private_seed, - ) { - num_ran += tg_len - num_failed += tg_len + switch len(test_group.public_key) { + case 0: + for &test_vector in test_group.tests { + num_ran += 1 + switch result_is_invalid(test_vector.result) { + case true: + num_passed += 1 + case false: + num_failed += 1 + } + } continue + case: + if !testing.expectf( + t, + mldsa.private_key_set_bytes(&priv_key, params, seed), + "%s/Sign/%d: failed to set private key from seed: %s", + params_str, + tg_id, + test_group.private_seed, + ) { + num_ran += tg_len + num_failed += tg_len + continue + } } pub_bytes := make([]byte, mldsa.PUBLIC_KEY_SIZES[params]) @@ -575,7 +590,7 @@ test_mldsa_sign :: proc(t: ^testing.T, test_vectors: ^Test_Vectors(Mldsa_Test_Gr ctx := common.hexbytes_decode(test_vector.ctx) msg := common.hexbytes_decode(test_vector.msg) - is_external_mu := slice.contains(test_vector.flags, FLAG_INTERNAL) + is_external_mu := slice.contains(test_vector.flags, FLAG_INTERNAL) || slice.contains(test_vector.flags, FLAG_RANDOMIZED) switch is_external_mu { case false: ok = mldsa.sign( @@ -586,11 +601,16 @@ test_mldsa_sign :: proc(t: ^testing.T, test_vectors: ^Test_Vectors(Mldsa_Test_Gr true, ) case true: + rnd := dummy_rnd[:] + if len(test_vector.rnd) != 0 { + rnd = common.hexbytes_decode(test_vector.rnd) + } + ok = _mldsa.dsa_sign_internal( sig, msg, ctx, - dummy_rnd[:], + rnd, &priv_key, common.hexbytes_decode(test_vector.mu), ) diff --git a/tests/core/crypto/wycheproof/schemas.odin b/tests/core/crypto/wycheproof/schemas.odin index 36fc22d10..2e72a1098 100644 --- a/tests/core/crypto/wycheproof/schemas.odin +++ b/tests/core/crypto/wycheproof/schemas.odin @@ -234,6 +234,7 @@ Mldsa_Test_Vector :: struct { tc_id: int `json:"tcId"`, comment: string `json:"comment"`, msg: common.Hex_Bytes `json:"msg"`, + rnd: common.Hex_Bytes `json:"rnd"`, ctx: common.Hex_Bytes `json:"ctx"`, mu: common.Hex_Bytes `json:"mu"`, sig: common.Hex_Bytes `json:"sig"`,