@@ -154,11 +154,11 @@ static int cbc_encrypt(struct skcipher_request *req)
u8 *dst = walk.dst.virt.addr;
u8 *prev = walk.iv;
do {
crypto_xor_cpy(dst, src, prev, AES_BLOCK_SIZE);
- aes_encrypt_new(&ctx->fallback, dst, dst);
+ aes_encrypt(&ctx->fallback, dst, dst);
prev = dst;
src += AES_BLOCK_SIZE;
dst += AES_BLOCK_SIZE;
nbytes -= AES_BLOCK_SIZE;
} while (nbytes >= AES_BLOCK_SIZE);
@@ -280,11 +280,11 @@ static int __xts_crypt(struct skcipher_request *req, bool encrypt,
err = skcipher_walk_virt(&walk, req, true);
if (err)
return err;
- aes_encrypt_new(&ctx->tweak_key, walk.iv, walk.iv);
+ aes_encrypt(&ctx->tweak_key, walk.iv, walk.iv);
while (walk.nbytes >= AES_BLOCK_SIZE) {
unsigned int blocks = walk.nbytes / AES_BLOCK_SIZE;
int reorder_last_tweak = !encrypt && tail > 0;
@@ -312,13 +312,13 @@ static int __xts_crypt(struct skcipher_request *req, bool encrypt,
scatterwalk_map_and_copy(buf, req->src, req->cryptlen, tail, 0);
crypto_xor(buf, req->iv, AES_BLOCK_SIZE);
if (encrypt)
- aes_encrypt_new(&ctx->fallback, buf, buf);
+ aes_encrypt(&ctx->fallback, buf, buf);
else
- aes_decrypt_new(&ctx->fallback, buf, buf);
+ aes_decrypt(&ctx->fallback, buf, buf);
crypto_xor(buf, req->iv, AES_BLOCK_SIZE);
scatterwalk_map_and_copy(buf, req->dst, req->cryptlen - AES_BLOCK_SIZE,
AES_BLOCK_SIZE + tail, 1);
@@ -210,11 +210,11 @@ static int gcm_aes_setkey(struct crypto_aead *tfm, const u8 *inkey,
ret = aes_prepareenckey(&aes_key, inkey, keylen);
if (ret)
return -EINVAL;
- aes_encrypt_new(&aes_key, (u8 *)&k, (u8[AES_BLOCK_SIZE]){});
+ aes_encrypt(&aes_key, (u8 *)&k, (u8[AES_BLOCK_SIZE]){});
/*
* Note: this assumes that the arm implementation of the AES library
* stores the standard round keys in k.rndkeys.
*/
@@ -196,11 +196,11 @@ static int gcm_aes_setkey(struct crypto_aead *tfm, const u8 *inkey,
ret = aes_prepareenckey(&ctx->aes_key, inkey, keylen);
if (ret)
return -EINVAL;
- aes_encrypt_new(&ctx->aes_key, key, (u8[AES_BLOCK_SIZE]){});
+ aes_encrypt(&ctx->aes_key, key, (u8[AES_BLOCK_SIZE]){});
/* needed for the fallback */
memcpy(&ctx->ghash_key.k, key, GHASH_BLOCK_SIZE);
ghash_reflect(ctx->ghash_key.h[0], &ctx->ghash_key.k);
@@ -320,11 +320,11 @@ static int riscv64_aes_xts_crypt(struct skcipher_request *req, bool enc)
if (req->cryptlen < AES_BLOCK_SIZE)
return -EINVAL;
/* Encrypt the IV with the tweak key to get the first tweak. */
- aes_encrypt_new(&ctx->tweak_key, req->iv, req->iv);
+ aes_encrypt(&ctx->tweak_key, req->iv, req->iv);
err = skcipher_walk_virt(&walk, req, false);
/*
* If the message length isn't divisible by the AES block size and the
@@ -1211,11 +1211,11 @@ static int gcm_setkey(struct crypto_aead *tfm, const u8 *raw_key,
be128 h1 = {};
be128 h;
int i;
/* Encrypt the all-zeroes block to get the hash key H^1 */
- aes_encrypt_new(&key->aes_key, (u8 *)&h1, (u8 *)&h1);
+ aes_encrypt(&key->aes_key, (u8 *)&h1, (u8 *)&h1);
/* Compute H^1 * x^-1 */
h = h1;
gf128mul_lle(&h, (const be128 *)x_to_the_minus1);
@@ -21,18 +21,18 @@ static int crypto_aes_setkey(struct crypto_tfm *tfm, const u8 *in_key,
static void crypto_aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
{
const struct aes_key *key = crypto_tfm_ctx(tfm);
- aes_encrypt_new(key, out, in);
+ aes_encrypt(key, out, in);
}
static void crypto_aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
{
const struct aes_key *key = crypto_tfm_ctx(tfm);
- aes_decrypt_new(key, out, in);
+ aes_decrypt(key, out, in);
}
static struct crypto_alg alg = {
.cra_name = "aes",
.cra_driver_name = "aes-lib",
@@ -17,11 +17,11 @@
static void drbg_kcapi_sym(struct aes_enckey *aeskey, unsigned char *outval,
const struct drbg_string *in, u8 blocklen_bytes)
{
/* there is only component in *in */
BUG_ON(in->len < blocklen_bytes);
- aes_encrypt_new(aeskey, outval, in->buf);
+ aes_encrypt(aeskey, outval, in->buf);
}
/* BCC function for CTR DRBG as defined in 10.4.3 */
static void drbg_ctr_bcc(struct aes_enckey *aeskey,
@@ -499,11 +499,11 @@ static int crypto4xx_compute_gcm_hash_key_sw(__le32 *hash_start, const u8 *key,
if (rc) {
pr_err("aes_prepareenckey() failed: %d\n", rc);
return rc;
}
- aes_encrypt_new(&aes, src, src);
+ aes_encrypt(&aes, src, src);
crypto4xx_memcpy_to_le32(hash_start, src, 16);
memzero_explicit(&aes, sizeof(aes));
return 0;
}
@@ -288,11 +288,11 @@ static int ccp_aes_cmac_setkey(struct crypto_ahash *tfm, const u8 *key,
if (ret)
return ret;
/* Encrypt a block of zeroes - use key area in context */
memset(ctx->u.aes.key, 0, sizeof(ctx->u.aes.key));
- aes_encrypt_new(&aes, ctx->u.aes.key, ctx->u.aes.key);
+ aes_encrypt(&aes, ctx->u.aes.key, ctx->u.aes.key);
memzero_explicit(&aes, sizeof(aes));
/* Generate K1 and K2 */
k0_hi = be64_to_cpu(*((__be64 *)ctx->u.aes.key));
k0_lo = be64_to_cpu(*((__be64 *)ctx->u.aes.key + 1));
@@ -1047,19 +1047,19 @@ static int chcr_update_tweak(struct skcipher_request *req, u8 *iv,
ret = aes_preparekey(&aes, key, keylen - 8);
else
ret = aes_preparekey(&aes, key, keylen);
if (ret)
return ret;
- aes_encrypt_new(&aes, iv, iv);
+ aes_encrypt(&aes, iv, iv);
for (i = 0; i < round8; i++)
gf128mul_x8_ble((le128 *)iv, (le128 *)iv);
for (i = 0; i < (round % 8); i++)
gf128mul_x_ble((le128 *)iv, (le128 *)iv);
if (!isfinal)
- aes_decrypt_new(&aes, iv, iv);
+ aes_decrypt(&aes, iv, iv);
memzero_explicit(&aes, sizeof(aes));
return 0;
}
@@ -3448,11 +3448,11 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key,
if (ret) {
aeadctx->enckey_len = 0;
goto out;
}
memset(gctx->ghash_h, 0, AEAD_H_SIZE);
- aes_encrypt_new(&aes, gctx->ghash_h, gctx->ghash_h);
+ aes_encrypt(&aes, gctx->ghash_h, gctx->ghash_h);
memzero_explicit(&aes, sizeof(aes));
out:
return ret;
}
@@ -2529,11 +2529,11 @@ static int safexcel_aead_gcm_setkey(struct crypto_aead *ctfm, const u8 *key,
ctx->key_len = len;
/* Compute hash key by encrypting zeroes with cipher key */
memset(hashkey, 0, AES_BLOCK_SIZE);
- aes_encrypt_new(&aes, (u8 *)hashkey, (u8 *)hashkey);
+ aes_encrypt(&aes, (u8 *)hashkey, (u8 *)hashkey);
if (priv->flags & EIP197_TRC_CACHE && ctx->base.ctxr_dma) {
for (i = 0; i < AES_BLOCK_SIZE / sizeof(u32); i++) {
if (be32_to_cpu(ctx->base.ipad.be[i]) != hashkey[i]) {
ctx->base.needs_inv = true;
@@ -820,11 +820,11 @@ static int safexcel_ahash_final(struct ahash_request *areq)
/* K3 */
result[i] = swab32(ctx->base.ipad.word[i + 4]);
}
areq->result[0] ^= 0x80; // 10- padding
- aes_encrypt_new(ctx->aes, areq->result, areq->result);
+ aes_encrypt(ctx->aes, areq->result, areq->result);
return 0;
} else if (unlikely(req->hmac &&
(req->len == req->block_sz) &&
!areq->nbytes)) {
/*
@@ -1979,16 +1979,16 @@ static int safexcel_xcbcmac_setkey(struct crypto_ahash *tfm, const u8 *key,
ret = aes_prepareenckey(ctx->aes, key, len);
if (ret)
return ret;
/* precompute the XCBC key material */
- aes_encrypt_new(ctx->aes, (u8 *)key_tmp + 2 * AES_BLOCK_SIZE,
- "\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1");
- aes_encrypt_new(ctx->aes, (u8 *)key_tmp,
- "\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2");
- aes_encrypt_new(ctx->aes, (u8 *)key_tmp + AES_BLOCK_SIZE,
- "\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3");
+ aes_encrypt(ctx->aes, (u8 *)key_tmp + 2 * AES_BLOCK_SIZE,
+ "\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1\x1");
+ aes_encrypt(ctx->aes, (u8 *)key_tmp,
+ "\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2\x2");
+ aes_encrypt(ctx->aes, (u8 *)key_tmp + AES_BLOCK_SIZE,
+ "\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3");
for (i = 0; i < 3 * AES_BLOCK_SIZE / sizeof(u32); i++)
ctx->base.ipad.word[i] = swab32(key_tmp[i]);
ret = aes_prepareenckey(ctx->aes,
(u8 *)key_tmp + 2 * AES_BLOCK_SIZE,
@@ -2070,11 +2070,11 @@ static int safexcel_cmac_setkey(struct crypto_ahash *tfm, const u8 *key,
ctx->base.ipad.word[i + 8] = get_unaligned_be32(&key[4 * i]);
/* code below borrowed from crypto/cmac.c */
/* encrypt the zero block */
memset(consts, 0, AES_BLOCK_SIZE);
- aes_encrypt_new(ctx->aes, (u8 *)consts, (u8 *)consts);
+ aes_encrypt(ctx->aes, (u8 *)consts, (u8 *)consts);
gfmask = 0x87;
_const[0] = be64_to_cpu(consts[1]);
_const[1] = be64_to_cpu(consts[0]);
@@ -175,11 +175,11 @@ static int omap_aes_gcm_copy_buffers(struct omap_aes_dev *dd,
static int do_encrypt_iv(struct aead_request *req, u32 *tag, u32 *iv)
{
struct omap_aes_gcm_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req));
- aes_encrypt_new(&ctx->akey, (u8 *)tag, (const u8 *)iv);
+ aes_encrypt(&ctx->akey, (u8 *)tag, (const u8 *)iv);
return 0;
}
void omap_aes_gcm_dma_out_callback(void *data)
{
@@ -208,11 +208,11 @@ static int ch_ipsec_setkey(struct xfrm_state *x,
if (ret) {
sa_entry->enckey_len = 0;
goto out;
}
memset(ghash_h, 0, AEAD_H_SIZE);
- aes_encrypt_new(&aes, ghash_h, ghash_h);
+ aes_encrypt(&aes, ghash_h, ghash_h);
memzero_explicit(&aes, sizeof(aes));
memcpy(sa_entry->key + (DIV_ROUND_UP(sa_entry->enckey_len, 16) *
16), ghash_h, AEAD_H_SIZE);
sa_entry->kctx_len = ((DIV_ROUND_UP(sa_entry->enckey_len, 16)) << 4) +
@@ -141,11 +141,11 @@ static int chcr_ktls_save_keys(struct chcr_ktls_info *tx_info,
ret = aes_prepareenckey(&aes, key, keylen);
if (ret)
goto out;
memset(ghash_h, 0, ghash_size);
- aes_encrypt_new(&aes, ghash_h, ghash_h);
+ aes_encrypt(&aes, ghash_h, ghash_h);
memzero_explicit(&aes, sizeof(aes));
/* fill the Key context */
if (direction == TLS_OFFLOAD_CTX_DIR_TX) {
kctx->ctx_hdr = FILL_KEY_CTX_HDR(ck_size,
@@ -294,11 +294,11 @@ static int chtls_key_info(struct chtls_sock *csk,
ret = aes_prepareenckey(&aes, key, keylen);
if (ret)
return ret;
memset(ghash_h, 0, AEAD_H_SIZE);
- aes_encrypt_new(&aes, ghash_h, ghash_h);
+ aes_encrypt(&aes, ghash_h, ghash_h);
memzero_explicit(&aes, sizeof(aes));
csk->tlshws.keylen = key_ctx_size;
/* Copy the Key context */
if (optname == TLS_RX) {
@@ -509,11 +509,11 @@ static int vsc8584_macsec_derive_key(const u8 *key, u16 key_len, u8 hkey[16])
ret = aes_prepareenckey(&aes, key, key_len);
if (ret)
return ret;
- aes_encrypt_new(&aes, hkey, input);
+ aes_encrypt(&aes, hkey, input);
memzero_explicit(&aes, sizeof(aes));
return 0;
}
static int vsc8584_macsec_transformation(struct phy_device *phydev,
@@ -638,11 +638,11 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
{
struct aes_enckey aes;
aes_prepareenckey(&aes, key, 16);
- aes_encrypt_new(&aes, ciphertext, data);
+ aes_encrypt(&aes, ciphertext, data);
memzero_explicit(&aes, sizeof(aes));
}
/************************************************/
/* construct_mic_iv() */
@@ -1434,16 +1434,16 @@ static int omac1_aes_128_vector(u8 *key, size_t num_elem,
pos = addr[e];
end = pos + len[e];
}
}
if (left > AES_BLOCK_SIZE)
- aes_encrypt_new(&aes, cbc, cbc);
+ aes_encrypt(&aes, cbc, cbc);
left -= AES_BLOCK_SIZE;
}
memset(pad, 0, AES_BLOCK_SIZE);
- aes_encrypt_new(&aes, pad, pad);
+ aes_encrypt(&aes, pad, pad);
gf_mulx(pad);
if (left || total_len == 0) {
for (i = 0; i < left; i++) {
cbc[i] ^= *pos++;
@@ -1457,11 +1457,11 @@ static int omac1_aes_128_vector(u8 *key, size_t num_elem,
gf_mulx(pad);
}
for (i = 0; i < AES_BLOCK_SIZE; i++)
pad[i] ^= cbc[i];
- aes_encrypt_new(&aes, pad, mac);
+ aes_encrypt(&aes, pad, mac);
memzero_explicit(&aes, sizeof(aes));
return 0;
}
/**
@@ -299,31 +299,31 @@ typedef union {
const struct aes_enckey *enc_key;
const struct aes_key *full_key;
} aes_encrypt_arg __attribute__ ((__transparent_union__));
/**
- * aes_encrypt_new() - Encrypt a single AES block
+ * aes_encrypt() - Encrypt a single AES block
* @key: The AES key, as a pointer to either an encryption-only key
* (struct aes_enckey) or a full, bidirectional key (struct aes_key).
* @out: Buffer to store the ciphertext block
* @in: Buffer containing the plaintext block
*
* Context: Any context.
*/
-void aes_encrypt_new(aes_encrypt_arg key, u8 out[at_least AES_BLOCK_SIZE],
- const u8 in[at_least AES_BLOCK_SIZE]);
+void aes_encrypt(aes_encrypt_arg key, u8 out[at_least AES_BLOCK_SIZE],
+ const u8 in[at_least AES_BLOCK_SIZE]);
/**
- * aes_decrypt_new() - Decrypt a single AES block
+ * aes_decrypt() - Decrypt a single AES block
* @key: The AES key, previously initialized by aes_preparekey()
* @out: Buffer to store the plaintext block
* @in: Buffer containing the ciphertext block
*
* Context: Any context.
*/
-void aes_decrypt_new(const struct aes_key *key, u8 out[at_least AES_BLOCK_SIZE],
- const u8 in[at_least AES_BLOCK_SIZE]);
+void aes_decrypt(const struct aes_key *key, u8 out[at_least AES_BLOCK_SIZE],
+ const u8 in[at_least AES_BLOCK_SIZE]);
extern const u8 crypto_aes_sbox[];
extern const u8 crypto_aes_inv_sbox[];
extern const u32 __cacheline_aligned aes_enc_tab[256];
extern const u32 __cacheline_aligned aes_dec_tab[256];
@@ -500,23 +500,23 @@ int aes_prepareenckey(struct aes_enckey *key, const u8 *in_key, size_t key_len)
{
return __aes_preparekey(key, NULL, in_key, key_len);
}
EXPORT_SYMBOL(aes_prepareenckey);
-void aes_encrypt_new(aes_encrypt_arg key, u8 out[AES_BLOCK_SIZE],
- const u8 in[AES_BLOCK_SIZE])
+void aes_encrypt(aes_encrypt_arg key, u8 out[AES_BLOCK_SIZE],
+ const u8 in[AES_BLOCK_SIZE])
{
aes_encrypt_arch(key.enc_key, out, in);
}
-EXPORT_SYMBOL(aes_encrypt_new);
+EXPORT_SYMBOL(aes_encrypt);
-void aes_decrypt_new(const struct aes_key *key, u8 out[AES_BLOCK_SIZE],
- const u8 in[AES_BLOCK_SIZE])
+void aes_decrypt(const struct aes_key *key, u8 out[AES_BLOCK_SIZE],
+ const u8 in[AES_BLOCK_SIZE])
{
aes_decrypt_arch(key, out, in);
}
-EXPORT_SYMBOL(aes_decrypt_new);
+EXPORT_SYMBOL(aes_decrypt);
#ifdef aes_mod_init_arch
static int __init aes_mod_init(void)
{
aes_mod_init_arch();
@@ -23,11 +23,11 @@ static void aescfb_encrypt_block(const struct aes_enckey *key, void *dst,
* extent by pulling the entire S-box into the caches before doing any
* substitutions, but this strategy is more effective when running with
* interrupts disabled.
*/
local_irq_save(flags);
- aes_encrypt_new(key, dst, src);
+ aes_encrypt(key, dst, src);
local_irq_restore(flags);
}
/**
* aescfb_encrypt - Perform AES-CFB encryption on a block of data
@@ -24,11 +24,11 @@ static void aesgcm_encrypt_block(const struct aes_enckey *key, void *dst,
* mitigates this risk to some extent by pulling the entire S-box into
* the caches before doing any substitutions, but this strategy is more
* effective when running with interrupts disabled.
*/
local_irq_save(flags);
- aes_encrypt_new(key, dst, src);
+ aes_encrypt(key, dst, src);
local_irq_restore(flags);
}
/**
* aesgcm_expandkey - Expands the AES and GHASH keys for the AES-GCM key
@@ -390,11 +390,11 @@ static int smp_e(const u8 *k, u8 *r)
}
/* Most significant octet of plaintextData corresponds to data[0] */
swap_buf(r, data, 16);
- aes_encrypt_new(&aes, data, data);
+ aes_encrypt(&aes, data, data);
/* Most significant octet of encryptedData corresponds to data[0] */
swap_buf(data, r, 16);
SMP_DBG("r %16phN", r);
Now that all callers of aes_encrypt() and aes_decrypt() have been updated to use aes_encrypt_new() and aes_decrypt_new() instead, and the original aes_encrypt() and aes_decrypt() have been removed, drop the "_new" suffix. This completes the migration to the revised AES API, which uses a different type for the key argument and is more efficient when the user only requires the encryption direction of the cipher. Signed-off-by: Eric Biggers <ebiggers@kernel.org> --- arch/arm/crypto/aes-neonbs-glue.c | 8 ++++---- arch/arm/crypto/ghash-ce-glue.c | 2 +- arch/arm64/crypto/ghash-ce-glue.c | 2 +- arch/riscv/crypto/aes-riscv64-glue.c | 2 +- arch/x86/crypto/aesni-intel_glue.c | 2 +- crypto/aes.c | 4 ++-- crypto/df_sp80090a.c | 2 +- drivers/crypto/amcc/crypto4xx_alg.c | 2 +- drivers/crypto/ccp/ccp-crypto-aes-cmac.c | 2 +- drivers/crypto/chelsio/chcr_algo.c | 6 +++--- drivers/crypto/inside-secure/safexcel_cipher.c | 2 +- drivers/crypto/inside-secure/safexcel_hash.c | 16 ++++++++-------- drivers/crypto/omap-aes-gcm.c | 2 +- .../chelsio/inline_crypto/ch_ipsec/chcr_ipsec.c | 2 +- .../chelsio/inline_crypto/ch_ktls/chcr_ktls.c | 2 +- .../chelsio/inline_crypto/chtls/chtls_hw.c | 2 +- drivers/net/phy/mscc/mscc_macsec.c | 2 +- drivers/staging/rtl8723bs/core/rtw_security.c | 8 ++++---- include/crypto/aes.h | 12 ++++++------ lib/crypto/aes.c | 12 ++++++------ lib/crypto/aescfb.c | 2 +- lib/crypto/aesgcm.c | 2 +- net/bluetooth/smp.c | 2 +- 23 files changed, 49 insertions(+), 49 deletions(-)