diff options
author | tb <> | 2023-07-01 14:50:39 +0000 |
---|---|---|
committer | tb <> | 2023-07-01 14:50:39 +0000 |
commit | 051da6d02b4e1290f2af4135c212b9083524d588 (patch) | |
tree | 5015aa7f4c468a77c15f9be1618c20ea89cb4405 | |
parent | e31da3c8eee0fdd1dcf6c0a9c3e447aba90a70e3 (diff) | |
download | openbsd-051da6d02b4e1290f2af4135c212b9083524d588.tar.gz openbsd-051da6d02b4e1290f2af4135c212b9083524d588.tar.bz2 openbsd-051da6d02b4e1290f2af4135c212b9083524d588.zip |
Simplify handling of ret
ok jsing
-rw-r--r-- | src/lib/libcrypto/ecdh/ech_key.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/libcrypto/ecdh/ech_key.c b/src/lib/libcrypto/ecdh/ech_key.c index b364b31c88..662fc5bba1 100644 --- a/src/lib/libcrypto/ecdh/ech_key.c +++ b/src/lib/libcrypto/ecdh/ech_key.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ech_key.c,v 1.21 2023/07/01 14:48:01 tb Exp $ */ | 1 | /* $OpenBSD: ech_key.c,v 1.22 2023/07/01 14:50:39 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
4 | * | 4 | * |
@@ -97,9 +97,9 @@ ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, | |||
97 | BIGNUM *x; | 97 | BIGNUM *x; |
98 | const BIGNUM *priv_key; | 98 | const BIGNUM *priv_key; |
99 | const EC_GROUP* group; | 99 | const EC_GROUP* group; |
100 | int ret = -1; | ||
101 | unsigned char *buf = NULL; | 100 | unsigned char *buf = NULL; |
102 | int buflen, len; | 101 | int buflen, len; |
102 | int ret = -1; | ||
103 | 103 | ||
104 | if (outlen > INT_MAX) { | 104 | if (outlen > INT_MAX) { |
105 | /* Sort of, anyway. */ | 105 | /* Sort of, anyway. */ |
@@ -166,7 +166,6 @@ ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, | |||
166 | ECDHerror(ECDH_R_KDF_FAILED); | 166 | ECDHerror(ECDH_R_KDF_FAILED); |
167 | goto err; | 167 | goto err; |
168 | } | 168 | } |
169 | ret = outlen; | ||
170 | } else { | 169 | } else { |
171 | /* No KDF, just copy out the key and zero the rest. */ | 170 | /* No KDF, just copy out the key and zero the rest. */ |
172 | if (outlen > buflen) { | 171 | if (outlen > buflen) { |
@@ -174,15 +173,16 @@ ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, | |||
174 | outlen = buflen; | 173 | outlen = buflen; |
175 | } | 174 | } |
176 | memcpy(out, buf, outlen); | 175 | memcpy(out, buf, outlen); |
177 | ret = outlen; | ||
178 | } | 176 | } |
179 | 177 | ||
178 | ret = outlen; | ||
180 | err: | 179 | err: |
181 | EC_POINT_free(tmp); | 180 | EC_POINT_free(tmp); |
182 | BN_CTX_end(ctx); | 181 | BN_CTX_end(ctx); |
183 | BN_CTX_free(ctx); | 182 | BN_CTX_free(ctx); |
184 | free(buf); | 183 | free(buf); |
185 | return (ret); | 184 | |
185 | return ret; | ||
186 | } | 186 | } |
187 | 187 | ||
188 | int | 188 | int |
@@ -199,5 +199,5 @@ ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, | |||
199 | int | 199 | int |
200 | ECDH_size(const EC_KEY *d) | 200 | ECDH_size(const EC_KEY *d) |
201 | { | 201 | { |
202 | return ((EC_GROUP_get_degree(EC_KEY_get0_group(d)) + 7) / 8); | 202 | return (EC_GROUP_get_degree(EC_KEY_get0_group(d)) + 7) / 8; |
203 | } | 203 | } |