mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-21 23:16:50 +08:00
Merge tag 'libcrypto-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux
Pull crypto library fixes from Eric Biggers: - Disable the "padlock" SHA-1 and SHA-256 driver on Zhaoxin processors, since it does not compute hash values correctly - Make a generated file be removed by 'make clean' - Fix excessive stack usage in some of the arm64 AES code * tag 'libcrypto-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux: lib/crypto: powerpc: Add powerpc/aesp8-ppc.S to clean-files crypto: padlock-sha - Disable for Zhaoxin processor crypto: arm64/aes-neonbs - Move key expansion off the stack
This commit is contained in:
@@ -76,19 +76,24 @@ static int aesbs_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
|
||||
unsigned int key_len)
|
||||
{
|
||||
struct aesbs_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
struct crypto_aes_ctx rk;
|
||||
struct crypto_aes_ctx *rk;
|
||||
int err;
|
||||
|
||||
err = aes_expandkey(&rk, in_key, key_len);
|
||||
rk = kmalloc(sizeof(*rk), GFP_KERNEL);
|
||||
if (!rk)
|
||||
return -ENOMEM;
|
||||
|
||||
err = aes_expandkey(rk, in_key, key_len);
|
||||
if (err)
|
||||
return err;
|
||||
goto out;
|
||||
|
||||
ctx->rounds = 6 + key_len / 4;
|
||||
|
||||
scoped_ksimd()
|
||||
aesbs_convert_key(ctx->rk, rk.key_enc, ctx->rounds);
|
||||
|
||||
return 0;
|
||||
aesbs_convert_key(ctx->rk, rk->key_enc, ctx->rounds);
|
||||
out:
|
||||
kfree_sensitive(rk);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int __ecb_crypt(struct skcipher_request *req,
|
||||
@@ -133,22 +138,26 @@ static int aesbs_cbc_ctr_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
|
||||
unsigned int key_len)
|
||||
{
|
||||
struct aesbs_cbc_ctr_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
struct crypto_aes_ctx rk;
|
||||
struct crypto_aes_ctx *rk;
|
||||
int err;
|
||||
|
||||
err = aes_expandkey(&rk, in_key, key_len);
|
||||
rk = kmalloc(sizeof(*rk), GFP_KERNEL);
|
||||
if (!rk)
|
||||
return -ENOMEM;
|
||||
|
||||
err = aes_expandkey(rk, in_key, key_len);
|
||||
if (err)
|
||||
return err;
|
||||
goto out;
|
||||
|
||||
ctx->key.rounds = 6 + key_len / 4;
|
||||
|
||||
memcpy(ctx->enc, rk.key_enc, sizeof(ctx->enc));
|
||||
memcpy(ctx->enc, rk->key_enc, sizeof(ctx->enc));
|
||||
|
||||
scoped_ksimd()
|
||||
aesbs_convert_key(ctx->key.rk, rk.key_enc, ctx->key.rounds);
|
||||
memzero_explicit(&rk, sizeof(rk));
|
||||
|
||||
return 0;
|
||||
aesbs_convert_key(ctx->key.rk, rk->key_enc, ctx->key.rounds);
|
||||
out:
|
||||
kfree_sensitive(rk);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int cbc_encrypt(struct skcipher_request *req)
|
||||
|
||||
@@ -332,6 +332,13 @@ static int __init padlock_init(void)
|
||||
if (!x86_match_cpu(padlock_sha_ids) || !boot_cpu_has(X86_FEATURE_PHE_EN))
|
||||
return -ENODEV;
|
||||
|
||||
/*
|
||||
* Skip family 0x07 and newer used by Zhaoxin processors,
|
||||
* as the driver's self-tests fail on these CPUs.
|
||||
*/
|
||||
if (c->x86 >= 0x07)
|
||||
return -ENODEV;
|
||||
|
||||
/* Register the newly added algorithm module if on *
|
||||
* VIA Nano processor, or else just do as before */
|
||||
if (c->x86_model < 0x0f) {
|
||||
|
||||
@@ -55,6 +55,9 @@ libaes-$(CONFIG_SPARC) += sparc/aes_asm.o
|
||||
libaes-$(CONFIG_X86) += x86/aes-aesni.o
|
||||
endif # CONFIG_CRYPTO_LIB_AES_ARCH
|
||||
|
||||
# clean-files must be defined unconditionally
|
||||
clean-files += powerpc/aesp8-ppc.S
|
||||
|
||||
################################################################################
|
||||
|
||||
obj-$(CONFIG_CRYPTO_LIB_AESCFB) += libaescfb.o
|
||||
|
||||
Reference in New Issue
Block a user