diff options
author | 2014-06-18 15:42:09 +0000 | |
---|---|---|
committer | 2014-06-18 15:42:09 +0000 | |
commit | bf6a6c75028b0906047f09dec1a5c7d2678ab3f9 (patch) | |
tree | dedfa1796242378ded3e932698835e1d628a31d4 /usr.bin/ssh/sshbuf-getput-crypto.c | |
parent | Update comment; there seems to be no PC-9801 extension board slot on (diff) | |
download | wireguard-openbsd-bf6a6c75028b0906047f09dec1a5c7d2678ab3f9.tar.xz wireguard-openbsd-bf6a6c75028b0906047f09dec1a5c7d2678ab3f9.zip |
The ssh_get_bignum functions must accept the same range of bignums
the corresponding ssh_put_bignum functions create. This fixes the
use of 16384-bit RSA keys (bug reported by Eivind Evensen).
ok djm@
Diffstat (limited to 'usr.bin/ssh/sshbuf-getput-crypto.c')
-rw-r--r-- | usr.bin/ssh/sshbuf-getput-crypto.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/ssh/sshbuf-getput-crypto.c b/usr.bin/ssh/sshbuf-getput-crypto.c index 6cfb25a4836..79951afda17 100644 --- a/usr.bin/ssh/sshbuf-getput-crypto.c +++ b/usr.bin/ssh/sshbuf-getput-crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshbuf-getput-crypto.c,v 1.1 2014/04/30 05:29:56 djm Exp $ */ +/* $OpenBSD: sshbuf-getput-crypto.c,v 1.2 2014/06/18 15:42:09 naddy Exp $ */ /* * Copyright (c) 2011 Damien Miller * @@ -36,10 +36,12 @@ sshbuf_get_bignum2(struct sshbuf *buf, BIGNUM *v) if ((r = sshbuf_peek_string_direct(buf, &d, &len)) < 0) return r; - /* Refuse negative (MSB set) and overlong bignums */ + /* Refuse negative (MSB set) bignums */ if ((len != 0 && (*d & 0x80) != 0)) return SSH_ERR_BIGNUM_IS_NEGATIVE; - if (len > SSHBUF_MAX_BIGNUM) + /* Refuse overlong bignums, allow prepended \0 to avoid MSB set */ + if (len > SSHBUF_MAX_BIGNUM + 1 || + (len == SSHBUF_MAX_BIGNUM + 1 && *d != 0)) return SSH_ERR_BIGNUM_TOO_LARGE; if (v != NULL && BN_bin2bn(d, len, v) == NULL) return SSH_ERR_ALLOC_FAIL; @@ -65,7 +67,7 @@ sshbuf_get_bignum1(struct sshbuf *buf, BIGNUM *v) return SSH_ERR_MESSAGE_INCOMPLETE; len_bits = PEEK_U16(d); len_bytes = (len_bits + 7) >> 3; - if (len_bytes > SSHBUF_MAX_BIGNUM + 1) + if (len_bytes > SSHBUF_MAX_BIGNUM) return SSH_ERR_BIGNUM_TOO_LARGE; if (sshbuf_len(buf) < 2 + len_bytes) return SSH_ERR_MESSAGE_INCOMPLETE; |