mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
crypto: inside-secure - Replace generic aes with libaes
Commit363a90c2d5("crypto: safexcel/aes - switch to library version of key expansion routine") removed CRYPTO_AES in the config. However, some portions of codes still rely on generic AES cipher (e.g. refer to safexcel_aead_gcm_cra_init(), safexcel_xcbcmac_cra_init()). This causes transform allocation failure for those algos, if CRYPTO_AES is not manually enabled. To resolve that, we replace all existing AES cipher dependent codes with their AES library counterpart. Fixes:363a90c2d5("crypto: safexcel/aes - switch to library version of key expansion routine") Signed-off-by: Peter Harliman Liem <pliem@maxlinear.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
committed by
Herbert Xu
parent
49186a7d9e
commit
320406cb60
@@ -63,7 +63,6 @@ struct safexcel_cipher_ctx {
|
||||
u32 hash_alg;
|
||||
u32 state_sz;
|
||||
|
||||
struct crypto_cipher *hkaes;
|
||||
struct crypto_aead *fback;
|
||||
};
|
||||
|
||||
@@ -2607,15 +2606,8 @@ 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 */
|
||||
crypto_cipher_clear_flags(ctx->hkaes, CRYPTO_TFM_REQ_MASK);
|
||||
crypto_cipher_set_flags(ctx->hkaes, crypto_aead_get_flags(ctfm) &
|
||||
CRYPTO_TFM_REQ_MASK);
|
||||
ret = crypto_cipher_setkey(ctx->hkaes, key, len);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
memset(hashkey, 0, AES_BLOCK_SIZE);
|
||||
crypto_cipher_encrypt_one(ctx->hkaes, (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++) {
|
||||
@@ -2644,15 +2636,11 @@ static int safexcel_aead_gcm_cra_init(struct crypto_tfm *tfm)
|
||||
ctx->xcm = EIP197_XCM_MODE_GCM;
|
||||
ctx->mode = CONTEXT_CONTROL_CRYPTO_MODE_XCM; /* override default */
|
||||
|
||||
ctx->hkaes = crypto_alloc_cipher("aes", 0, 0);
|
||||
return PTR_ERR_OR_ZERO(ctx->hkaes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void safexcel_aead_gcm_cra_exit(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
|
||||
crypto_free_cipher(ctx->hkaes);
|
||||
safexcel_aead_cra_exit(tfm);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user