Skip to content

Commit

Permalink
PCT deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemas committed Mar 6, 2025
1 parent bed4702 commit 9373d75
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions crypto/fipsmodule/ml_dsa/ml_dsa_ref/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,27 @@
static int ml_dsa_keypair_pct(ml_dsa_params *params,
uint8_t *pk,
uint8_t *sk) {
uint8_t message[1] = {0};
uint8_t signature[MLDSA87_SIGNATURE_BYTES];
int ret = ml_dsa_sign(params, signature, &params->bytes, message, sizeof(message), NULL, 0, sk);
uint8_t rnd[ML_DSA_SEEDBYTES] = {0};
uint8_t message[32] = {
0x4a, 0x41, 0x4b, 0x45, 0x20, 0x4d, 0x41, 0x53, 0x53, 0x49, 0x4d, 0x4f,
0x20, 0x41, 0x57, 0x53, 0x32, 0x30, 0x32, 0x35, 0x2e, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
};

int ret = ml_dsa_sign_internal(params, signature, &params->bytes, message,
sizeof(message), NULL, 0, rnd, sk, 0);
if (ret < 0) {
return 0;
}
if (boringssl_fips_break_test("MLDSA_PWCT")) {
message[0] = ~message[0];
}
return ml_dsa_verify(params, signature, params->bytes, message, sizeof(message), NULL, 0, pk) == 0;

int verify_result = ml_dsa_verify_internal(params, signature, params->bytes, message,
sizeof(message), NULL, 0, pk, 0);

return verify_result == 0;
}
#endif

Expand Down

0 comments on commit 9373d75

Please sign in to comment.