diff options
author | djm@openbsd.org <djm@openbsd.org> | 2019-01-21 09:52:25 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2019-01-21 21:46:57 +1100 |
commit | 803178bd5da7e72be94ba5b4c4c196d4b542da4d (patch) | |
tree | 84d9b3d978b519c5baa8aa4aef5a5151f16a8813 /sshbuf-getput-crypto.c | |
parent | f3ebaffd8714be31d4345f90af64992de4b3bba2 (diff) |
upstream: remove obsolete (SSH v.1) sshbuf_get/put_bignum1
functions
from markus@ ok djm@
OpenBSD-Commit-ID: 0380b1b2d9de063de3c5a097481a622e6a04943e
Diffstat (limited to 'sshbuf-getput-crypto.c')
-rw-r--r-- | sshbuf-getput-crypto.c | 50 |
1 files changed, 1 insertions, 49 deletions
diff --git a/sshbuf-getput-crypto.c b/sshbuf-getput-crypto.c index d0d791b50..a49b72ef7 100644 --- a/sshbuf-getput-crypto.c +++ b/sshbuf-getput-crypto.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sshbuf-getput-crypto.c,v 1.5 2016/01/12 23:42:54 djm Exp $ */ | 1 | /* $OpenBSD: sshbuf-getput-crypto.c,v 1.6 2019/01/21 09:52:25 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2011 Damien Miller | 3 | * Copyright (c) 2011 Damien Miller |
4 | * | 4 | * |
@@ -45,32 +45,6 @@ sshbuf_get_bignum2(struct sshbuf *buf, BIGNUM *v) | |||
45 | return 0; | 45 | return 0; |
46 | } | 46 | } |
47 | 47 | ||
48 | int | ||
49 | sshbuf_get_bignum1(struct sshbuf *buf, BIGNUM *v) | ||
50 | { | ||
51 | const u_char *d = sshbuf_ptr(buf); | ||
52 | u_int16_t len_bits; | ||
53 | size_t len_bytes; | ||
54 | |||
55 | /* Length in bits */ | ||
56 | if (sshbuf_len(buf) < 2) | ||
57 | return SSH_ERR_MESSAGE_INCOMPLETE; | ||
58 | len_bits = PEEK_U16(d); | ||
59 | len_bytes = (len_bits + 7) >> 3; | ||
60 | if (len_bytes > SSHBUF_MAX_BIGNUM) | ||
61 | return SSH_ERR_BIGNUM_TOO_LARGE; | ||
62 | if (sshbuf_len(buf) < 2 + len_bytes) | ||
63 | return SSH_ERR_MESSAGE_INCOMPLETE; | ||
64 | if (v != NULL && BN_bin2bn(d + 2, len_bytes, v) == NULL) | ||
65 | return SSH_ERR_ALLOC_FAIL; | ||
66 | if (sshbuf_consume(buf, 2 + len_bytes) != 0) { | ||
67 | SSHBUF_DBG(("SSH_ERR_INTERNAL_ERROR")); | ||
68 | SSHBUF_ABORT(); | ||
69 | return SSH_ERR_INTERNAL_ERROR; | ||
70 | } | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | #ifdef OPENSSL_HAS_ECC | 48 | #ifdef OPENSSL_HAS_ECC |
75 | static int | 49 | static int |
76 | get_ec(const u_char *d, size_t len, EC_POINT *v, const EC_GROUP *g) | 50 | get_ec(const u_char *d, size_t len, EC_POINT *v, const EC_GROUP *g) |
@@ -165,28 +139,6 @@ sshbuf_put_bignum2(struct sshbuf *buf, const BIGNUM *v) | |||
165 | return 0; | 139 | return 0; |
166 | } | 140 | } |
167 | 141 | ||
168 | int | ||
169 | sshbuf_put_bignum1(struct sshbuf *buf, const BIGNUM *v) | ||
170 | { | ||
171 | int r, len_bits = BN_num_bits(v); | ||
172 | size_t len_bytes = (len_bits + 7) / 8; | ||
173 | u_char d[SSHBUF_MAX_BIGNUM], *dp; | ||
174 | |||
175 | if (len_bits < 0 || len_bytes > SSHBUF_MAX_BIGNUM) | ||
176 | return SSH_ERR_INVALID_ARGUMENT; | ||
177 | if (BN_bn2bin(v, d) != (int)len_bytes) | ||
178 | return SSH_ERR_INTERNAL_ERROR; /* Shouldn't happen */ | ||
179 | if ((r = sshbuf_reserve(buf, len_bytes + 2, &dp)) < 0) { | ||
180 | explicit_bzero(d, sizeof(d)); | ||
181 | return r; | ||
182 | } | ||
183 | POKE_U16(dp, len_bits); | ||
184 | if (len_bytes != 0) | ||
185 | memcpy(dp + 2, d, len_bytes); | ||
186 | explicit_bzero(d, sizeof(d)); | ||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | #ifdef OPENSSL_HAS_ECC | 142 | #ifdef OPENSSL_HAS_ECC |
191 | int | 143 | int |
192 | sshbuf_put_ec(struct sshbuf *buf, const EC_POINT *v, const EC_GROUP *g) | 144 | sshbuf_put_ec(struct sshbuf *buf, const EC_POINT *v, const EC_GROUP *g) |