From a8a3c2c751dda987fb94a1afbd771134bcbd7f04 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sun, 30 Jan 2022 08:07:23 +0100 Subject: [PATCH 02/12] wpa_supplicant: add prefix wpa_ to crypto functions Prefix `_wpa` added to crypto functions of `wpa_suppplicant` to avoid name conflicts with RIOT modules `crypto` and `hashes`. --- components/wpa_supplicant/src/common/dpp.c | 2 +- components/wpa_supplicant/src/common/sae.c | 2 +- .../wpa_supplicant/src/common/wpa_common.c | 2 +- components/wpa_supplicant/src/crypto/aes-cbc.c | 4 ++-- components/wpa_supplicant/src/crypto/aes-ccm.c | 18 +++++++++--------- components/wpa_supplicant/src/crypto/aes-ctr.c | 2 +- components/wpa_supplicant/src/crypto/aes-gcm.c | 6 +++--- .../src/crypto/aes-internal-dec.c | 2 +- .../src/crypto/aes-internal-enc.c | 2 +- .../wpa_supplicant/src/crypto/aes-omac1.c | 6 +++--- .../wpa_supplicant/src/crypto/aes-unwrap.c | 2 +- .../wpa_supplicant/src/crypto/aes-wrap.c | 2 +- components/wpa_supplicant/src/crypto/aes.h | 4 ++-- components/wpa_supplicant/src/crypto/crypto.h | 4 ++-- .../src/crypto/crypto_internal-cipher.c | 4 ++-- .../src/crypto/crypto_internal.c | 8 ++++---- .../wpa_supplicant/src/crypto/crypto_mbedtls.c | 6 +++--- .../wpa_supplicant/src/crypto/crypto_ops.c | 4 ++-- .../src/crypto/sha256-internal.c | 4 ++-- .../wpa_supplicant/src/crypto/sha256-tlsprf.c | 2 +- components/wpa_supplicant/src/crypto/sha256.c | 2 +- components/wpa_supplicant/src/crypto/sha256.h | 2 +- .../wpa_supplicant/src/crypto/sha256_i.h | 2 +- .../wpa_supplicant/src/wps/wps_attr_build.c | 2 +- .../wpa_supplicant/src/wps/wps_attr_process.c | 2 +- components/wpa_supplicant/src/wps/wps_common.c | 4 ++-- 26 files changed, 50 insertions(+), 50 deletions(-) diff --git a/components/wpa_supplicant/src/common/dpp.c b/components/wpa_supplicant/src/common/dpp.c index 899e0c06c4..c97399d88c 100644 --- a/components/wpa_supplicant/src/common/dpp.c +++ b/components/wpa_supplicant/src/common/dpp.c @@ -153,7 +153,7 @@ static int dpp_hmac(size_t hash_len, const u8 *key, size_t key_len, const u8 *data, size_t data_len, u8 *mac) { if (hash_len == 32) - return hmac_sha256(key, key_len, data, data_len, mac); + return wpa_hmac_sha256(key, key_len, data, data_len, mac); #ifndef ESP_SUPPLICANT if (hash_len == 48) return hmac_sha384(key, key_len, data, data_len, mac); diff --git a/components/wpa_supplicant/src/common/sae.c b/components/wpa_supplicant/src/common/sae.c index ec65605337..00eb2f6c21 100644 --- a/components/wpa_supplicant/src/common/sae.c +++ b/components/wpa_supplicant/src/common/sae.c @@ -827,7 +827,7 @@ static int sae_derive_keys(struct sae_data *sae, const u8 *k) */ os_memset(null_key, 0, sizeof(null_key)); - hmac_sha256(null_key, sizeof(null_key), k, sae->tmp->prime_len, + wpa_hmac_sha256(null_key, sizeof(null_key), k, sae->tmp->prime_len, keyseed); wpa_hexdump_key(MSG_DEBUG, "SAE: keyseed", keyseed, sizeof(keyseed)); diff --git a/components/wpa_supplicant/src/common/wpa_common.c b/components/wpa_supplicant/src/common/wpa_common.c index 070ba0887e..36b230a9cc 100644 --- a/components/wpa_supplicant/src/common/wpa_common.c +++ b/components/wpa_supplicant/src/common/wpa_common.c @@ -467,7 +467,7 @@ int wpa_eapol_key_mic(const u8 *key, size_t key_len, int akmp, int ver, #endif /* CONFIG_WPA3_SAE */ #ifdef CONFIG_SUITEB case WPA_KEY_MGMT_IEEE8021X_SUITE_B: - if (hmac_sha256(key, key_len, buf, len, hash)) + if (wpa_hmac_sha256(key, key_len, buf, len, hash)) return -1; os_memcpy(mic, hash, MD5_MAC_LEN); break; diff --git a/components/wpa_supplicant/src/crypto/aes-cbc.c b/components/wpa_supplicant/src/crypto/aes-cbc.c index 0835f2cfb7..fa01d4083a 100644 --- a/components/wpa_supplicant/src/crypto/aes-cbc.c +++ b/components/wpa_supplicant/src/crypto/aes-cbc.c @@ -40,7 +40,7 @@ int aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len) for (i = 0; i < blocks; i++) { for (j = 0; j < AES_BLOCK_SIZE; j++) cbc[j] ^= pos[j]; - aes_encrypt(ctx, cbc, cbc); + wpa_aes_encrypt(ctx, cbc, cbc); os_memcpy(pos, cbc, AES_BLOCK_SIZE); pos += AES_BLOCK_SIZE; } @@ -75,7 +75,7 @@ int aes_128_cbc_decrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len) blocks = data_len / AES_BLOCK_SIZE; for (i = 0; i < blocks; i++) { os_memcpy(tmp, pos, AES_BLOCK_SIZE); - aes_decrypt(ctx, pos, pos); + wpa_aes_decrypt(ctx, pos, pos); for (j = 0; j < AES_BLOCK_SIZE; j++) pos[j] ^= cbc[j]; os_memcpy(cbc, tmp, AES_BLOCK_SIZE); diff --git a/components/wpa_supplicant/src/crypto/aes-ccm.c b/components/wpa_supplicant/src/crypto/aes-ccm.c index e5bb94ca08..2a837463be 100644 --- a/components/wpa_supplicant/src/crypto/aes-ccm.c +++ b/components/wpa_supplicant/src/crypto/aes-ccm.c @@ -42,7 +42,7 @@ static void aes_ccm_auth_start(void *aes, size_t M, size_t L, const u8 *nonce, WPA_PUT_BE16(&b[AES_BLOCK_SIZE - L], plain_len); wpa_hexdump_key(MSG_DEBUG, "CCM B_0", b, AES_BLOCK_SIZE); - aes_encrypt(aes, b, x); /* X_1 = E(K, B_0) */ + wpa_aes_encrypt(aes, b, x); /* X_1 = E(K, B_0) */ if (!aad_len) return; @@ -52,12 +52,12 @@ static void aes_ccm_auth_start(void *aes, size_t M, size_t L, const u8 *nonce, os_memset(aad_buf + 2 + aad_len, 0, sizeof(aad_buf) - 2 - aad_len); xor_aes_block(aad_buf, x); - aes_encrypt(aes, aad_buf, x); /* X_2 = E(K, X_1 XOR B_1) */ + wpa_aes_encrypt(aes, aad_buf, x); /* X_2 = E(K, X_1 XOR B_1) */ if (aad_len > AES_BLOCK_SIZE - 2) { xor_aes_block(&aad_buf[AES_BLOCK_SIZE], x); /* X_3 = E(K, X_2 XOR B_2) */ - aes_encrypt(aes, &aad_buf[AES_BLOCK_SIZE], x); + wpa_aes_encrypt(aes, &aad_buf[AES_BLOCK_SIZE], x); } } @@ -71,13 +71,13 @@ static void aes_ccm_auth(void *aes, const u8 *data, size_t len, u8 *x) /* X_i+1 = E(K, X_i XOR B_i) */ xor_aes_block(x, data); data += AES_BLOCK_SIZE; - aes_encrypt(aes, x, x); + wpa_aes_encrypt(aes, x, x); } if (last) { /* XOR zero-padded last block */ for (i = 0; i < last; i++) x[i] ^= *data++; - aes_encrypt(aes, x, x); + wpa_aes_encrypt(aes, x, x); } } @@ -100,14 +100,14 @@ static void aes_ccm_encr(void *aes, size_t L, const u8 *in, size_t len, u8 *out, for (i = 1; i <= len / AES_BLOCK_SIZE; i++) { WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i); /* S_i = E(K, A_i) */ - aes_encrypt(aes, a, out); + wpa_aes_encrypt(aes, a, out); xor_aes_block(out, in); out += AES_BLOCK_SIZE; in += AES_BLOCK_SIZE; } if (last) { WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i); - aes_encrypt(aes, a, out); + wpa_aes_encrypt(aes, a, out); /* XOR zero-padded last block */ for (i = 0; i < last; i++) *out++ ^= *in++; @@ -123,7 +123,7 @@ static void aes_ccm_encr_auth(void *aes, size_t M, u8 *x, u8 *a, u8 *auth) wpa_hexdump_key(MSG_DEBUG, "CCM T", x, M); /* U = T XOR S_0; S_0 = E(K, A_0) */ WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], 0); - aes_encrypt(aes, a, tmp); + wpa_aes_encrypt(aes, a, tmp); for (i = 0; i < M; i++) auth[i] = x[i] ^ tmp[i]; wpa_hexdump_key(MSG_DEBUG, "CCM U", auth, M); @@ -138,7 +138,7 @@ static void aes_ccm_decr_auth(void *aes, size_t M, u8 *a, const u8 *auth, u8 *t) wpa_hexdump_key(MSG_DEBUG, "CCM U", auth, M); /* U = T XOR S_0; S_0 = E(K, A_0) */ WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], 0); - aes_encrypt(aes, a, tmp); + wpa_aes_encrypt(aes, a, tmp); for (i = 0; i < M; i++) t[i] = auth[i] ^ tmp[i]; wpa_hexdump_key(MSG_DEBUG, "CCM T", t, M); diff --git a/components/wpa_supplicant/src/crypto/aes-ctr.c b/components/wpa_supplicant/src/crypto/aes-ctr.c index 8ce05b894d..0647706306 100644 --- a/components/wpa_supplicant/src/crypto/aes-ctr.c +++ b/components/wpa_supplicant/src/crypto/aes-ctr.c @@ -37,7 +37,7 @@ int aes_ctr_encrypt(const u8 *key, size_t key_len, const u8 *nonce, os_memcpy(counter, nonce, AES_BLOCK_SIZE); while (left > 0) { - aes_encrypt(ctx, counter, buf); + wpa_aes_encrypt(ctx, counter, buf); len = (left < AES_BLOCK_SIZE) ? left : AES_BLOCK_SIZE; for (j = 0; j < len; j++) diff --git a/components/wpa_supplicant/src/crypto/aes-gcm.c b/components/wpa_supplicant/src/crypto/aes-gcm.c index 84294d2d10..9b2f18df02 100644 --- a/components/wpa_supplicant/src/crypto/aes-gcm.c +++ b/components/wpa_supplicant/src/crypto/aes-gcm.c @@ -155,7 +155,7 @@ static void aes_gctr(void *aes, const u8 *icb, const u8 *x, size_t xlen, u8 *y) os_memcpy(cb, icb, AES_BLOCK_SIZE); /* Full blocks */ for (i = 0; i < n; i++) { - aes_encrypt(aes, cb, ypos); + wpa_aes_encrypt(aes, cb, ypos); xor_block(ypos, xpos); xpos += AES_BLOCK_SIZE; ypos += AES_BLOCK_SIZE; @@ -165,7 +165,7 @@ static void aes_gctr(void *aes, const u8 *icb, const u8 *x, size_t xlen, u8 *y) last = x + xlen - xpos; if (last) { /* Last, partial block */ - aes_encrypt(aes, cb, tmp); + wpa_aes_encrypt(aes, cb, tmp); for (i = 0; i < last; i++) *ypos++ = *xpos++ ^ tmp[i]; } @@ -182,7 +182,7 @@ static void * aes_gcm_init_hash_subkey(const u8 *key, size_t key_len, u8 *H) /* Generate hash subkey H = AES_K(0^128) */ os_memset(H, 0, AES_BLOCK_SIZE); - aes_encrypt(aes, H, H); + wpa_aes_encrypt(aes, H, H); wpa_hexdump_key(MSG_EXCESSIVE, "Hash subkey H for GHASH", H, AES_BLOCK_SIZE); return aes; diff --git a/components/wpa_supplicant/src/crypto/aes-internal-dec.c b/components/wpa_supplicant/src/crypto/aes-internal-dec.c index 7482295949..f72742cf59 100644 --- a/components/wpa_supplicant/src/crypto/aes-internal-dec.c +++ b/components/wpa_supplicant/src/crypto/aes-internal-dec.c @@ -148,7 +148,7 @@ d##3 = TD0(s##3) ^ TD1(s##2) ^ TD2(s##1) ^ TD3(s##0) ^ rk[4 * i + 3] } -int aes_decrypt(void *ctx, const u8 *crypt, u8 *plain) +int wpa_aes_decrypt(void *ctx, const u8 *crypt, u8 *plain) { u32 *rk = ctx; rijndaelDecrypt(ctx, rk[AES_PRIV_NR_POS], crypt, plain); diff --git a/components/wpa_supplicant/src/crypto/aes-internal-enc.c b/components/wpa_supplicant/src/crypto/aes-internal-enc.c index baeffcaf63..a856dc9f3f 100644 --- a/components/wpa_supplicant/src/crypto/aes-internal-enc.c +++ b/components/wpa_supplicant/src/crypto/aes-internal-enc.c @@ -116,7 +116,7 @@ void * aes_encrypt_init(const u8 *key, size_t len) } -int aes_encrypt(void *ctx, const u8 *plain, u8 *crypt) +int wpa_aes_encrypt(void *ctx, const u8 *plain, u8 *crypt) { u32 *rk = ctx; rijndaelEncrypt(ctx, rk[AES_PRIV_NR_POS], plain, crypt); diff --git a/components/wpa_supplicant/src/crypto/aes-omac1.c b/components/wpa_supplicant/src/crypto/aes-omac1.c index 8642516340..21ba314ae0 100644 --- a/components/wpa_supplicant/src/crypto/aes-omac1.c +++ b/components/wpa_supplicant/src/crypto/aes-omac1.c @@ -82,12 +82,12 @@ int omac1_aes_vector(const u8 *key, size_t key_len, size_t num_elem, } } if (left > AES_BLOCK_SIZE) - aes_encrypt(ctx, cbc, cbc); + wpa_aes_encrypt(ctx, cbc, cbc); left -= AES_BLOCK_SIZE; } os_memset(pad, 0, AES_BLOCK_SIZE); - aes_encrypt(ctx, pad, pad); + wpa_aes_encrypt(ctx, pad, pad); gf_mulx(pad); if (left || total_len == 0) { @@ -111,7 +111,7 @@ int omac1_aes_vector(const u8 *key, size_t key_len, size_t num_elem, for (i = 0; i < AES_BLOCK_SIZE; i++) pad[i] ^= cbc[i]; - aes_encrypt(ctx, pad, mac); + wpa_aes_encrypt(ctx, pad, mac); aes_encrypt_deinit(ctx); return 0; } diff --git a/components/wpa_supplicant/src/crypto/aes-unwrap.c b/components/wpa_supplicant/src/crypto/aes-unwrap.c index ec793d9dbf..08aedc12de 100644 --- a/components/wpa_supplicant/src/crypto/aes-unwrap.c +++ b/components/wpa_supplicant/src/crypto/aes-unwrap.c @@ -58,7 +58,7 @@ int aes_unwrap(const u8 *kek, size_t kek_len, int n, const u8 *cipher, b[4] ^= t >> 24; os_memcpy(b + 8, r, 8); - aes_decrypt(ctx, b, b); + wpa_aes_decrypt(ctx, b, b); os_memcpy(a, b, 8); os_memcpy(r, b + 8, 8); r -= 8; diff --git a/components/wpa_supplicant/src/crypto/aes-wrap.c b/components/wpa_supplicant/src/crypto/aes-wrap.c index 7ed34e803e..49621d2231 100644 --- a/components/wpa_supplicant/src/crypto/aes-wrap.c +++ b/components/wpa_supplicant/src/crypto/aes-wrap.c @@ -53,7 +53,7 @@ int aes_wrap(const u8 *kek, size_t kek_len, int n, const u8 *plain, u8 *cipher) for (i = 1; i <= n; i++) { os_memcpy(b, a, 8); os_memcpy(b + 8, r, 8); - aes_encrypt(ctx, b, b); + wpa_aes_encrypt(ctx, b, b); os_memcpy(a, b, 8); t = n * j + i; a[7] ^= t; diff --git a/components/wpa_supplicant/src/crypto/aes.h b/components/wpa_supplicant/src/crypto/aes.h index 8ab3de2ee8..fe04fc4b2b 100644 --- a/components/wpa_supplicant/src/crypto/aes.h +++ b/components/wpa_supplicant/src/crypto/aes.h @@ -12,10 +12,10 @@ #define AES_BLOCK_SIZE 16 void * aes_encrypt_init(const u8 *key, size_t len); -int aes_encrypt(void *ctx, const u8 *plain, u8 *crypt); +int wpa_aes_encrypt(void *ctx, const u8 *plain, u8 *crypt); void aes_encrypt_deinit(void *ctx); void * aes_decrypt_init(const u8 *key, size_t len); -int aes_decrypt(void *ctx, const u8 *crypt, u8 *plain); +int wpa_aes_decrypt(void *ctx, const u8 *crypt, u8 *plain); void aes_decrypt_deinit(void *ctx); #endif /* AES_H */ diff --git a/components/wpa_supplicant/src/crypto/crypto.h b/components/wpa_supplicant/src/crypto/crypto.h index 9a43c9bfd9..f87a21872b 100644 --- a/components/wpa_supplicant/src/crypto/crypto.h +++ b/components/wpa_supplicant/src/crypto/crypto.h @@ -125,7 +125,7 @@ void * aes_encrypt_init(const u8 *key, size_t len); * @crypt: Buffer for the encrypted data (16 bytes) * Returns: 0 on success, -1 on failure */ -int aes_encrypt(void *ctx, const u8 *plain, u8 *crypt); +int wpa_aes_encrypt(void *ctx, const u8 *plain, u8 *crypt); /** * aes_encrypt_deinit - Deinitialize AES encryption @@ -148,7 +148,7 @@ void * aes_decrypt_init(const u8 *key, size_t len); * @plain: Buffer for the decrypted data (16 bytes) * Returns: 0 on success, -1 on failure */ -int aes_decrypt(void *ctx, const u8 *crypt, u8 *plain); +int wpa_aes_decrypt(void *ctx, const u8 *crypt, u8 *plain); /** * aes_decrypt_deinit - Deinitialize AES decryption diff --git a/components/wpa_supplicant/src/crypto/crypto_internal-cipher.c b/components/wpa_supplicant/src/crypto/crypto_internal-cipher.c index ad0930a5a9..4887fd36c6 100644 --- a/components/wpa_supplicant/src/crypto/crypto_internal-cipher.c +++ b/components/wpa_supplicant/src/crypto/crypto_internal-cipher.c @@ -120,7 +120,7 @@ int crypto_cipher_encrypt(struct crypto_cipher *ctx, const u8 *plain, for (i = 0; i < blocks; i++) { for (j = 0; j < AES_BLOCK_SIZE; j++) ctx->u.aes.cbc[j] ^= plain[j]; - aes_encrypt(ctx->u.aes.ctx_enc, ctx->u.aes.cbc, + wpa_aes_encrypt(ctx->u.aes.ctx_enc, ctx->u.aes.cbc, ctx->u.aes.cbc); os_memcpy(crypt, ctx->u.aes.cbc, AES_BLOCK_SIZE); plain += AES_BLOCK_SIZE; @@ -183,7 +183,7 @@ int crypto_cipher_decrypt(struct crypto_cipher *ctx, const u8 *crypt, blocks = len / AES_BLOCK_SIZE; for (i = 0; i < blocks; i++) { os_memcpy(tmp, crypt, AES_BLOCK_SIZE); - aes_decrypt(ctx->u.aes.ctx_dec, crypt, plain); + wpa_aes_decrypt(ctx->u.aes.ctx_dec, crypt, plain); for (j = 0; j < AES_BLOCK_SIZE; j++) plain[j] ^= ctx->u.aes.cbc[j]; os_memcpy(ctx->u.aes.cbc, tmp, AES_BLOCK_SIZE); diff --git a/components/wpa_supplicant/src/crypto/crypto_internal.c b/components/wpa_supplicant/src/crypto/crypto_internal.c index 3d14babe5a..d1426a8feb 100644 --- a/components/wpa_supplicant/src/crypto/crypto_internal.c +++ b/components/wpa_supplicant/src/crypto/crypto_internal.c @@ -57,7 +57,7 @@ struct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key, break; #ifdef CONFIG_SHA256 case CRYPTO_HASH_ALG_SHA256: - sha256_init(&ctx->u.sha256); + wpa_sha256_init(&ctx->u.sha256); break; #endif /* CONFIG_SHA256 */ #ifdef CONFIG_INTERNAL_SHA384 @@ -111,7 +111,7 @@ struct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key, #ifdef CONFIG_SHA256 case CRYPTO_HASH_ALG_HMAC_SHA256: if (key_len > sizeof(k_pad)) { - sha256_init(&ctx->u.sha256); + wpa_sha256_init(&ctx->u.sha256); sha256_process(&ctx->u.sha256, key, key_len); sha256_done(&ctx->u.sha256, tk); key = tk; @@ -125,7 +125,7 @@ struct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key, os_memset(k_pad + key_len, 0, sizeof(k_pad) - key_len); for (i = 0; i < sizeof(k_pad); i++) k_pad[i] ^= 0x36; - sha256_init(&ctx->u.sha256); + wpa_sha256_init(&ctx->u.sha256); sha256_process(&ctx->u.sha256, k_pad, sizeof(k_pad)); break; #endif /* CONFIG_SHA256 */ @@ -295,7 +295,7 @@ int crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len) sizeof(k_pad) - ctx->key_len); for (i = 0; i < sizeof(k_pad); i++) k_pad[i] ^= 0x5c; - sha256_init(&ctx->u.sha256); + wpa_sha256_init(&ctx->u.sha256); sha256_process(&ctx->u.sha256, k_pad, sizeof(k_pad)); sha256_process(&ctx->u.sha256, mac, 32); sha256_done(&ctx->u.sha256, mac); diff --git a/components/wpa_supplicant/src/crypto/crypto_mbedtls.c b/components/wpa_supplicant/src/crypto/crypto_mbedtls.c index d640a64189..d32321657a 100644 --- a/components/wpa_supplicant/src/crypto/crypto_mbedtls.c +++ b/components/wpa_supplicant/src/crypto/crypto_mbedtls.c @@ -239,7 +239,7 @@ int hmac_sha256_vector(const u8 *key, size_t key_len, size_t num_elem, len, mac); } -int hmac_sha256(const u8 *key, size_t key_len, const u8 *data, +int wpa_hmac_sha256(const u8 *key, size_t key_len, const u8 *data, size_t data_len, u8 *mac) { return hmac_sha256_vector(key, key_len, 1, &data, &data_len, mac); @@ -312,7 +312,7 @@ void *aes_encrypt_init(const u8 *key, size_t len) return aes_crypt_init(MBEDTLS_AES_ENCRYPT, key, len); } -int aes_encrypt(void *ctx, const u8 *plain, u8 *crypt) +int wpa_aes_encrypt(void *ctx, const u8 *plain, u8 *crypt) { return aes_crypt(ctx, MBEDTLS_AES_ENCRYPT, plain, crypt); } @@ -327,7 +327,7 @@ void * aes_decrypt_init(const u8 *key, size_t len) return aes_crypt_init(MBEDTLS_AES_DECRYPT, key, len); } -int aes_decrypt(void *ctx, const u8 *crypt, u8 *plain) +int wpa_aes_decrypt(void *ctx, const u8 *crypt, u8 *plain) { return aes_crypt(ctx, MBEDTLS_AES_DECRYPT, crypt, plain); } diff --git a/components/wpa_supplicant/src/crypto/crypto_ops.c b/components/wpa_supplicant/src/crypto/crypto_ops.c index d4aff08787..16b1364373 100644 --- a/components/wpa_supplicant/src/crypto/crypto_ops.c +++ b/components/wpa_supplicant/src/crypto/crypto_ops.c @@ -28,12 +28,12 @@ static int esp_aes_unwrap(const u8 *kek, int n, const u8 *cipher, u8 *plain) static void esp_aes_encrypt(void *ctx, const u8 *plain, u8 *crypt) { - aes_encrypt(ctx, plain, crypt); + wpa_aes_encrypt(ctx, plain, crypt); } static void esp_aes_decrypt(void *ctx, const u8 *crypt, u8 *plain) { - aes_decrypt(ctx, crypt, plain); + wpa_aes_decrypt(ctx, crypt, plain); } static int esp_aes_gmac(const u8 *key, size_t key_len, const u8 *iv, size_t iv_len, diff --git a/components/wpa_supplicant/src/crypto/sha256-internal.c b/components/wpa_supplicant/src/crypto/sha256-internal.c index ff1e2ba168..d763fa6f06 100644 --- a/components/wpa_supplicant/src/crypto/sha256-internal.c +++ b/components/wpa_supplicant/src/crypto/sha256-internal.c @@ -31,7 +31,7 @@ int sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len, if (TEST_FAIL()) return -1; - sha256_init(&ctx); + wpa_sha256_init(&ctx); for (i = 0; i < num_elem; i++) if (sha256_process(&ctx, addr[i], len[i])) return -1; @@ -124,7 +124,7 @@ static int sha256_compress(struct sha256_state *md, unsigned char *buf) /* Initialize the hash state */ -void sha256_init(struct sha256_state *md) +void wpa_sha256_init(struct sha256_state *md) { md->curlen = 0; md->length = 0; diff --git a/components/wpa_supplicant/src/crypto/sha256-tlsprf.c b/components/wpa_supplicant/src/crypto/sha256-tlsprf.c index 9045cd36b4..4d0c57e79e 100644 --- a/components/wpa_supplicant/src/crypto/sha256-tlsprf.c +++ b/components/wpa_supplicant/src/crypto/sha256-tlsprf.c @@ -57,7 +57,7 @@ int tls_prf_sha256(const u8 *secret, size_t secret_len, const char *label, while (pos < outlen) { if (hmac_sha256_vector(secret, secret_len, 3, addr, len, P) < 0 || - hmac_sha256(secret, secret_len, A, SHA256_MAC_LEN, A) < 0) + wpa_hmac_sha256(secret, secret_len, A, SHA256_MAC_LEN, A) < 0) return -1; clen = outlen - pos; diff --git a/components/wpa_supplicant/src/crypto/sha256.c b/components/wpa_supplicant/src/crypto/sha256.c index 17af964ad0..0fac0dd52d 100644 --- a/components/wpa_supplicant/src/crypto/sha256.c +++ b/components/wpa_supplicant/src/crypto/sha256.c @@ -97,7 +97,7 @@ int hmac_sha256_vector(const u8 *key, size_t key_len, size_t num_elem, * @mac: Buffer for the hash (32 bytes) * Returns: 0 on success, -1 on failure */ -int hmac_sha256(const u8 *key, size_t key_len, const u8 *data, +int wpa_hmac_sha256(const u8 *key, size_t key_len, const u8 *data, size_t data_len, u8 *mac) { return hmac_sha256_vector(key, key_len, 1, &data, &data_len, mac); diff --git a/components/wpa_supplicant/src/crypto/sha256.h b/components/wpa_supplicant/src/crypto/sha256.h index 8054bbe5c5..7ce7ddebe9 100644 --- a/components/wpa_supplicant/src/crypto/sha256.h +++ b/components/wpa_supplicant/src/crypto/sha256.h @@ -13,7 +13,7 @@ int hmac_sha256_vector(const u8 *key, size_t key_len, size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac); -int hmac_sha256(const u8 *key, size_t key_len, const u8 *data, +int wpa_hmac_sha256(const u8 *key, size_t key_len, const u8 *data, size_t data_len, u8 *mac); int sha256_prf(const u8 *key, size_t key_len, const char *label, const u8 *data, size_t data_len, u8 *buf, size_t buf_len); diff --git a/components/wpa_supplicant/src/crypto/sha256_i.h b/components/wpa_supplicant/src/crypto/sha256_i.h index a502d2ba5d..c53558abd8 100644 --- a/components/wpa_supplicant/src/crypto/sha256_i.h +++ b/components/wpa_supplicant/src/crypto/sha256_i.h @@ -17,7 +17,7 @@ struct sha256_state { u8 buf[SHA256_BLOCK_SIZE]; }; -void sha256_init(struct sha256_state *md); +void wpa_sha256_init(struct sha256_state *md); int sha256_process(struct sha256_state *md, const unsigned char *in, unsigned long inlen); int sha256_done(struct sha256_state *md, unsigned char *out); diff --git a/components/wpa_supplicant/src/wps/wps_attr_build.c b/components/wpa_supplicant/src/wps/wps_attr_build.c index c61114bdb2..ce74875dab 100644 --- a/components/wpa_supplicant/src/wps/wps_attr_build.c +++ b/components/wpa_supplicant/src/wps/wps_attr_build.c @@ -324,7 +324,7 @@ int wps_build_key_wrap_auth(struct wps_data *wps, struct wpabuf *msg) u8 hash[SHA256_MAC_LEN]; wpa_printf(MSG_DEBUG, "WPS: * Key Wrap Authenticator"); - hmac_sha256(wps->authkey, WPS_AUTHKEY_LEN, wpabuf_head(msg), + wpa_hmac_sha256(wps->authkey, WPS_AUTHKEY_LEN, wpabuf_head(msg), wpabuf_len(msg), hash); wpabuf_put_be16(msg, ATTR_KEY_WRAP_AUTH); wpabuf_put_be16(msg, WPS_KWA_LEN); diff --git a/components/wpa_supplicant/src/wps/wps_attr_process.c b/components/wpa_supplicant/src/wps/wps_attr_process.c index c298df3f69..880cacd8ae 100644 --- a/components/wpa_supplicant/src/wps/wps_attr_process.c +++ b/components/wpa_supplicant/src/wps/wps_attr_process.c @@ -68,7 +68,7 @@ int wps_process_key_wrap_auth(struct wps_data *wps, struct wpabuf *msg, return -1; } - hmac_sha256(wps->authkey, WPS_AUTHKEY_LEN, head, len, hash); + wpa_hmac_sha256(wps->authkey, WPS_AUTHKEY_LEN, head, len, hash); if (os_memcmp(hash, key_wrap_auth, WPS_KWA_LEN) != 0) { wpa_printf(MSG_DEBUG, "WPS: Invalid KWA"); return -1; diff --git a/components/wpa_supplicant/src/wps/wps_common.c b/components/wpa_supplicant/src/wps/wps_common.c index ead31af3e0..dcbf39aff8 100644 --- a/components/wpa_supplicant/src/wps/wps_common.c +++ b/components/wpa_supplicant/src/wps/wps_common.c @@ -139,10 +139,10 @@ void wps_derive_psk(struct wps_data *wps, const u8 *dev_passwd, { u8 hash[SHA256_MAC_LEN]; - hmac_sha256(wps->authkey, WPS_AUTHKEY_LEN, dev_passwd, + wpa_hmac_sha256(wps->authkey, WPS_AUTHKEY_LEN, dev_passwd, (dev_passwd_len + 1) / 2, hash); os_memcpy(wps->psk1, hash, WPS_PSK_LEN); - hmac_sha256(wps->authkey, WPS_AUTHKEY_LEN, + wpa_hmac_sha256(wps->authkey, WPS_AUTHKEY_LEN, dev_passwd + (dev_passwd_len + 1) / 2, dev_passwd_len / 2, hash); os_memcpy(wps->psk2, hash, WPS_PSK_LEN); -- 2.17.1