summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2015-09-13 12:03:07 +0000
committerjsing <>2015-09-13 12:03:07 +0000
commitd3ca9c5fcc829c09183fad7a61d257f5af99078f (patch)
tree8102b2308916eb876e18b8eb9d63e50a7762027d /src/lib
parent21654feacf896dbd0001798f2c549c31b9974412 (diff)
downloadopenbsd-d3ca9c5fcc829c09183fad7a61d257f5af99078f.tar.gz
openbsd-d3ca9c5fcc829c09183fad7a61d257f5af99078f.tar.bz2
openbsd-d3ca9c5fcc829c09183fad7a61d257f5af99078f.zip
Provide ECDH_size().
"jajaja" miod@
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/ecdh/ecdh.h3
-rw-r--r--src/lib/libcrypto/ecdh/ech_lib.c8
-rw-r--r--src/lib/libcrypto/ecdh/ech_ossl.c4
-rw-r--r--src/lib/libssl/src/crypto/ecdh/ecdh.h3
-rw-r--r--src/lib/libssl/src/crypto/ecdh/ech_lib.c8
-rw-r--r--src/lib/libssl/src/crypto/ecdh/ech_ossl.c4
6 files changed, 22 insertions, 8 deletions
diff --git a/src/lib/libcrypto/ecdh/ecdh.h b/src/lib/libcrypto/ecdh/ecdh.h
index e1cc8404d0..ccc1312fd8 100644
--- a/src/lib/libcrypto/ecdh/ecdh.h
+++ b/src/lib/libcrypto/ecdh/ecdh.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecdh.h,v 1.4 2015/09/13 11:49:44 jsing Exp $ */ 1/* $OpenBSD: ecdh.h,v 1.5 2015/09/13 12:03:07 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -91,6 +91,7 @@ void ECDH_set_default_method(const ECDH_METHOD *);
91const ECDH_METHOD *ECDH_get_default_method(void); 91const ECDH_METHOD *ECDH_get_default_method(void);
92int ECDH_set_method(EC_KEY *, const ECDH_METHOD *); 92int ECDH_set_method(EC_KEY *, const ECDH_METHOD *);
93 93
94int ECDH_size(const EC_KEY *ecdh);
94int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, 95int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
95 EC_KEY *ecdh, 96 EC_KEY *ecdh,
96 void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); 97 void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen));
diff --git a/src/lib/libcrypto/ecdh/ech_lib.c b/src/lib/libcrypto/ecdh/ech_lib.c
index 579dfc4b4f..bb70d2d95f 100644
--- a/src/lib/libcrypto/ecdh/ech_lib.c
+++ b/src/lib/libcrypto/ecdh/ech_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ech_lib.c,v 1.10 2015/09/13 10:46:20 jsing Exp $ */ 1/* $OpenBSD: ech_lib.c,v 1.11 2015/09/13 12:03:07 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -239,3 +239,9 @@ ECDH_get_ex_data(EC_KEY *d, int idx)
239 return NULL; 239 return NULL;
240 return (CRYPTO_get_ex_data(&ecdh->ex_data, idx)); 240 return (CRYPTO_get_ex_data(&ecdh->ex_data, idx));
241} 241}
242
243int
244ECDH_size(const EC_KEY *d)
245{
246 return ((EC_GROUP_get_degree(EC_KEY_get0_group(d)) + 7) / 8);
247}
diff --git a/src/lib/libcrypto/ecdh/ech_ossl.c b/src/lib/libcrypto/ecdh/ech_ossl.c
index 746eb12ea3..7956edc0e6 100644
--- a/src/lib/libcrypto/ecdh/ech_ossl.c
+++ b/src/lib/libcrypto/ecdh/ech_ossl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ech_ossl.c,v 1.11 2015/09/13 11:49:44 jsing Exp $ */ 1/* $OpenBSD: ech_ossl.c,v 1.12 2015/09/13 12:03:07 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -166,7 +166,7 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
166 } 166 }
167#endif 167#endif
168 168
169 buflen = (EC_GROUP_get_degree(group) + 7)/8; 169 buflen = ECDH_size(ecdh);
170 len = BN_num_bytes(x); 170 len = BN_num_bytes(x);
171 if (len > buflen) { 171 if (len > buflen) {
172 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY, ERR_R_INTERNAL_ERROR); 172 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY, ERR_R_INTERNAL_ERROR);
diff --git a/src/lib/libssl/src/crypto/ecdh/ecdh.h b/src/lib/libssl/src/crypto/ecdh/ecdh.h
index e1cc8404d0..ccc1312fd8 100644
--- a/src/lib/libssl/src/crypto/ecdh/ecdh.h
+++ b/src/lib/libssl/src/crypto/ecdh/ecdh.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecdh.h,v 1.4 2015/09/13 11:49:44 jsing Exp $ */ 1/* $OpenBSD: ecdh.h,v 1.5 2015/09/13 12:03:07 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -91,6 +91,7 @@ void ECDH_set_default_method(const ECDH_METHOD *);
91const ECDH_METHOD *ECDH_get_default_method(void); 91const ECDH_METHOD *ECDH_get_default_method(void);
92int ECDH_set_method(EC_KEY *, const ECDH_METHOD *); 92int ECDH_set_method(EC_KEY *, const ECDH_METHOD *);
93 93
94int ECDH_size(const EC_KEY *ecdh);
94int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, 95int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
95 EC_KEY *ecdh, 96 EC_KEY *ecdh,
96 void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); 97 void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen));
diff --git a/src/lib/libssl/src/crypto/ecdh/ech_lib.c b/src/lib/libssl/src/crypto/ecdh/ech_lib.c
index 579dfc4b4f..bb70d2d95f 100644
--- a/src/lib/libssl/src/crypto/ecdh/ech_lib.c
+++ b/src/lib/libssl/src/crypto/ecdh/ech_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ech_lib.c,v 1.10 2015/09/13 10:46:20 jsing Exp $ */ 1/* $OpenBSD: ech_lib.c,v 1.11 2015/09/13 12:03:07 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -239,3 +239,9 @@ ECDH_get_ex_data(EC_KEY *d, int idx)
239 return NULL; 239 return NULL;
240 return (CRYPTO_get_ex_data(&ecdh->ex_data, idx)); 240 return (CRYPTO_get_ex_data(&ecdh->ex_data, idx));
241} 241}
242
243int
244ECDH_size(const EC_KEY *d)
245{
246 return ((EC_GROUP_get_degree(EC_KEY_get0_group(d)) + 7) / 8);
247}
diff --git a/src/lib/libssl/src/crypto/ecdh/ech_ossl.c b/src/lib/libssl/src/crypto/ecdh/ech_ossl.c
index 746eb12ea3..7956edc0e6 100644
--- a/src/lib/libssl/src/crypto/ecdh/ech_ossl.c
+++ b/src/lib/libssl/src/crypto/ecdh/ech_ossl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ech_ossl.c,v 1.11 2015/09/13 11:49:44 jsing Exp $ */ 1/* $OpenBSD: ech_ossl.c,v 1.12 2015/09/13 12:03:07 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -166,7 +166,7 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
166 } 166 }
167#endif 167#endif
168 168
169 buflen = (EC_GROUP_get_degree(group) + 7)/8; 169 buflen = ECDH_size(ecdh);
170 len = BN_num_bytes(x); 170 len = BN_num_bytes(x);
171 if (len > buflen) { 171 if (len > buflen) {
172 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY, ERR_R_INTERNAL_ERROR); 172 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY, ERR_R_INTERNAL_ERROR);