Fixed size check in ecc_get_key, Fixes #630
This commit is contained in:
parent
71c93ed301
commit
03b3538830
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user