summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitry Kasatkin <dmitry.kasatkin@intel.com>2012-09-12 13:26:55 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-02 10:29:55 -0700
commitdd8121960467e40388876403758334fa91516db2 (patch)
tree77174d90183bdd6a1940490ef46da3c67c5b253f /lib
parente3c9398035cbf79a2ab75c2f43de999fc9a726f4 (diff)
downloadlinux-3.10-dd8121960467e40388876403758334fa91516db2.tar.gz
linux-3.10-dd8121960467e40388876403758334fa91516db2.tar.bz2
linux-3.10-dd8121960467e40388876403758334fa91516db2.zip
digsig: add hash size comparision on signature verification
commit bc01637a80f5b670bd70a0279d3f93fa8de1c96d upstream. When pkcs_1_v1_5_decode_emsa() returns without error and hash sizes do not match, hash comparision is not done and digsig_verify_rsa() returns no error. This is a bug and this patch fixes it. The bug was introduced in v3.3 by commit b35e286a640f ("lib/digsig: pkcs_1_v1_5_decode_emsa cleanup"). Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/digsig.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/digsig.c b/lib/digsig.c
index 286d558033e..8c0e62975c8 100644
--- a/lib/digsig.c
+++ b/lib/digsig.c
@@ -163,9 +163,11 @@ static int digsig_verify_rsa(struct key *key,
memcpy(out1 + head, p, l);
err = pkcs_1_v1_5_decode_emsa(out1, len, mblen, out2, &len);
+ if (err)
+ goto err;
- if (!err && len == hlen)
- err = memcmp(out2, h, hlen);
+ if (len != hlen || memcmp(out2, h, hlen))
+ err = -EINVAL;
err:
mpi_free(in);