diff options
author | 2019-01-21 09:52:25 +0000 | |
---|---|---|
committer | 2019-01-21 09:52:25 +0000 | |
commit | e144fa24bddcd86107507f231de7fcb3731db9df (patch) | |
tree | 365a7f062daf2d9c8b8ec49505ab5d019cb7f709 | |
parent | fix all-zero check in kexc25519_shared_key (diff) | |
download | wireguard-openbsd-e144fa24bddcd86107507f231de7fcb3731db9df.tar.xz wireguard-openbsd-e144fa24bddcd86107507f231de7fcb3731db9df.zip |
remove obsolete (SSH v.1) sshbuf_get/put_bignum1 functions
from markus@ ok djm@
-rw-r--r-- | usr.bin/ssh/sshbuf-getput-crypto.c | 50 | ||||
-rw-r--r-- | usr.bin/ssh/sshbuf.h | 4 |
2 files changed, 2 insertions, 52 deletions
diff --git a/usr.bin/ssh/sshbuf-getput-crypto.c b/usr.bin/ssh/sshbuf-getput-crypto.c index e90f5ba8e6c..9d0da3b935e 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.5 2016/01/12 23:42:54 djm Exp $ */ +/* $OpenBSD: sshbuf-getput-crypto.c,v 1.6 2019/01/21 09:52:25 djm Exp $ */ /* * Copyright (c) 2011 Damien Miller * @@ -41,32 +41,6 @@ sshbuf_get_bignum2(struct sshbuf *buf, BIGNUM *v) return 0; } -int -sshbuf_get_bignum1(struct sshbuf *buf, BIGNUM *v) -{ - const u_char *d = sshbuf_ptr(buf); - u_int16_t len_bits; - size_t len_bytes; - - /* Length in bits */ - if (sshbuf_len(buf) < 2) - return SSH_ERR_MESSAGE_INCOMPLETE; - len_bits = PEEK_U16(d); - len_bytes = (len_bits + 7) >> 3; - if (len_bytes > SSHBUF_MAX_BIGNUM) - return SSH_ERR_BIGNUM_TOO_LARGE; - if (sshbuf_len(buf) < 2 + len_bytes) - return SSH_ERR_MESSAGE_INCOMPLETE; - if (v != NULL && BN_bin2bn(d + 2, len_bytes, v) == NULL) - return SSH_ERR_ALLOC_FAIL; - if (sshbuf_consume(buf, 2 + len_bytes) != 0) { - SSHBUF_DBG(("SSH_ERR_INTERNAL_ERROR")); - SSHBUF_ABORT(); - return SSH_ERR_INTERNAL_ERROR; - } - return 0; -} - static int get_ec(const u_char *d, size_t len, EC_POINT *v, const EC_GROUP *g) { @@ -160,28 +134,6 @@ sshbuf_put_bignum2(struct sshbuf *buf, const BIGNUM *v) } int -sshbuf_put_bignum1(struct sshbuf *buf, const BIGNUM *v) -{ - int r, len_bits = BN_num_bits(v); - size_t len_bytes = (len_bits + 7) / 8; - u_char d[SSHBUF_MAX_BIGNUM], *dp; - - if (len_bits < 0 || len_bytes > SSHBUF_MAX_BIGNUM) - return SSH_ERR_INVALID_ARGUMENT; - if (BN_bn2bin(v, d) != (int)len_bytes) - return SSH_ERR_INTERNAL_ERROR; /* Shouldn't happen */ - if ((r = sshbuf_reserve(buf, len_bytes + 2, &dp)) < 0) { - explicit_bzero(d, sizeof(d)); - return r; - } - POKE_U16(dp, len_bits); - if (len_bytes != 0) - memcpy(dp + 2, d, len_bytes); - explicit_bzero(d, sizeof(d)); - return 0; -} - -int sshbuf_put_ec(struct sshbuf *buf, const EC_POINT *v, const EC_GROUP *g) { u_char d[SSHBUF_MAX_ECPOINT]; diff --git a/usr.bin/ssh/sshbuf.h b/usr.bin/ssh/sshbuf.h index 6fd3322891d..01fafb43ac1 100644 --- a/usr.bin/ssh/sshbuf.h +++ b/usr.bin/ssh/sshbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sshbuf.h,v 1.11 2018/07/09 21:56:06 markus Exp $ */ +/* $OpenBSD: sshbuf.h,v 1.12 2019/01/21 09:52:25 djm Exp $ */ /* * Copyright (c) 2011 Damien Miller * @@ -205,11 +205,9 @@ int sshbuf_peek_string_direct(const struct sshbuf *buf, const u_char **valp, * curve points. */ int sshbuf_get_bignum2(struct sshbuf *buf, BIGNUM *v); -int sshbuf_get_bignum1(struct sshbuf *buf, BIGNUM *v); int sshbuf_get_bignum2_bytes_direct(struct sshbuf *buf, const u_char **valp, size_t *lenp); int sshbuf_put_bignum2(struct sshbuf *buf, const BIGNUM *v); -int sshbuf_put_bignum1(struct sshbuf *buf, const BIGNUM *v); int sshbuf_put_bignum2_bytes(struct sshbuf *buf, const void *v, size_t len); int sshbuf_get_ec(struct sshbuf *buf, EC_POINT *v, const EC_GROUP *g); int sshbuf_get_eckey(struct sshbuf *buf, EC_KEY *v); |