aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2019-08-04 12:03:08 (GMT)
committerJouni Malinen <j@w1.fi>2019-08-04 12:03:08 (GMT)
commitd001fe31ab0a3e7619484c4a6a3aa5a85cd81816 (patch)
treee6ae1ea42cedb4bfdbded3455a5efde03f5598ac /src
parent29ef1c5ee4c1251aa3a70cb45af6888deba040f8 (diff)
downloadhostap-d001fe31ab0a3e7619484c4a6a3aa5a85cd81816.zip
hostap-d001fe31ab0a3e7619484c4a6a3aa5a85cd81816.tar.gz
hostap-d001fe31ab0a3e7619484c4a6a3aa5a85cd81816.tar.bz2
OpenSSL: Handle EVP_PKEY_derive() secret_len changes for ECDH
It looks like EVP_PKEY_derive() may change the returned length of the buffer from the initial length determination (NULL buffer) to the fetching of the value. Handle this by updating the secret length based on the second call instead of the first one. This fixes some cases where ECDH result has been used with extra data (zeros in the end) with OWE or FILS PFS. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src')
-rw-r--r--src/crypto/crypto_openssl.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/crypto/crypto_openssl.c b/src/crypto/crypto_openssl.c
index aa5b9b4..bab33a5 100644
--- a/src/crypto/crypto_openssl.c
+++ b/src/crypto/crypto_openssl.c
@@ -2059,13 +2059,17 @@ struct wpabuf * crypto_ecdh_set_peerkey(struct crypto_ecdh *ecdh, int inc_y,
secret = wpabuf_alloc(secret_len);
if (!secret)
goto fail;
- if (EVP_PKEY_derive(ctx, wpabuf_put(secret, secret_len),
- &secret_len) != 1) {
+ if (EVP_PKEY_derive(ctx, wpabuf_put(secret, 0), &secret_len) != 1) {
wpa_printf(MSG_ERROR,
"OpenSSL: EVP_PKEY_derive(2) failed: %s",
ERR_error_string(ERR_get_error(), NULL));
goto fail;
}
+ if (secret->size != secret_len)
+ wpa_printf(MSG_DEBUG,
+ "OpenSSL: EVP_PKEY_derive(2) changed secret_len %d -> %d",
+ (int) secret->size, (int) secret_len);
+ wpabuf_put(secret, secret_len);
done:
BN_free(x);