DPP: Add crypto_ec_key_cmp() in crypto.h and use it

This gets rid of one more direct OpenSSL call in the DPP implementation.

Signed-off-by: Cedric Izoard <cedric.izoard@ceva-dsp.com>
This commit is contained in:
Cedric Izoard 2021-06-28 18:25:34 +02:00 committed by Jouni Malinen
parent 984faf9634
commit c88b7fcaef
3 changed files with 17 additions and 2 deletions

View file

@ -2370,8 +2370,7 @@ skip_groups:
goto fail; goto fail;
dpp_debug_print_key("DPP: Received netAccessKey", key); dpp_debug_print_key("DPP: Received netAccessKey", key);
if (EVP_PKEY_cmp((EVP_PKEY *) key, if (crypto_ec_key_cmp(key, auth->own_protocol_key)) {
(EVP_PKEY *) auth->own_protocol_key) != 1) {
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
"DPP: netAccessKey in connector does not match own protocol key"); "DPP: netAccessKey in connector does not match own protocol key");
#ifdef CONFIG_TESTING_OPTIONS #ifdef CONFIG_TESTING_OPTIONS

View file

@ -1150,4 +1150,12 @@ int crypto_ec_key_verify_signature_r_s(struct crypto_ec_key *key,
*/ */
int crypto_ec_key_group(struct crypto_ec_key *key); int crypto_ec_key_group(struct crypto_ec_key *key);
/**
* crypto_ec_key_cmp - Compare two EC public keys
* @key1: Key 1
* @key2: Key 2
* Returns: 0 if public keys are identical, -1 otherwise
*/
int crypto_ec_key_cmp(struct crypto_ec_key *key1, struct crypto_ec_key *key2);
#endif /* CRYPTO_H */ #endif /* CRYPTO_H */

View file

@ -2770,4 +2770,12 @@ int crypto_ec_key_group(struct crypto_ec_key *key)
return -1; return -1;
} }
int crypto_ec_key_cmp(struct crypto_ec_key *key1, struct crypto_ec_key *key2)
{
if (EVP_PKEY_cmp((EVP_PKEY *) key1, (EVP_PKEY *) key2) != 1)
return -1;
return 0;
}
#endif /* CONFIG_ECC */ #endif /* CONFIG_ECC */