projects/linux·commit bc01637a

digsig: add hash size comparision on signature verification

bc01637a · Dmitry Kasatkin <[email protected]> · 2012-09-12 13:26:55 +03:00

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").

Cc: [email protected]
Signed-off-by: Dmitry Kasatkin <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
bc01637a80f5b670bd70a0279d3f93fa8de1c96d
Parents
8507876a

Changes

1 files changed · +4 −2

FileStatusAddDelContent
lib/digsig.cmodified+4−2View file

lib/digsig.c

View file
diff --git a/lib/digsig.c b/lib/digsig.c
index 286d558..8c0e629 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);