diff options
author | djm@openbsd.org <djm@openbsd.org> | 2015-01-14 15:02:39 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2015-01-15 02:22:18 +1100 |
commit | a165bab605f7be55940bb8fae977398e8c96a46d (patch) | |
tree | 8a805f18a1f3cc5412b5f94ef64baa275f559a0b /sshbuf-getput-crypto.c | |
parent | 7d845f4a0b7ec97887be204c3760e44de8bf1f32 (diff) |
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.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/sshbuf-getput-crypto.c b/sshbuf-getput-crypto.c index 7fad28bb7..e2e093c00 100644 --- a/sshbuf-getput-crypto.c +++ b/sshbuf-getput-crypto.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sshbuf-getput-crypto.c,v 1.3 2015/01/12 15:18:07 djm Exp $ */ | 1 | /* $OpenBSD: sshbuf-getput-crypto.c,v 1.4 2015/01/14 15:02:39 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2011 Damien Miller | 3 | * Copyright (c) 2011 Damien Miller |
4 | * | 4 | * |
@@ -38,24 +38,10 @@ sshbuf_get_bignum2(struct sshbuf *buf, BIGNUM *v) | |||
38 | size_t len; | 38 | size_t len; |
39 | int r; | 39 | int r; |
40 | 40 | ||
41 | if ((r = sshbuf_peek_string_direct(buf, &d, &len)) < 0) | 41 | if ((r = sshbuf_get_bignum2_bytes_direct(buf, &d, &len)) != 0) |
42 | return r; | 42 | return r; |
43 | /* Refuse negative (MSB set) bignums */ | ||
44 | if ((len != 0 && (*d & 0x80) != 0)) | ||
45 | return SSH_ERR_BIGNUM_IS_NEGATIVE; | ||
46 | /* Refuse overlong bignums, allow prepended \0 to avoid MSB set */ | ||
47 | if (len > SSHBUF_MAX_BIGNUM + 1 || | ||
48 | (len == SSHBUF_MAX_BIGNUM + 1 && *d != 0)) | ||
49 | return SSH_ERR_BIGNUM_TOO_LARGE; | ||
50 | if (v != NULL && BN_bin2bn(d, len, v) == NULL) | 43 | if (v != NULL && BN_bin2bn(d, len, v) == NULL) |
51 | return SSH_ERR_ALLOC_FAIL; | 44 | return SSH_ERR_ALLOC_FAIL; |
52 | /* Consume the string */ | ||
53 | if (sshbuf_get_string_direct(buf, NULL, NULL) != 0) { | ||
54 | /* Shouldn't happen */ | ||
55 | SSHBUF_DBG(("SSH_ERR_INTERNAL_ERROR")); | ||
56 | SSHBUF_ABORT(); | ||
57 | return SSH_ERR_INTERNAL_ERROR; | ||
58 | } | ||
59 | return 0; | 45 | return 0; |
60 | } | 46 | } |
61 | 47 | ||