summaryrefslogtreecommitdiff
path: root/sshbuf-getput-crypto.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2020-02-21 11:57:14 +0000
committerColin Watson <cjwatson@debian.org>2020-02-21 14:27:02 +0000
commit886e47e745586c34e81cfd5c5fb9b5dbc8e84d04 (patch)
treedd6c3b4dc64a17c520af7aaf213163f8a0a63e56 /sshbuf-getput-crypto.c
parentac2b4c0697fcac554041ab95f81736887eadf6ec (diff)
parenta2dabf35ce0228c86a288d11cc847a9d9801604f (diff)
New upstream release (8.2p1)
Diffstat (limited to 'sshbuf-getput-crypto.c')
-rw-r--r--sshbuf-getput-crypto.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/sshbuf-getput-crypto.c b/sshbuf-getput-crypto.c
index 3dd1e1446..2e61d3bcd 100644
--- a/sshbuf-getput-crypto.c
+++ b/sshbuf-getput-crypto.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshbuf-getput-crypto.c,v 1.7 2019/01/21 09:54:11 djm Exp $ */ 1/* $OpenBSD: sshbuf-getput-crypto.c,v 1.8 2019/11/15 06:00:20 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2011 Damien Miller 3 * Copyright (c) 2011 Damien Miller
4 * 4 *
@@ -23,6 +23,7 @@
23#include <stdio.h> 23#include <stdio.h>
24#include <string.h> 24#include <string.h>
25 25
26#ifdef WITH_OPENSSL
26#include <openssl/bn.h> 27#include <openssl/bn.h>
27#ifdef OPENSSL_HAS_ECC 28#ifdef OPENSSL_HAS_ECC
28# include <openssl/ec.h> 29# include <openssl/ec.h>
@@ -153,23 +154,17 @@ int
153sshbuf_put_ec(struct sshbuf *buf, const EC_POINT *v, const EC_GROUP *g) 154sshbuf_put_ec(struct sshbuf *buf, const EC_POINT *v, const EC_GROUP *g)
154{ 155{
155 u_char d[SSHBUF_MAX_ECPOINT]; 156 u_char d[SSHBUF_MAX_ECPOINT];
156 BN_CTX *bn_ctx;
157 size_t len; 157 size_t len;
158 int ret; 158 int ret;
159 159
160 if ((bn_ctx = BN_CTX_new()) == NULL)
161 return SSH_ERR_ALLOC_FAIL;
162 if ((len = EC_POINT_point2oct(g, v, POINT_CONVERSION_UNCOMPRESSED, 160 if ((len = EC_POINT_point2oct(g, v, POINT_CONVERSION_UNCOMPRESSED,
163 NULL, 0, bn_ctx)) > SSHBUF_MAX_ECPOINT) { 161 NULL, 0, NULL)) > SSHBUF_MAX_ECPOINT) {
164 BN_CTX_free(bn_ctx);
165 return SSH_ERR_INVALID_ARGUMENT; 162 return SSH_ERR_INVALID_ARGUMENT;
166 } 163 }
167 if (EC_POINT_point2oct(g, v, POINT_CONVERSION_UNCOMPRESSED, 164 if (EC_POINT_point2oct(g, v, POINT_CONVERSION_UNCOMPRESSED,
168 d, len, bn_ctx) != len) { 165 d, len, NULL) != len) {
169 BN_CTX_free(bn_ctx);
170 return SSH_ERR_INTERNAL_ERROR; /* Shouldn't happen */ 166 return SSH_ERR_INTERNAL_ERROR; /* Shouldn't happen */
171 } 167 }
172 BN_CTX_free(bn_ctx);
173 ret = sshbuf_put_string(buf, d, len); 168 ret = sshbuf_put_string(buf, d, len);
174 explicit_bzero(d, len); 169 explicit_bzero(d, len);
175 return ret; 170 return ret;
@@ -182,4 +177,4 @@ sshbuf_put_eckey(struct sshbuf *buf, const EC_KEY *v)
182 EC_KEY_get0_group(v)); 177 EC_KEY_get0_group(v));
183} 178}
184#endif /* OPENSSL_HAS_ECC */ 179#endif /* OPENSSL_HAS_ECC */
185 180#endif /* WITH_OPENSSL */