Skip to content
Snippets Groups Projects
Commit 26b265cd authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

Pull crypto update from Herbert Xu:
 - Made x86 ablk_helper generic for ARM
 - Phase out chainiv in favour of eseqiv (affects IPsec)
 - Fixed aes-cbc IV corruption on s390
 - Added constant-time crypto_memneq which replaces memcmp
 - Fixed aes-ctr in omap-aes
 - Added OMAP3 ROM RNG support
 - Add PRNG support for MSM SoC's
 - Add and use Job Ring API in caam
 - Misc fixes

[ NOTE! This pull request was sent within the merge window, but Herbert
  has some questionable email sending setup that makes him public enemy
  #1 as far as gmail is concerned.  So most of his emails seem to be
  trapped by gmail as spam, resulting in me not seeing them.  - Linus ]

* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (49 commits)
  crypto: s390 - Fix aes-cbc IV corruption
  crypto: omap-aes - Fix CTR mode counter length
  crypto: omap-sham - Add missing modalias
  padata: make the sequence counter an atomic_t
  crypto: caam - Modify the interface layers to use JR API's
  crypto: caam - Add API's to allocate/free Job Rings
  crypto: caam - Add Platform driver for Job Ring
  hwrng: msm - Add PRNG support for MSM SoC's
  ARM: DT: msm: Add Qualcomm's PRNG driver binding document
  crypto: skcipher - Use eseqiv even on UP machines
  crypto: talitos - Simplify key parsing
  crypto: picoxcell - Simplify and harden key parsing
  crypto: ixp4xx - Simplify and harden key parsing
  crypto: authencesn - Simplify key parsing
  crypto: authenc - Export key parsing helper function
  crypto: mv_cesa: remove deprecated IRQF_DISABLED
  hwrng: OMAP3 ROM Random Number Generator support
  crypto: sha256_ssse3 - also test for BMI2
  crypto: mv_cesa - Remove redundant of_match_ptr
  crypto: sahara - Remove redundant of_match_ptr
  ...
parents 2e7babfa f262f0f5
No related merge requests found
Showing
with 81 additions and 70 deletions
Qualcomm MSM pseudo random number generator.
Required properties:
- compatible : should be "qcom,prng"
- reg : specifies base physical address and size of the registers map
- clocks : phandle to clock-controller plus clock-specifier pair
- clock-names : "core" clocks all registers, FIFO and circuits in PRNG IP block
Example:
rng@f9bff000 {
compatible = "qcom,prng";
reg = <0xf9bff000 0x200>;
clocks = <&clock GCC_PRNG_AHB_CLK>;
clock-names = "core";
};
...@@ -209,13 +209,3 @@ void __init tegra_init_fuse(void) ...@@ -209,13 +209,3 @@ void __init tegra_init_fuse(void)
tegra_sku_id, tegra_cpu_process_id, tegra_sku_id, tegra_cpu_process_id,
tegra_core_process_id); tegra_core_process_id);
} }
unsigned long long tegra_chip_uid(void)
{
unsigned long long lo, hi;
lo = tegra_fuse_readl(FUSE_UID_LOW);
hi = tegra_fuse_readl(FUSE_UID_HIGH);
return (hi << 32ull) | lo;
}
EXPORT_SYMBOL(tegra_chip_uid);
...@@ -35,7 +35,6 @@ static u8 *ctrblk; ...@@ -35,7 +35,6 @@ static u8 *ctrblk;
static char keylen_flag; static char keylen_flag;
struct s390_aes_ctx { struct s390_aes_ctx {
u8 iv[AES_BLOCK_SIZE];
u8 key[AES_MAX_KEY_SIZE]; u8 key[AES_MAX_KEY_SIZE];
long enc; long enc;
long dec; long dec;
...@@ -441,30 +440,36 @@ static int cbc_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, ...@@ -441,30 +440,36 @@ static int cbc_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
return aes_set_key(tfm, in_key, key_len); return aes_set_key(tfm, in_key, key_len);
} }
static int cbc_aes_crypt(struct blkcipher_desc *desc, long func, void *param, static int cbc_aes_crypt(struct blkcipher_desc *desc, long func,
struct blkcipher_walk *walk) struct blkcipher_walk *walk)
{ {
struct s390_aes_ctx *sctx = crypto_blkcipher_ctx(desc->tfm);
int ret = blkcipher_walk_virt(desc, walk); int ret = blkcipher_walk_virt(desc, walk);
unsigned int nbytes = walk->nbytes; unsigned int nbytes = walk->nbytes;
struct {
u8 iv[AES_BLOCK_SIZE];
u8 key[AES_MAX_KEY_SIZE];
} param;
if (!nbytes) if (!nbytes)
goto out; goto out;
memcpy(param, walk->iv, AES_BLOCK_SIZE); memcpy(param.iv, walk->iv, AES_BLOCK_SIZE);
memcpy(param.key, sctx->key, sctx->key_len);
do { do {
/* only use complete blocks */ /* only use complete blocks */
unsigned int n = nbytes & ~(AES_BLOCK_SIZE - 1); unsigned int n = nbytes & ~(AES_BLOCK_SIZE - 1);
u8 *out = walk->dst.virt.addr; u8 *out = walk->dst.virt.addr;
u8 *in = walk->src.virt.addr; u8 *in = walk->src.virt.addr;
ret = crypt_s390_kmc(func, param, out, in, n); ret = crypt_s390_kmc(func, &param, out, in, n);
if (ret < 0 || ret != n) if (ret < 0 || ret != n)
return -EIO; return -EIO;
nbytes &= AES_BLOCK_SIZE - 1; nbytes &= AES_BLOCK_SIZE - 1;
ret = blkcipher_walk_done(desc, walk, nbytes); ret = blkcipher_walk_done(desc, walk, nbytes);
} while ((nbytes = walk->nbytes)); } while ((nbytes = walk->nbytes));
memcpy(walk->iv, param, AES_BLOCK_SIZE); memcpy(walk->iv, param.iv, AES_BLOCK_SIZE);
out: out:
return ret; return ret;
...@@ -481,7 +486,7 @@ static int cbc_aes_encrypt(struct blkcipher_desc *desc, ...@@ -481,7 +486,7 @@ static int cbc_aes_encrypt(struct blkcipher_desc *desc,
return fallback_blk_enc(desc, dst, src, nbytes); return fallback_blk_enc(desc, dst, src, nbytes);
blkcipher_walk_init(&walk, dst, src, nbytes); blkcipher_walk_init(&walk, dst, src, nbytes);
return cbc_aes_crypt(desc, sctx->enc, sctx->iv, &walk); return cbc_aes_crypt(desc, sctx->enc, &walk);
} }
static int cbc_aes_decrypt(struct blkcipher_desc *desc, static int cbc_aes_decrypt(struct blkcipher_desc *desc,
...@@ -495,7 +500,7 @@ static int cbc_aes_decrypt(struct blkcipher_desc *desc, ...@@ -495,7 +500,7 @@ static int cbc_aes_decrypt(struct blkcipher_desc *desc,
return fallback_blk_dec(desc, dst, src, nbytes); return fallback_blk_dec(desc, dst, src, nbytes);
blkcipher_walk_init(&walk, dst, src, nbytes); blkcipher_walk_init(&walk, dst, src, nbytes);
return cbc_aes_crypt(desc, sctx->dec, sctx->iv, &walk); return cbc_aes_crypt(desc, sctx->dec, &walk);
} }
static struct crypto_alg cbc_aes_alg = { static struct crypto_alg cbc_aes_alg = {
......
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
# #
avx_supported := $(call as-instr,vpxor %xmm0$(comma)%xmm0$(comma)%xmm0,yes,no) avx_supported := $(call as-instr,vpxor %xmm0$(comma)%xmm0$(comma)%xmm0,yes,no)
avx2_supported := $(call as-instr,vpgatherdd %ymm0$(comma)(%eax$(comma)%ymm1\
$(comma)4)$(comma)%ymm2,yes,no)
obj-$(CONFIG_CRYPTO_ABLK_HELPER_X86) += ablk_helper.o
obj-$(CONFIG_CRYPTO_GLUE_HELPER_X86) += glue_helper.o obj-$(CONFIG_CRYPTO_GLUE_HELPER_X86) += glue_helper.o
obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <asm/cpu_device_id.h> #include <asm/cpu_device_id.h>
#include <asm/i387.h> #include <asm/i387.h>
#include <asm/crypto/aes.h> #include <asm/crypto/aes.h>
#include <asm/crypto/ablk_helper.h> #include <crypto/ablk_helper.h>
#include <crypto/scatterwalk.h> #include <crypto/scatterwalk.h>
#include <crypto/internal/aead.h> #include <crypto/internal/aead.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/err.h> #include <linux/err.h>
#include <crypto/ablk_helper.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/ctr.h> #include <crypto/ctr.h>
#include <crypto/lrw.h> #include <crypto/lrw.h>
...@@ -21,7 +22,6 @@ ...@@ -21,7 +22,6 @@
#include <asm/xcr.h> #include <asm/xcr.h>
#include <asm/xsave.h> #include <asm/xsave.h>
#include <asm/crypto/camellia.h> #include <asm/crypto/camellia.h>
#include <asm/crypto/ablk_helper.h>
#include <asm/crypto/glue_helper.h> #include <asm/crypto/glue_helper.h>
#define CAMELLIA_AESNI_PARALLEL_BLOCKS 16 #define CAMELLIA_AESNI_PARALLEL_BLOCKS 16
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/err.h> #include <linux/err.h>
#include <crypto/ablk_helper.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/ctr.h> #include <crypto/ctr.h>
#include <crypto/lrw.h> #include <crypto/lrw.h>
...@@ -21,7 +22,6 @@ ...@@ -21,7 +22,6 @@
#include <asm/xcr.h> #include <asm/xcr.h>
#include <asm/xsave.h> #include <asm/xsave.h>
#include <asm/crypto/camellia.h> #include <asm/crypto/camellia.h>
#include <asm/crypto/ablk_helper.h>
#include <asm/crypto/glue_helper.h> #include <asm/crypto/glue_helper.h>
#define CAMELLIA_AESNI_PARALLEL_BLOCKS 16 #define CAMELLIA_AESNI_PARALLEL_BLOCKS 16
......
...@@ -26,13 +26,13 @@ ...@@ -26,13 +26,13 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/err.h> #include <linux/err.h>
#include <crypto/ablk_helper.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/cast5.h> #include <crypto/cast5.h>
#include <crypto/cryptd.h> #include <crypto/cryptd.h>
#include <crypto/ctr.h> #include <crypto/ctr.h>
#include <asm/xcr.h> #include <asm/xcr.h>
#include <asm/xsave.h> #include <asm/xsave.h>
#include <asm/crypto/ablk_helper.h>
#include <asm/crypto/glue_helper.h> #include <asm/crypto/glue_helper.h>
#define CAST5_PARALLEL_BLOCKS 16 #define CAST5_PARALLEL_BLOCKS 16
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/err.h> #include <linux/err.h>
#include <crypto/ablk_helper.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/cast6.h> #include <crypto/cast6.h>
#include <crypto/cryptd.h> #include <crypto/cryptd.h>
...@@ -37,7 +38,6 @@ ...@@ -37,7 +38,6 @@
#include <crypto/xts.h> #include <crypto/xts.h>
#include <asm/xcr.h> #include <asm/xcr.h>
#include <asm/xsave.h> #include <asm/xsave.h>
#include <asm/crypto/ablk_helper.h>
#include <asm/crypto/glue_helper.h> #include <asm/crypto/glue_helper.h>
#define CAST6_PARALLEL_BLOCKS 8 #define CAST6_PARALLEL_BLOCKS 8
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/err.h> #include <linux/err.h>
#include <crypto/ablk_helper.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/ctr.h> #include <crypto/ctr.h>
#include <crypto/lrw.h> #include <crypto/lrw.h>
...@@ -22,7 +23,6 @@ ...@@ -22,7 +23,6 @@
#include <asm/xcr.h> #include <asm/xcr.h>
#include <asm/xsave.h> #include <asm/xsave.h>
#include <asm/crypto/serpent-avx.h> #include <asm/crypto/serpent-avx.h>
#include <asm/crypto/ablk_helper.h>
#include <asm/crypto/glue_helper.h> #include <asm/crypto/glue_helper.h>
#define SERPENT_AVX2_PARALLEL_BLOCKS 16 #define SERPENT_AVX2_PARALLEL_BLOCKS 16
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/err.h> #include <linux/err.h>
#include <crypto/ablk_helper.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/serpent.h> #include <crypto/serpent.h>
#include <crypto/cryptd.h> #include <crypto/cryptd.h>
...@@ -38,7 +39,6 @@ ...@@ -38,7 +39,6 @@
#include <asm/xcr.h> #include <asm/xcr.h>
#include <asm/xsave.h> #include <asm/xsave.h>
#include <asm/crypto/serpent-avx.h> #include <asm/crypto/serpent-avx.h>
#include <asm/crypto/ablk_helper.h>
#include <asm/crypto/glue_helper.h> #include <asm/crypto/glue_helper.h>
/* 8-way parallel cipher functions */ /* 8-way parallel cipher functions */
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/err.h> #include <linux/err.h>
#include <crypto/ablk_helper.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/serpent.h> #include <crypto/serpent.h>
#include <crypto/cryptd.h> #include <crypto/cryptd.h>
...@@ -42,7 +43,6 @@ ...@@ -42,7 +43,6 @@
#include <crypto/lrw.h> #include <crypto/lrw.h>
#include <crypto/xts.h> #include <crypto/xts.h>
#include <asm/crypto/serpent-sse2.h> #include <asm/crypto/serpent-sse2.h>
#include <asm/crypto/ablk_helper.h>
#include <asm/crypto/glue_helper.h> #include <asm/crypto/glue_helper.h>
static void serpent_decrypt_cbc_xway(void *ctx, u128 *dst, const u128 *src) static void serpent_decrypt_cbc_xway(void *ctx, u128 *dst, const u128 *src)
......
...@@ -281,7 +281,7 @@ static int __init sha256_ssse3_mod_init(void) ...@@ -281,7 +281,7 @@ static int __init sha256_ssse3_mod_init(void)
/* allow AVX to override SSSE3, it's a little faster */ /* allow AVX to override SSSE3, it's a little faster */
if (avx_usable()) { if (avx_usable()) {
#ifdef CONFIG_AS_AVX2 #ifdef CONFIG_AS_AVX2
if (boot_cpu_has(X86_FEATURE_AVX2)) if (boot_cpu_has(X86_FEATURE_AVX2) && boot_cpu_has(X86_FEATURE_BMI2))
sha256_transform_asm = sha256_transform_rorx; sha256_transform_asm = sha256_transform_rorx;
else else
#endif #endif
...@@ -319,4 +319,4 @@ MODULE_LICENSE("GPL"); ...@@ -319,4 +319,4 @@ MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("SHA256 Secure Hash Algorithm, Supplemental SSE3 accelerated"); MODULE_DESCRIPTION("SHA256 Secure Hash Algorithm, Supplemental SSE3 accelerated");
MODULE_ALIAS("sha256"); MODULE_ALIAS("sha256");
MODULE_ALIAS("sha384"); MODULE_ALIAS("sha224");
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/err.h> #include <linux/err.h>
#include <crypto/ablk_helper.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/twofish.h> #include <crypto/twofish.h>
#include <crypto/cryptd.h> #include <crypto/cryptd.h>
...@@ -39,7 +40,6 @@ ...@@ -39,7 +40,6 @@
#include <asm/xcr.h> #include <asm/xcr.h>
#include <asm/xsave.h> #include <asm/xsave.h>
#include <asm/crypto/twofish.h> #include <asm/crypto/twofish.h>
#include <asm/crypto/ablk_helper.h>
#include <asm/crypto/glue_helper.h> #include <asm/crypto/glue_helper.h>
#include <crypto/scatterwalk.h> #include <crypto/scatterwalk.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
......
#include <asm/i387.h>
/*
* may_use_simd - whether it is allowable at this time to issue SIMD
* instructions or access the SIMD register file
*/
static __must_check inline bool may_use_simd(void)
{
return irq_fpu_usable();
}
...@@ -174,9 +174,8 @@ config CRYPTO_TEST ...@@ -174,9 +174,8 @@ config CRYPTO_TEST
help help
Quick & dirty crypto test module. Quick & dirty crypto test module.
config CRYPTO_ABLK_HELPER_X86 config CRYPTO_ABLK_HELPER
tristate tristate
depends on X86
select CRYPTO_CRYPTD select CRYPTO_CRYPTD
config CRYPTO_GLUE_HELPER_X86 config CRYPTO_GLUE_HELPER_X86
...@@ -695,7 +694,7 @@ config CRYPTO_AES_NI_INTEL ...@@ -695,7 +694,7 @@ config CRYPTO_AES_NI_INTEL
select CRYPTO_AES_X86_64 if 64BIT select CRYPTO_AES_X86_64 if 64BIT
select CRYPTO_AES_586 if !64BIT select CRYPTO_AES_586 if !64BIT
select CRYPTO_CRYPTD select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86 select CRYPTO_ABLK_HELPER
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_GLUE_HELPER_X86 if 64BIT select CRYPTO_GLUE_HELPER_X86 if 64BIT
select CRYPTO_LRW select CRYPTO_LRW
...@@ -895,7 +894,7 @@ config CRYPTO_CAMELLIA_AESNI_AVX_X86_64 ...@@ -895,7 +894,7 @@ config CRYPTO_CAMELLIA_AESNI_AVX_X86_64
depends on CRYPTO depends on CRYPTO
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_CRYPTD select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86 select CRYPTO_ABLK_HELPER
select CRYPTO_GLUE_HELPER_X86 select CRYPTO_GLUE_HELPER_X86
select CRYPTO_CAMELLIA_X86_64 select CRYPTO_CAMELLIA_X86_64
select CRYPTO_LRW select CRYPTO_LRW
...@@ -917,7 +916,7 @@ config CRYPTO_CAMELLIA_AESNI_AVX2_X86_64 ...@@ -917,7 +916,7 @@ config CRYPTO_CAMELLIA_AESNI_AVX2_X86_64
depends on CRYPTO depends on CRYPTO
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_CRYPTD select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86 select CRYPTO_ABLK_HELPER
select CRYPTO_GLUE_HELPER_X86 select CRYPTO_GLUE_HELPER_X86
select CRYPTO_CAMELLIA_X86_64 select CRYPTO_CAMELLIA_X86_64
select CRYPTO_CAMELLIA_AESNI_AVX_X86_64 select CRYPTO_CAMELLIA_AESNI_AVX_X86_64
...@@ -969,7 +968,7 @@ config CRYPTO_CAST5_AVX_X86_64 ...@@ -969,7 +968,7 @@ config CRYPTO_CAST5_AVX_X86_64
depends on X86 && 64BIT depends on X86 && 64BIT
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_CRYPTD select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86 select CRYPTO_ABLK_HELPER
select CRYPTO_CAST_COMMON select CRYPTO_CAST_COMMON
select CRYPTO_CAST5 select CRYPTO_CAST5
help help
...@@ -992,7 +991,7 @@ config CRYPTO_CAST6_AVX_X86_64 ...@@ -992,7 +991,7 @@ config CRYPTO_CAST6_AVX_X86_64
depends on X86 && 64BIT depends on X86 && 64BIT
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_CRYPTD select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86 select CRYPTO_ABLK_HELPER
select CRYPTO_GLUE_HELPER_X86 select CRYPTO_GLUE_HELPER_X86
select CRYPTO_CAST_COMMON select CRYPTO_CAST_COMMON
select CRYPTO_CAST6 select CRYPTO_CAST6
...@@ -1110,7 +1109,7 @@ config CRYPTO_SERPENT_SSE2_X86_64 ...@@ -1110,7 +1109,7 @@ config CRYPTO_SERPENT_SSE2_X86_64
depends on X86 && 64BIT depends on X86 && 64BIT
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_CRYPTD select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86 select CRYPTO_ABLK_HELPER
select CRYPTO_GLUE_HELPER_X86 select CRYPTO_GLUE_HELPER_X86
select CRYPTO_SERPENT select CRYPTO_SERPENT
select CRYPTO_LRW select CRYPTO_LRW
...@@ -1132,7 +1131,7 @@ config CRYPTO_SERPENT_SSE2_586 ...@@ -1132,7 +1131,7 @@ config CRYPTO_SERPENT_SSE2_586
depends on X86 && !64BIT depends on X86 && !64BIT
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_CRYPTD select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86 select CRYPTO_ABLK_HELPER
select CRYPTO_GLUE_HELPER_X86 select CRYPTO_GLUE_HELPER_X86
select CRYPTO_SERPENT select CRYPTO_SERPENT
select CRYPTO_LRW select CRYPTO_LRW
...@@ -1154,7 +1153,7 @@ config CRYPTO_SERPENT_AVX_X86_64 ...@@ -1154,7 +1153,7 @@ config CRYPTO_SERPENT_AVX_X86_64
depends on X86 && 64BIT depends on X86 && 64BIT
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_CRYPTD select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86 select CRYPTO_ABLK_HELPER
select CRYPTO_GLUE_HELPER_X86 select CRYPTO_GLUE_HELPER_X86
select CRYPTO_SERPENT select CRYPTO_SERPENT
select CRYPTO_LRW select CRYPTO_LRW
...@@ -1176,7 +1175,7 @@ config CRYPTO_SERPENT_AVX2_X86_64 ...@@ -1176,7 +1175,7 @@ config CRYPTO_SERPENT_AVX2_X86_64
depends on X86 && 64BIT depends on X86 && 64BIT
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_CRYPTD select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86 select CRYPTO_ABLK_HELPER
select CRYPTO_GLUE_HELPER_X86 select CRYPTO_GLUE_HELPER_X86
select CRYPTO_SERPENT select CRYPTO_SERPENT
select CRYPTO_SERPENT_AVX_X86_64 select CRYPTO_SERPENT_AVX_X86_64
...@@ -1292,7 +1291,7 @@ config CRYPTO_TWOFISH_AVX_X86_64 ...@@ -1292,7 +1291,7 @@ config CRYPTO_TWOFISH_AVX_X86_64
depends on X86 && 64BIT depends on X86 && 64BIT
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_CRYPTD select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86 select CRYPTO_ABLK_HELPER
select CRYPTO_GLUE_HELPER_X86 select CRYPTO_GLUE_HELPER_X86
select CRYPTO_TWOFISH_COMMON select CRYPTO_TWOFISH_COMMON
select CRYPTO_TWOFISH_X86_64 select CRYPTO_TWOFISH_X86_64
......
...@@ -2,8 +2,13 @@ ...@@ -2,8 +2,13 @@
# Cryptographic API # Cryptographic API
# #
# memneq MUST be built with -Os or -O0 to prevent early-return optimizations
# that will defeat memneq's actual purpose to prevent timing attacks.
CFLAGS_REMOVE_memneq.o := -O1 -O2 -O3
CFLAGS_memneq.o := -Os
obj-$(CONFIG_CRYPTO) += crypto.o obj-$(CONFIG_CRYPTO) += crypto.o
crypto-y := api.o cipher.o compress.o crypto-y := api.o cipher.o compress.o memneq.o
obj-$(CONFIG_CRYPTO_WORKQUEUE) += crypto_wq.o obj-$(CONFIG_CRYPTO_WORKQUEUE) += crypto_wq.o
...@@ -105,3 +110,4 @@ obj-$(CONFIG_XOR_BLOCKS) += xor.o ...@@ -105,3 +110,4 @@ obj-$(CONFIG_XOR_BLOCKS) += xor.o
obj-$(CONFIG_ASYNC_CORE) += async_tx/ obj-$(CONFIG_ASYNC_CORE) += async_tx/
obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys/ obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys/
obj-$(CONFIG_CRYPTO_HASH_INFO) += hash_info.o obj-$(CONFIG_CRYPTO_HASH_INFO) += hash_info.o
obj-$(CONFIG_CRYPTO_ABLK_HELPER) += ablk_helper.o
...@@ -28,10 +28,11 @@ ...@@ -28,10 +28,11 @@
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/hardirq.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/cryptd.h> #include <crypto/cryptd.h>
#include <asm/i387.h> #include <crypto/ablk_helper.h>
#include <asm/crypto/ablk_helper.h> #include <asm/simd.h>
int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key, int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key,
unsigned int key_len) unsigned int key_len)
...@@ -70,11 +71,11 @@ int ablk_encrypt(struct ablkcipher_request *req) ...@@ -70,11 +71,11 @@ int ablk_encrypt(struct ablkcipher_request *req)
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req); struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm); struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm);
if (!irq_fpu_usable()) { if (!may_use_simd()) {
struct ablkcipher_request *cryptd_req = struct ablkcipher_request *cryptd_req =
ablkcipher_request_ctx(req); ablkcipher_request_ctx(req);
memcpy(cryptd_req, req, sizeof(*req)); *cryptd_req = *req;
ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base); ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base);
return crypto_ablkcipher_encrypt(cryptd_req); return crypto_ablkcipher_encrypt(cryptd_req);
...@@ -89,11 +90,11 @@ int ablk_decrypt(struct ablkcipher_request *req) ...@@ -89,11 +90,11 @@ int ablk_decrypt(struct ablkcipher_request *req)
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req); struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm); struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm);
if (!irq_fpu_usable()) { if (!may_use_simd()) {
struct ablkcipher_request *cryptd_req = struct ablkcipher_request *cryptd_req =
ablkcipher_request_ctx(req); ablkcipher_request_ctx(req);
memcpy(cryptd_req, req, sizeof(*req)); *cryptd_req = *req;
ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base); ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base);
return crypto_ablkcipher_decrypt(cryptd_req); return crypto_ablkcipher_decrypt(cryptd_req);
......
...@@ -16,9 +16,7 @@ ...@@ -16,9 +16,7 @@
#include <crypto/internal/skcipher.h> #include <crypto/internal/skcipher.h>
#include <linux/cpumask.h> #include <linux/cpumask.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -30,8 +28,6 @@ ...@@ -30,8 +28,6 @@
#include "internal.h" #include "internal.h"
static const char *skcipher_default_geniv __read_mostly;
struct ablkcipher_buffer { struct ablkcipher_buffer {
struct list_head entry; struct list_head entry;
struct scatter_walk dst; struct scatter_walk dst;
...@@ -527,8 +523,7 @@ const char *crypto_default_geniv(const struct crypto_alg *alg) ...@@ -527,8 +523,7 @@ const char *crypto_default_geniv(const struct crypto_alg *alg)
alg->cra_blocksize) alg->cra_blocksize)
return "chainiv"; return "chainiv";
return alg->cra_flags & CRYPTO_ALG_ASYNC ? return "eseqiv";
"eseqiv" : skcipher_default_geniv;
} }
static int crypto_givcipher_default(struct crypto_alg *alg, u32 type, u32 mask) static int crypto_givcipher_default(struct crypto_alg *alg, u32 type, u32 mask)
...@@ -709,17 +704,3 @@ struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name, ...@@ -709,17 +704,3 @@ struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name,
return ERR_PTR(err); return ERR_PTR(err);
} }
EXPORT_SYMBOL_GPL(crypto_alloc_ablkcipher); EXPORT_SYMBOL_GPL(crypto_alloc_ablkcipher);
static int __init skcipher_module_init(void)
{
skcipher_default_geniv = num_possible_cpus() > 1 ?
"eseqiv" : "chainiv";
return 0;
}
static void skcipher_module_exit(void)
{
}
module_init(skcipher_module_init);
module_exit(skcipher_module_exit);
...@@ -230,11 +230,11 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx, ...@@ -230,11 +230,11 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx,
*/ */
if (byte_count < DEFAULT_BLK_SZ) { if (byte_count < DEFAULT_BLK_SZ) {
empty_rbuf: empty_rbuf:
for (; ctx->rand_data_valid < DEFAULT_BLK_SZ; while (ctx->rand_data_valid < DEFAULT_BLK_SZ) {
ctx->rand_data_valid++) {
*ptr = ctx->rand_data[ctx->rand_data_valid]; *ptr = ctx->rand_data[ctx->rand_data_valid];
ptr++; ptr++;
byte_count--; byte_count--;
ctx->rand_data_valid++;
if (byte_count == 0) if (byte_count == 0)
goto done; goto done;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment