summaryrefslogtreecommitdiff
path: root/sshbuf-getput-crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'sshbuf-getput-crypto.c')
-rw-r--r--sshbuf-getput-crypto.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/sshbuf-getput-crypto.c b/sshbuf-getput-crypto.c
index ecbfa550f..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 *
@@ -154,23 +154,17 @@ int
154sshbuf_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)
155{ 155{
156 u_char d[SSHBUF_MAX_ECPOINT]; 156 u_char d[SSHBUF_MAX_ECPOINT];
157 BN_CTX *bn_ctx;
158 size_t len; 157 size_t len;
159 int ret; 158 int ret;
160 159
161 if ((bn_ctx = BN_CTX_new()) == NULL)
162 return SSH_ERR_ALLOC_FAIL;
163 if ((len = EC_POINT_point2oct(g, v, POINT_CONVERSION_UNCOMPRESSED, 160 if ((len = EC_POINT_point2oct(g, v, POINT_CONVERSION_UNCOMPRESSED,
164 NULL, 0, bn_ctx)) > SSHBUF_MAX_ECPOINT) { 161 NULL, 0, NULL)) > SSHBUF_MAX_ECPOINT) {
165 BN_CTX_free(bn_ctx);
166 return SSH_ERR_INVALID_ARGUMENT; 162 return SSH_ERR_INVALID_ARGUMENT;
167 } 163 }
168 if (EC_POINT_point2oct(g, v, POINT_CONVERSION_UNCOMPRESSED, 164 if (EC_POINT_point2oct(g, v, POINT_CONVERSION_UNCOMPRESSED,
169 d, len, bn_ctx) != len) { 165 d, len, NULL) != len) {
170 BN_CTX_free(bn_ctx);
171 return SSH_ERR_INTERNAL_ERROR; /* Shouldn't happen */ 166 return SSH_ERR_INTERNAL_ERROR; /* Shouldn't happen */
172 } 167 }
173 BN_CTX_free(bn_ctx);
174 ret = sshbuf_put_string(buf, d, len); 168 ret = sshbuf_put_string(buf, d, len);
175 explicit_bzero(d, len); 169 explicit_bzero(d, len);
176 return ret; 170 return ret;