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 committed Aug 4, 2023
1 parent 1e629e6 commit 4fcc967
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/pk/ecc/ecc_get_key.c
Original file line number Diff line number Diff line change
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 4fcc967

Please sign in to comment.