diff options
author | 2010-07-16 14:07:35 +0000 | |
---|---|---|
committer | 2010-07-16 14:07:35 +0000 | |
commit | d57ed660409fc7eed8a1308f1de47d5b73501b83 (patch) | |
tree | 94dcd7d2c13751aacc0231dc64f106276a761ed4 /usr.bin/ssh/ssh-rsa.c | |
parent | diff exits 2 on error, not 1. (diff) | |
download | wireguard-openbsd-d57ed660409fc7eed8a1308f1de47d5b73501b83.tar.xz wireguard-openbsd-d57ed660409fc7eed8a1308f1de47d5b73501b83.zip |
more timing paranoia - compare all parts of the expected decrypted
data before returning. AFAIK not exploitable in the SSH protocol.
"groovy" deraadt@
Diffstat (limited to 'usr.bin/ssh/ssh-rsa.c')
-rw-r--r-- | usr.bin/ssh/ssh-rsa.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/ssh/ssh-rsa.c b/usr.bin/ssh/ssh-rsa.c index 08ee9e290ac..b29546783a2 100644 --- a/usr.bin/ssh/ssh-rsa.c +++ b/usr.bin/ssh/ssh-rsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-rsa.c,v 1.43 2010/07/13 23:13:16 djm Exp $ */ +/* $OpenBSD: ssh-rsa.c,v 1.44 2010/07/16 14:07:35 djm Exp $ */ /* * Copyright (c) 2000, 2003 Markus Friedl <markus@openbsd.org> * @@ -208,7 +208,7 @@ openssh_RSA_verify(int type, u_char *hash, u_int hashlen, u_char *sigbuf, u_int siglen, RSA *rsa) { u_int ret, rsasize, oidlen = 0, hlen = 0; - int len; + int len, oidmatch, hashmatch; const u_char *oid = NULL; u_char *decrypted = NULL; @@ -247,11 +247,13 @@ openssh_RSA_verify(int type, u_char *hash, u_int hashlen, error("bad decrypted len: %d != %d + %d", len, hlen, oidlen); goto done; } - if (timingsafe_bcmp(decrypted, oid, oidlen) != 0) { + oidmatch = timingsafe_bcmp(decrypted, oid, oidlen) == 0; + hashmatch = timingsafe_bcmp(decrypted + oidlen, hash, hlen) == 0; + if (!oidmatch) { error("oid mismatch"); goto done; } - if (timingsafe_bcmp(decrypted + oidlen, hash, hlen) != 0) { + if (!hashmatch) { error("hash mismatch"); goto done; } |