Skip to content

Commit

Permalink
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git…
Browse files Browse the repository at this point in the history
…/herbert/crypto-2.6

Pull crypto updates from Herbert Xu:
 "Here is the crypto update for 4.12:

  API:
   - Add batch registration for acomp/scomp
   - Change acomp testing to non-unique compressed result
   - Extend algorithm name limit to 128 bytes
   - Require setkey before accept(2) in algif_aead

  Algorithms:
   - Add support for deflate rfc1950 (zlib)

  Drivers:
   - Add accelerated crct10dif for powerpc
   - Add crc32 in stm32
   - Add sha384/sha512 in ccp
   - Add 3des/gcm(aes) for v5 devices in ccp
   - Add Queue Interface (QI) backend support in caam
   - Add new Exynos RNG driver
   - Add ThunderX ZIP driver
   - Add driver for hardware random generator on MT7623 SoC"

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (101 commits)
  crypto: stm32 - Fix OF module alias information
  crypto: algif_aead - Require setkey before accept(2)
  crypto: scomp - add support for deflate rfc1950 (zlib)
  crypto: scomp - allow registration of multiple scomps
  crypto: ccp - Change ISR handler method for a v5 CCP
  crypto: ccp - Change ISR handler method for a v3 CCP
  crypto: crypto4xx - rename ce_ring_contol to ce_ring_control
  crypto: testmgr - Allow ecb(cipher_null) in FIPS mode
  Revert "crypto: arm64/sha - Add constant operand modifier to ASM_EXPORT"
  crypto: ccp - Disable interrupts early on unload
  crypto: ccp - Use only the relevant interrupt bits
  hwrng: mtk - Add driver for hardware random generator on MT7623 SoC
  dt-bindings: hwrng: Add Mediatek hardware random generator bindings
  crypto: crct10dif-vpmsum - Fix missing preempt_disable()
  crypto: testmgr - replace compression known answer test
  crypto: acomp - allow registration of multiple acomps
  hwrng: n2 - Use devm_kcalloc() in n2rng_probe()
  crypto: chcr - Fix error handling related to 'chcr_alloc_shash'
  padata: get_next is never NULL
  crypto: exynos - Add new Exynos RNG driver
  ...
  • Loading branch information
torvalds committed May 2, 2017
2 parents 204f144 + 929562b commit 5a0387a
Show file tree
Hide file tree
Showing 137 changed files with 13,710 additions and 2,480 deletions.
6 changes: 3 additions & 3 deletions Documentation/crypto/api-samples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ Code Example For Use of Operational State Memory With SHASH
char ctx[];
};

static struct sdescinit_sdesc(struct crypto_shash *alg)
static struct sdesc init_sdesc(struct crypto_shash *alg)
{
struct sdescsdesc;
struct sdesc sdesc;
int size;

size = sizeof(struct shash_desc) + crypto_shash_descsize(alg);
Expand All @@ -172,7 +172,7 @@ Code Example For Use of Operational State Memory With SHASH
static int calc_hash(struct crypto_shashalg,
const unsigned chardata, unsigned int datalen,
unsigned chardigest) {
struct sdescsdesc;
struct sdesc sdesc;
int ret;

sdesc = init_sdesc(alg);
Expand Down
16 changes: 16 additions & 0 deletions Documentation/devicetree/bindings/crypto/st,stm32-crc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
* STMicroelectronics STM32 CRC

Required properties:
- compatible: Should be "st,stm32f7-crc".
- reg: The address and length of the peripheral registers space
- clocks: The input clock of the CRC instance

Optional properties: none

Example:

crc: crc@40023000 {
compatible = "st,stm32f7-crc";
reg = <0x40023000 0x400>;
clocks = <&rcc 0 12>;
};
11 changes: 9 additions & 2 deletions Documentation/devicetree/bindings/rng/amlogic,meson-rng.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ Required properties:
- compatible : should be "amlogic,meson-rng"
- reg : Specifies base physical address and size of the registers.

Optional properties:

- clocks : phandle to the following named clocks
- clock-names: Name of core clock, must be "core"

Example:

rng {
compatible = "amlogic,meson-rng";
reg = <0x0 0xc8834000 0x0 0x4>;
compatible = "amlogic,meson-rng";
reg = <0x0 0xc8834000 0x0 0x4>;
clocks = <&clkc CLKID_RNG0>;
clock-names = "core";
};
18 changes: 18 additions & 0 deletions Documentation/devicetree/bindings/rng/mtk-rng.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Device-Tree bindings for Mediatek random number generator
found in Mediatek SoC family

Required properties:
- compatible : Should be "mediatek,mt7623-rng"
- clocks : list of clock specifiers, corresponding to
entries in clock-names property;
- clock-names : Should contain "rng" entries;
- reg : Specifies base physical address and size of the registers

Example:

rng: rng@1020f000 {
compatible = "mediatek,mt7623-rng";
reg = <0 0x1020f000 0 0x1000>;
clocks = <&infracfg CLK_INFRA_TRNG>;
clock-names = "rng";
};
18 changes: 17 additions & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -6242,7 +6242,7 @@ F: drivers/crypto/nx/nx_csbcpb.h
F: drivers/crypto/nx/nx_debugfs.h

IBM Power 842 compression accelerator
M: Dan Streetman <[email protected]>
M: Haren Myneni <[email protected]>
S: Supported
F: drivers/crypto/nx/Makefile
F: drivers/crypto/nx/Kconfig
Expand Down Expand Up @@ -10954,6 +10954,14 @@ L: [email protected] (moderated for non-subscribers)
S: Supported
F: sound/soc/samsung/

SAMSUNG EXYNOS PSEUDO RANDOM NUMBER GENERATOR (RNG) DRIVER
M: Krzysztof Kozlowski <[email protected]>
L: [email protected]
L: [email protected]
S: Maintained
F: drivers/crypto/exynos-rng.c
F: Documentation/devicetree/bindings/rng/samsung,exynos-rng4.txt

SAMSUNG FRAMEBUFFER DRIVER
M: Jingoo Han <[email protected]>
L: [email protected]
Expand All @@ -10978,6 +10986,14 @@ F: Documentation/devicetree/bindings/regulator/samsung,s2m*.txt
F: Documentation/devicetree/bindings/regulator/samsung,s5m*.txt
F: Documentation/devicetree/bindings/clock/samsung,s2mps11.txt

SAMSUNG S5P Security SubSystem (SSS) DRIVER
M: Krzysztof Kozlowski <[email protected]>
M: Vladimir Zapolskiy <[email protected]>
L: [email protected]
L: [email protected]
S: Maintained
F: drivers/crypto/s5p-sss.c

SAMSUNG S5P/EXYNOS4 SOC SERIES CAMERA SUBSYSTEM DRIVERS
M: Kyungmin Park <[email protected]>
M: Sylwester Nawrocki <[email protected]>
Expand Down
4 changes: 4 additions & 0 deletions arch/arm/boot/dts/stm32746g-eval.dts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
clock-frequency = <25000000>;
};

&crc {
status = "okay";
};

&usart1 {
pinctrl-0 = <&usart1_pins_a>;
pinctrl-names = "default";
Expand Down
7 changes: 7 additions & 0 deletions arch/arm/boot/dts/stm32f746.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,13 @@
};
};

crc: crc@40023000 {
compatible = "st,stm32f7-crc";
reg = <0x40023000 0x400>;
clocks = <&rcc 0 12>;
status = "disabled";
};

rcc: rcc@40023800 {
#clock-cells = <2>;
compatible = "st,stm32f42xx-rcc", "st,stm32-rcc";
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/configs/stm32_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,7 @@ CONFIG_MAGIC_SYSRQ=y
# CONFIG_SCHED_DEBUG is not set
# CONFIG_DEBUG_BUGVERBOSE is not set
# CONFIG_FTRACE is not set
CONFIG_CRYPTO=y
CONFIG_CRYPTO_DEV_STM32=y
CONFIG_CRC_ITU_T=y
CONFIG_CRC7=y
2 changes: 1 addition & 1 deletion arch/arm/crypto/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ config CRYPTO_AES_ARM_BS
depends on KERNEL_MODE_NEON
select CRYPTO_BLKCIPHER
select CRYPTO_SIMD
select CRYPTO_AES_ARM
select CRYPTO_AES
help
Use a faster and more secure NEON based implementation of AES in CBC,
CTR and XTS modes
Expand Down
60 changes: 45 additions & 15 deletions arch/arm/crypto/aes-neonbs-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,19 @@ asmlinkage void aesbs_xts_encrypt(u8 out[], u8 const in[], u8 const rk[],
asmlinkage void aesbs_xts_decrypt(u8 out[], u8 const in[], u8 const rk[],
int rounds, int blocks, u8 iv[]);

asmlinkage void __aes_arm_encrypt(const u32 rk[], int rounds, const u8 in[],
u8 out[]);

struct aesbs_ctx {
int rounds;
u8 rk[13 * (8 * AES_BLOCK_SIZE) + 32] __aligned(AES_BLOCK_SIZE);
};

struct aesbs_cbc_ctx {
struct aesbs_ctx key;
u32 enc[AES_MAX_KEYLENGTH_U32];
struct crypto_cipher *enc_tfm;
};

struct aesbs_xts_ctx {
struct aesbs_ctx key;
u32 twkey[AES_MAX_KEYLENGTH_U32];
struct crypto_cipher *tweak_tfm;
};

static int aesbs_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
Expand Down Expand Up @@ -132,20 +129,18 @@ static int aesbs_cbc_setkey(struct crypto_skcipher *tfm, const u8 *in_key,

ctx->key.rounds = 6 + key_len / 4;

memcpy(ctx->enc, rk.key_enc, sizeof(ctx->enc));

kernel_neon_begin();
aesbs_convert_key(ctx->key.rk, rk.key_enc, ctx->key.rounds);
kernel_neon_end();

return 0;
return crypto_cipher_setkey(ctx->enc_tfm, in_key, key_len);
}

static void cbc_encrypt_one(struct crypto_skcipher *tfm, const u8 *src, u8 *dst)
{
struct aesbs_cbc_ctx *ctx = crypto_skcipher_ctx(tfm);

__aes_arm_encrypt(ctx->enc, ctx->key.rounds, src, dst);
crypto_cipher_encrypt_one(ctx->enc_tfm, dst, src);
}

static int cbc_encrypt(struct skcipher_request *req)
Expand Down Expand Up @@ -181,6 +176,23 @@ static int cbc_decrypt(struct skcipher_request *req)
return err;
}

static int cbc_init(struct crypto_tfm *tfm)
{
struct aesbs_cbc_ctx *ctx = crypto_tfm_ctx(tfm);

ctx->enc_tfm = crypto_alloc_cipher("aes", 0, 0);
if (IS_ERR(ctx->enc_tfm))
return PTR_ERR(ctx->enc_tfm);
return 0;
}

static void cbc_exit(struct crypto_tfm *tfm)
{
struct aesbs_cbc_ctx *ctx = crypto_tfm_ctx(tfm);

crypto_free_cipher(ctx->enc_tfm);
}

static int ctr_encrypt(struct skcipher_request *req)
{
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
Expand Down Expand Up @@ -228,23 +240,37 @@ static int aesbs_xts_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
unsigned int key_len)
{
struct aesbs_xts_ctx *ctx = crypto_skcipher_ctx(tfm);
struct crypto_aes_ctx rk;
int err;

err = xts_verify_key(tfm, in_key, key_len);
if (err)
return err;

key_len /= 2;
err = crypto_aes_expand_key(&rk, in_key + key_len, key_len);
err = crypto_cipher_setkey(ctx->tweak_tfm, in_key + key_len, key_len);
if (err)
return err;

memcpy(ctx->twkey, rk.key_enc, sizeof(ctx->twkey));

return aesbs_setkey(tfm, in_key, key_len);
}

static int xts_init(struct crypto_tfm *tfm)
{
struct aesbs_xts_ctx *ctx = crypto_tfm_ctx(tfm);

ctx->tweak_tfm = crypto_alloc_cipher("aes", 0, 0);
if (IS_ERR(ctx->tweak_tfm))
return PTR_ERR(ctx->tweak_tfm);
return 0;
}

static void xts_exit(struct crypto_tfm *tfm)
{
struct aesbs_xts_ctx *ctx = crypto_tfm_ctx(tfm);

crypto_free_cipher(ctx->tweak_tfm);
}

static int __xts_crypt(struct skcipher_request *req,
void (*fn)(u8 out[], u8 const in[], u8 const rk[],
int rounds, int blocks, u8 iv[]))
Expand All @@ -256,7 +282,7 @@ static int __xts_crypt(struct skcipher_request *req,

err = skcipher_walk_virt(&walk, req, true);

__aes_arm_encrypt(ctx->twkey, ctx->key.rounds, walk.iv, walk.iv);
crypto_cipher_encrypt_one(ctx->tweak_tfm, walk.iv, walk.iv);

kernel_neon_begin();
while (walk.nbytes >= AES_BLOCK_SIZE) {
Expand Down Expand Up @@ -309,6 +335,8 @@ static struct skcipher_alg aes_algs[] = { {
.base.cra_ctxsize = sizeof(struct aesbs_cbc_ctx),
.base.cra_module = THIS_MODULE,
.base.cra_flags = CRYPTO_ALG_INTERNAL,
.base.cra_init = cbc_init,
.base.cra_exit = cbc_exit,

.min_keysize = AES_MIN_KEY_SIZE,
.max_keysize = AES_MAX_KEY_SIZE,
Expand Down Expand Up @@ -342,6 +370,8 @@ static struct skcipher_alg aes_algs[] = { {
.base.cra_ctxsize = sizeof(struct aesbs_xts_ctx),
.base.cra_module = THIS_MODULE,
.base.cra_flags = CRYPTO_ALG_INTERNAL,
.base.cra_init = xts_init,
.base.cra_exit = xts_exit,

.min_keysize = 2 * AES_MIN_KEY_SIZE,
.max_keysize = 2 * AES_MAX_KEY_SIZE,
Expand Down Expand Up @@ -402,5 +432,5 @@ static int __init aes_init(void)
return err;
}

module_init(aes_init);
late_initcall(aes_init);
module_exit(aes_exit);
2 changes: 1 addition & 1 deletion arch/arm64/boot/dts/amlogic/meson-gx.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
#size-cells = <2>;
ranges = <0x0 0x0 0x0 0xc8834000 0x0 0x2000>;

rng {
hwrng: rng {
compatible = "amlogic,meson-rng";
reg = <0x0 0x0 0x0 0x4>;
};
Expand Down
5 changes: 5 additions & 0 deletions arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -524,3 +524,8 @@
&vpu {
compatible = "amlogic,meson-gxbb-vpu", "amlogic,meson-gx-vpu";
};

&hwrng {
clocks = <&clkc CLKID_RNG0>;
clock-names = "core";
};
2 changes: 0 additions & 2 deletions arch/metag/kernel/stacktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ static void tbi_boing_init(void)
}
#endif

#define ALIGN_DOWN(addr, size) ((addr)&(~((size)-1)))

/*
* Unwind the current stack frame and store the new register values in the
* structure passed as argument. Unwinding is equivalent to a function return,
Expand Down
3 changes: 3 additions & 0 deletions arch/powerpc/crypto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ obj-$(CONFIG_CRYPTO_SHA1_PPC) += sha1-powerpc.o
obj-$(CONFIG_CRYPTO_SHA1_PPC_SPE) += sha1-ppc-spe.o
obj-$(CONFIG_CRYPTO_SHA256_PPC_SPE) += sha256-ppc-spe.o
obj-$(CONFIG_CRYPTO_CRC32C_VPMSUM) += crc32c-vpmsum.o
obj-$(CONFIG_CRYPTO_CRCT10DIF_VPMSUM) += crct10dif-vpmsum.o
obj-$(CONFIG_CRYPTO_VPMSUM_TESTER) += crc-vpmsum_test.o

aes-ppc-spe-y := aes-spe-core.o aes-spe-keys.o aes-tab-4k.o aes-spe-modes.o aes-spe-glue.o
md5-ppc-y := md5-asm.o md5-glue.o
sha1-powerpc-y := sha1-powerpc-asm.o sha1.o
sha1-ppc-spe-y := sha1-spe-asm.o sha1-spe-glue.o
sha256-ppc-spe-y := sha256-spe-asm.o sha256-spe-glue.o
crc32c-vpmsum-y := crc32c-vpmsum_asm.o crc32c-vpmsum_glue.o
crct10dif-vpmsum-y := crct10dif-vpmsum_asm.o crct10dif-vpmsum_glue.o
Loading

0 comments on commit 5a0387a

Please sign in to comment.