summaryrefslogtreecommitdiff
path: root/sshbuf-getput-crypto.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-01-14 15:02:39 +0000
committerDamien Miller <djm@mindrot.org>2015-01-15 02:22:18 +1100
commita165bab605f7be55940bb8fae977398e8c96a46d (patch)
tree8a805f18a1f3cc5412b5f94ef64baa275f559a0b /sshbuf-getput-crypto.c
parent7d845f4a0b7ec97887be204c3760e44de8bf1f32 (diff)
downloadopenssh-git-a165bab605f7be55940bb8fae977398e8c96a46d.tar.gz
upstream commit
avoid BIGNUM in KRL code by using a simple bitmap; feedback and ok markus
Diffstat (limited to 'sshbuf-getput-crypto.c')
-rw-r--r--sshbuf-getput-crypto.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/sshbuf-getput-crypto.c b/sshbuf-getput-crypto.c
index 7fad28bb..e2e093c0 100644
--- a/sshbuf-getput-crypto.c
+++ b/sshbuf-getput-crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshbuf-getput-crypto.c,v 1.3 2015/01/12 15:18:07 djm Exp $ */
+/* $OpenBSD: sshbuf-getput-crypto.c,v 1.4 2015/01/14 15:02:39 djm Exp $ */
/*
* Copyright (c) 2011 Damien Miller
*
@@ -38,24 +38,10 @@ sshbuf_get_bignum2(struct sshbuf *buf, BIGNUM *v)
size_t len;
int r;
- if ((r = sshbuf_peek_string_direct(buf, &d, &len)) < 0)
+ if ((r = sshbuf_get_bignum2_bytes_direct(buf, &d, &len)) != 0)
return r;
- /* Refuse negative (MSB set) bignums */
- if ((len != 0 && (*d & 0x80) != 0))
- return SSH_ERR_BIGNUM_IS_NEGATIVE;
- /* 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;
- /* Consume the string */
- if (sshbuf_get_string_direct(buf, NULL, NULL) != 0) {
- /* Shouldn't happen */
- SSHBUF_DBG(("SSH_ERR_INTERNAL_ERROR"));
- SSHBUF_ABORT();
- return SSH_ERR_INTERNAL_ERROR;
- }
return 0;
}