Skip to content

Commit

Permalink
check size of seed/key
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemas committed Feb 3, 2025
1 parent c0b1ad1 commit 57cb9c4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crypto/evp_extra/p_pqdsa_asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,15 @@ static int pqdsa_priv_decode(EVP_PKEY *out, CBS *params, CBS *key, CBS *pubkey)
return 0;
}

// caller can either provide the full key of size |private_key_len| or
// check the size of the provided input against the private key and seed len
if (CBS_len(key) != out->pkey.pqdsa_key->pqdsa->private_key_len &&
CBS_len(key) != out->pkey.pqdsa_key->pqdsa->keygen_seed_len) {
OPENSSL_PUT_ERROR(EVP, EVP_R_INVALID_BUFFER_SIZE);
return 0;
}

// See https://datatracker.ietf.org/doc/draft-ietf-lamps-dilithium-certificates/
// The caller can either provide the full key of size |private_key_len| or
// |keygen_seed_len|.
if (CBS_len(key) == out->pkey.pqdsa_key->pqdsa->private_key_len) {

Expand Down

0 comments on commit 57cb9c4

Please sign in to comment.