diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-08-09 16:11:26 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-08-09 16:11:58 +0200 |
commit | de5499a73eb82e49da841144ea7d8a51892fb9b0 (patch) | |
tree | 01457de2774be1fbf6e10b1ad6d2269879a3f8e1 | |
parent | f5c5678585b0e295cc02e60fd7e8ee244c024596 (diff) | |
download | gnutls-de5499a73eb82e49da841144ea7d8a51892fb9b0.tar.gz |
gcrypt: backported PKCS#1 size check on verification
This backports 7730c6cba3e4d5e1d2c4acf3f433125910635a6e in
libgcrypt code.
-rw-r--r-- | lib/gcrypt/pk.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/gcrypt/pk.c b/lib/gcrypt/pk.c index b1ce8f9409..26f7eef05e 100644 --- a/lib/gcrypt/pk.c +++ b/lib/gcrypt/pk.c @@ -412,6 +412,7 @@ _wrap_gcry_pk_verify (gnutls_pk_algorithm_t algo, int rc = -1, ret; bigint_t hash; bigint_t tmp[2] = { NULL, NULL }; + unsigned pub_size; if (_gnutls_mpi_scan_nz (&hash, vdata->data, vdata->size) != 0) { @@ -479,6 +480,11 @@ _wrap_gcry_pk_verify (gnutls_pk_algorithm_t algo, break; case GNUTLS_PK_RSA: + pub_size = (_gnutls_mpi_get_nbits(pk_params->params[0])+7)/8; + + if (signature->size != pub_size) + return gnutls_assert_val(GNUTLS_E_DECRYPTION_FAILED); + ret = _gnutls_mpi_scan_nz (&tmp[0], signature->data, signature->size); if (ret < 0) { |