Skip to content

Commit

Permalink
add some sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaeckel committed Jan 22, 2020
1 parent da41c7a commit d1ac928
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/pk/ecc/ecc_sign_hash_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ int ecc_sign_hash_internal(const unsigned char *in, unsigned long inlen,
if ((err = mp_read_unsigned_bin(e, (unsigned char *)in, pbytes)) != CRYPT_OK) { goto errnokey; }
}
else {
if (pbytes >= MAXBLOCKSIZE) {
err = CRYPT_BUFFER_OVERFLOW;
goto error;
}
shift_right = 8 - pbits % 8;
for (i=0, ch=0; i<pbytes; i++) {
buf[i] = ch;
Expand Down
4 changes: 4 additions & 0 deletions src/pk/ecc/ecc_verify_hash_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ int ecc_verify_hash_internal(void *r, void *s,
if ((err = mp_read_unsigned_bin(e, (unsigned char *)hash, pbytes)) != CRYPT_OK) { goto error; }
}
else {
if (pbytes >= MAXBLOCKSIZE) {
err = CRYPT_BUFFER_OVERFLOW;
goto error;
}
shift_right = 8 - pbits % 8;
for (i=0, ch=0; i<pbytes; i++) {
buf[i] = ch;
Expand Down
5 changes: 5 additions & 0 deletions src/pk/ecc/ecc_verify_hash_rfc5656.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ int ecc_verify_hash_rfc5656(const unsigned char *sig, unsigned long siglen,
LTC_SSHDATA_MPINT, s,
LTC_SSHDATA_EOL, NULL)) != CRYPT_OK) goto error;

if (slen != siglen) {
err = CRYPT_INVALID_PACKET;
goto error;
}

/* Check curve matches identifier string */
if ((err = ecc_ssh_ecdsa_encode_name(name2, &name2len, key)) != CRYPT_OK) goto error;
if (XSTRCMP(name,name2) != 0) {
Expand Down

0 comments on commit d1ac928

Please sign in to comment.