diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2015-09-13 12:03:08 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2015-09-13 12:03:08 +0000 |
commit | 8f73bf05be59e1c17871d01538caf7e71c021373 (patch) | |
tree | e4c7df61ecf11c6ef1715dea68858240470be4ef /lib | |
parent | 4905532a7dbe6d85d33f59ad8417c0dab944e1a2 (diff) |
Provide ECDH_size().
"jajaja" miod@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/ecdh/ecdh.h | 3 | ||||
-rw-r--r-- | lib/libcrypto/ecdh/ech_lib.c | 8 | ||||
-rw-r--r-- | lib/libcrypto/ecdh/ech_ossl.c | 4 |
3 files changed, 11 insertions, 4 deletions
diff --git a/lib/libcrypto/ecdh/ecdh.h b/lib/libcrypto/ecdh/ecdh.h index e1cc8404d04..ccc1312fd87 100644 --- a/lib/libcrypto/ecdh/ecdh.h +++ b/lib/libcrypto/ecdh/ecdh.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ecdh.h,v 1.4 2015/09/13 11:49:44 jsing Exp $ */ +/* $OpenBSD: ecdh.h,v 1.5 2015/09/13 12:03:07 jsing Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -91,6 +91,7 @@ void ECDH_set_default_method(const ECDH_METHOD *); const ECDH_METHOD *ECDH_get_default_method(void); int ECDH_set_method(EC_KEY *, const ECDH_METHOD *); +int ECDH_size(const EC_KEY *ecdh); int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); diff --git a/lib/libcrypto/ecdh/ech_lib.c b/lib/libcrypto/ecdh/ech_lib.c index 579dfc4b4f8..bb70d2d95f7 100644 --- a/lib/libcrypto/ecdh/ech_lib.c +++ b/lib/libcrypto/ecdh/ech_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ech_lib.c,v 1.10 2015/09/13 10:46:20 jsing Exp $ */ +/* $OpenBSD: ech_lib.c,v 1.11 2015/09/13 12:03:07 jsing Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -239,3 +239,9 @@ ECDH_get_ex_data(EC_KEY *d, int idx) return NULL; return (CRYPTO_get_ex_data(&ecdh->ex_data, idx)); } + +int +ECDH_size(const EC_KEY *d) +{ + return ((EC_GROUP_get_degree(EC_KEY_get0_group(d)) + 7) / 8); +} diff --git a/lib/libcrypto/ecdh/ech_ossl.c b/lib/libcrypto/ecdh/ech_ossl.c index 746eb12ea36..7956edc0e62 100644 --- a/lib/libcrypto/ecdh/ech_ossl.c +++ b/lib/libcrypto/ecdh/ech_ossl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ech_ossl.c,v 1.11 2015/09/13 11:49:44 jsing Exp $ */ +/* $OpenBSD: ech_ossl.c,v 1.12 2015/09/13 12:03:07 jsing Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -166,7 +166,7 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, } #endif - buflen = (EC_GROUP_get_degree(group) + 7)/8; + buflen = ECDH_size(ecdh); len = BN_num_bytes(x); if (len > buflen) { ECDHerr(ECDH_F_ECDH_COMPUTE_KEY, ERR_R_INTERNAL_ERROR); |