Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 334297
b: refs/heads/master
c: 0b1568a
h: refs/heads/master
i:
  334295: 71bdc24
v: v3
  • Loading branch information
David Howells authored and Rusty Russell committed Oct 8, 2012
1 parent de19355 commit d4842e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 612e0fe99965a4028359cd1da5af56b7f6caf7f6
refs/heads/master: 0b1568a4536ff287a87908d7fc35c05bd7736a53
14 changes: 11 additions & 3 deletions trunk/crypto/asymmetric_keys/rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,23 @@ static int RSA_verify_signature(const struct public_key *key,
return -ENOTSUPP;

/* (1) Check the signature size against the public key modulus size */
k = (mpi_get_nbits(key->rsa.n) + 7) / 8;
k = mpi_get_nbits(key->rsa.n);
tsize = mpi_get_nbits(sig->rsa.s);

tsize = (mpi_get_nbits(sig->rsa.s) + 7) / 8;
/* According to RFC 4880 sec 3.2, length of MPI is computed starting
* from most significant bit. So the RFC 3447 sec 8.2.2 size check
* must be relaxed to conform with shorter signatures - so we fail here
* only if signature length is longer than modulus size.
*/
pr_devel("step 1: k=%zu size(S)=%zu\n", k, tsize);
if (tsize != k) {
if (k < tsize) {
ret = -EBADMSG;
goto error;
}

/* Round up and convert to octets */
k = (k + 7) / 8;

/* (2b) Apply the RSAVP1 verification primitive to the public key */
ret = RSAVP1(key, sig->rsa.s, &m);
if (ret < 0)
Expand Down

0 comments on commit d4842e4

Please sign in to comment.