Skip to content

Commit

Permalink
Fixed size check in ecc_get_key, Fixes #630
Browse files Browse the repository at this point in the history
  • Loading branch information
ulikos authored and sjaeckel committed Aug 7, 2023
1 parent 6120c82 commit 48462aa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/pk/ecc/ecc_get_key.c
Expand Up @@ -33,8 +33,11 @@ int ecc_get_key(unsigned char *out, unsigned long *outlen, int type, const ecc_k
}
else if (type == PK_PRIVATE) {
if (key->type != PK_PRIVATE) return CRYPT_PK_TYPE_MISMATCH;
if (size > *outlen) {
*outlen = size;
return CRYPT_BUFFER_OVERFLOW;
}
*outlen = size;
if (size > *outlen) return CRYPT_BUFFER_OVERFLOW;
if ((ksize = mp_unsigned_bin_size(key->k)) > size) return CRYPT_BUFFER_OVERFLOW;
/* pad and store k */
if ((err = mp_to_unsigned_bin(key->k, out + (size - ksize))) != CRYPT_OK) return err;
Expand Down

0 comments on commit 48462aa

Please sign in to comment.