Skip to content

Commit 80cee03

Browse files
committed
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto updates from Herbert Xu: "Here is the crypto update for 4.14: API: - Defer scompress scratch buffer allocation to first use. - Add __crypto_xor that takes separte src and dst operands. - Add ahash multiple registration interface. - Revamped aead/skcipher algif code to fix async IO properly. Drivers: - Add non-SIMD fallback code path on ARM for SVE. - Add AMD Security Processor framework for ccp. - Add support for RSA in ccp. - Add XTS-AES-256 support for CCP version 5. - Add support for PRNG in sun4i-ss. - Add support for DPAA2 in caam. - Add ARTPEC crypto support. - Add Freescale RNGC hwrng support. - Add Microchip / Atmel ECC driver. - Add support for STM32 HASH module" * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (116 commits) crypto: af_alg - get_page upon reassignment to TX SGL crypto: cavium/nitrox - Fix an error handling path in 'nitrox_probe()' crypto: inside-secure - fix an error handling path in safexcel_probe() crypto: rockchip - Don't dequeue the request when device is busy crypto: cavium - add release_firmware to all return case crypto: sahara - constify platform_device_id MAINTAINERS: Add ARTPEC crypto maintainer crypto: axis - add ARTPEC-6/7 crypto accelerator driver crypto: hash - add crypto_(un)register_ahashes() dt-bindings: crypto: add ARTPEC crypto crypto: algif_aead - fix comment regarding memory layout crypto: ccp - use dma_mapping_error to check map error lib/mpi: fix build with clang crypto: sahara - Remove leftover from previous used spinlock crypto: sahara - Fix dma unmap direction crypto: af_alg - consolidation of duplicate code crypto: caam - Remove unused dentry members crypto: ccp - select CONFIG_CRYPTO_RSA crypto: ccp - avoid uninitialized variable warning crypto: serpent - improve __serpent_setkey with UBSAN ...
2 parents aae3dbb + 2d45a7e commit 80cee03

File tree

136 files changed

+11758
-3169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+11758
-3169
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Axis crypto engine with PDMA interface.
2+
3+
Required properties:
4+
- compatible : Should be one of the following strings:
5+
"axis,artpec6-crypto" for the version in the Axis ARTPEC-6 SoC
6+
"axis,artpec7-crypto" for the version in the Axis ARTPEC-7 SoC.
7+
- reg: Base address and size for the PDMA register area.
8+
- interrupts: Interrupt handle for the PDMA interrupt line.
9+
10+
Example:
11+
12+
crypto@f4264000 {
13+
compatible = "axis,artpec6-crypto";
14+
reg = <0xf4264000 0x1000>;
15+
interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
16+
};

Documentation/devicetree/bindings/crypto/atmel-crypto.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,16 @@ sha@f8034000 {
6666
dmas = <&dma1 2 17>;
6767
dma-names = "tx";
6868
};
69+
70+
* Eliptic Curve Cryptography (I2C)
71+
72+
Required properties:
73+
- compatible : must be "atmel,atecc508a".
74+
- reg: I2C bus address of the device.
75+
- clock-frequency: must be present in the i2c controller node.
76+
77+
Example:
78+
atecc508a@C0 {
79+
compatible = "atmel,atecc508a";
80+
reg = <0xC0>;
81+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
* STMicroelectronics STM32 HASH
2+
3+
Required properties:
4+
- compatible: Should contain entries for this and backward compatible
5+
HASH versions:
6+
- "st,stm32f456-hash" for stm32 F456.
7+
- "st,stm32f756-hash" for stm32 F756.
8+
- reg: The address and length of the peripheral registers space
9+
- interrupts: the interrupt specifier for the HASH
10+
- clocks: The input clock of the HASH instance
11+
12+
Optional properties:
13+
- resets: The input reset of the HASH instance
14+
- dmas: DMA specifiers for the HASH. See the DMA client binding,
15+
Documentation/devicetree/bindings/dma/dma.txt
16+
- dma-names: DMA request name. Should be "in" if a dma is present.
17+
- dma-maxburst: Set number of maximum dma burst supported
18+
19+
Example:
20+
21+
hash1: hash@50060400 {
22+
compatible = "st,stm32f756-hash";
23+
reg = <0x50060400 0x400>;
24+
interrupts = <80>;
25+
clocks = <&rcc 0 STM32F7_AHB2_CLOCK(HASH)>;
26+
resets = <&rcc STM32F7_AHB2_RESET(HASH)>;
27+
dmas = <&dma2 7 2 0x400 0x0>;
28+
dma-names = "in";
29+
dma-maxburst = <0>;
30+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Freescale RNGC (Random Number Generator Version C)
2+
3+
The driver also supports version B, which is mostly compatible
4+
to version C.
5+
6+
Required properties:
7+
- compatible : should be one of
8+
"fsl,imx25-rngb"
9+
"fsl,imx35-rngc"
10+
- reg : offset and length of the register set of this block
11+
- interrupts : the interrupt number for the RNGC block
12+
- clocks : the RNGC clk source
13+
14+
Example:
15+
16+
rng@53fb0000 {
17+
compatible = "fsl,imx25-rngb";
18+
reg = <0x53fb0000 0x4000>;
19+
interrupts = <22>;
20+
clocks = <&trng_clk>;
21+
};

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,7 @@ L: [email protected]
11621162
F: arch/arm/mach-artpec
11631163
F: arch/arm/boot/dts/artpec6*
11641164
F: drivers/clk/axis
1165+
F: drivers/crypto/axis
11651166
F: drivers/pinctrl/pinctrl-artpec*
11661167
F: Documentation/devicetree/bindings/pinctrl/axis,artpec6-pinctrl.txt
11671168

@@ -8770,6 +8771,12 @@ F: drivers/dma/at_hdmac.c
87708771
F: drivers/dma/at_hdmac_regs.h
87718772
F: include/linux/platform_data/dma-atmel.h
87728773

8774+
MICROCHIP / ATMEL ECC DRIVER
8775+
M: Tudor Ambarus <[email protected]>
8776+
8777+
S: Maintained
8778+
F: drivers/crypto/atmel-ecc.*
8779+
87738780
MICROCHIP / ATMEL ISC DRIVER
87748781
M: Songjun Wu <[email protected]>
87758782

arch/arm/crypto/Kconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,15 @@ config CRYPTO_AES_ARM_CE
9494
ARMv8 Crypto Extensions
9595

9696
config CRYPTO_GHASH_ARM_CE
97-
tristate "PMULL-accelerated GHASH using ARMv8 Crypto Extensions"
97+
tristate "PMULL-accelerated GHASH using NEON/ARMv8 Crypto Extensions"
9898
depends on KERNEL_MODE_NEON
9999
select CRYPTO_HASH
100100
select CRYPTO_CRYPTD
101101
help
102102
Use an implementation of GHASH (used by the GCM AEAD chaining mode)
103103
that uses the 64x64 to 128 bit polynomial multiplication (vmull.p64)
104-
that is part of the ARMv8 Crypto Extensions
104+
that is part of the ARMv8 Crypto Extensions, or a slower variant that
105+
uses the vmull.p8 instruction that is part of the basic NEON ISA.
105106

106107
config CRYPTO_CRCT10DIF_ARM_CE
107108
tristate "CRCT10DIF digest algorithm using PMULL instructions"

arch/arm/crypto/aes-ce-glue.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,7 @@ static int ctr_encrypt(struct skcipher_request *req)
285285

286286
ce_aes_ctr_encrypt(tail, NULL, (u8 *)ctx->key_enc,
287287
num_rounds(ctx), blocks, walk.iv);
288-
if (tdst != tsrc)
289-
memcpy(tdst, tsrc, nbytes);
290-
crypto_xor(tdst, tail, nbytes);
288+
crypto_xor_cpy(tdst, tsrc, tail, nbytes);
291289
err = skcipher_walk_done(&walk, 0);
292290
}
293291
kernel_neon_end();

arch/arm/crypto/aes-cipher-core.S

Lines changed: 65 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
#include <linux/linkage.h>
13+
#include <asm/cache.h>
1314

1415
.text
1516
.align 5
@@ -32,19 +33,19 @@
3233
.endif
3334
.endm
3435

35-
.macro __load, out, in, idx
36+
.macro __load, out, in, idx, sz, op
3637
.if __LINUX_ARM_ARCH__ < 7 && \idx > 0
37-
ldr \out, [ttab, \in, lsr #(8 * \idx) - 2]
38+
ldr\op \out, [ttab, \in, lsr #(8 * \idx) - \sz]
3839
.else
39-
ldr \out, [ttab, \in, lsl #2]
40+
ldr\op \out, [ttab, \in, lsl #\sz]
4041
.endif
4142
.endm
4243

43-
.macro __hround, out0, out1, in0, in1, in2, in3, t3, t4, enc
44+
.macro __hround, out0, out1, in0, in1, in2, in3, t3, t4, enc, sz, op
4445
__select \out0, \in0, 0
4546
__select t0, \in1, 1
46-
__load \out0, \out0, 0
47-
__load t0, t0, 1
47+
__load \out0, \out0, 0, \sz, \op
48+
__load t0, t0, 1, \sz, \op
4849

4950
.if \enc
5051
__select \out1, \in1, 0
@@ -53,10 +54,10 @@
5354
__select \out1, \in3, 0
5455
__select t1, \in0, 1
5556
.endif
56-
__load \out1, \out1, 0
57+
__load \out1, \out1, 0, \sz, \op
5758
__select t2, \in2, 2
58-
__load t1, t1, 1
59-
__load t2, t2, 2
59+
__load t1, t1, 1, \sz, \op
60+
__load t2, t2, 2, \sz, \op
6061

6162
eor \out0, \out0, t0, ror #24
6263

@@ -68,9 +69,9 @@
6869
__select \t3, \in1, 2
6970
__select \t4, \in2, 3
7071
.endif
71-
__load \t3, \t3, 2
72-
__load t0, t0, 3
73-
__load \t4, \t4, 3
72+
__load \t3, \t3, 2, \sz, \op
73+
__load t0, t0, 3, \sz, \op
74+
__load \t4, \t4, 3, \sz, \op
7475

7576
eor \out1, \out1, t1, ror #24
7677
eor \out0, \out0, t2, ror #16
@@ -82,14 +83,14 @@
8283
eor \out1, \out1, t2
8384
.endm
8485

85-
.macro fround, out0, out1, out2, out3, in0, in1, in2, in3
86-
__hround \out0, \out1, \in0, \in1, \in2, \in3, \out2, \out3, 1
87-
__hround \out2, \out3, \in2, \in3, \in0, \in1, \in1, \in2, 1
86+
.macro fround, out0, out1, out2, out3, in0, in1, in2, in3, sz=2, op
87+
__hround \out0, \out1, \in0, \in1, \in2, \in3, \out2, \out3, 1, \sz, \op
88+
__hround \out2, \out3, \in2, \in3, \in0, \in1, \in1, \in2, 1, \sz, \op
8889
.endm
8990

90-
.macro iround, out0, out1, out2, out3, in0, in1, in2, in3
91-
__hround \out0, \out1, \in0, \in3, \in2, \in1, \out2, \out3, 0
92-
__hround \out2, \out3, \in2, \in1, \in0, \in3, \in1, \in0, 0
91+
.macro iround, out0, out1, out2, out3, in0, in1, in2, in3, sz=2, op
92+
__hround \out0, \out1, \in0, \in3, \in2, \in1, \out2, \out3, 0, \sz, \op
93+
__hround \out2, \out3, \in2, \in1, \in0, \in3, \in1, \in0, 0, \sz, \op
9394
.endm
9495

9596
.macro __rev, out, in
@@ -114,7 +115,7 @@
114115
.endif
115116
.endm
116117

117-
.macro do_crypt, round, ttab, ltab
118+
.macro do_crypt, round, ttab, ltab, bsz
118119
push {r3-r11, lr}
119120

120121
ldr r4, [in]
@@ -146,9 +147,12 @@
146147

147148
1: subs rounds, rounds, #4
148149
\round r8, r9, r10, r11, r4, r5, r6, r7
149-
__adrl ttab, \ltab, ls
150+
bls 2f
150151
\round r4, r5, r6, r7, r8, r9, r10, r11
151-
bhi 0b
152+
b 0b
153+
154+
2: __adrl ttab, \ltab
155+
\round r4, r5, r6, r7, r8, r9, r10, r11, \bsz, b
152156

153157
#ifdef CONFIG_CPU_BIG_ENDIAN
154158
__rev r4, r4
@@ -170,10 +174,48 @@
170174
.ltorg
171175
.endm
172176

177+
.align L1_CACHE_SHIFT
178+
.type __aes_arm_inverse_sbox, %object
179+
__aes_arm_inverse_sbox:
180+
.byte 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38
181+
.byte 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb
182+
.byte 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87
183+
.byte 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb
184+
.byte 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d
185+
.byte 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e
186+
.byte 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2
187+
.byte 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25
188+
.byte 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16
189+
.byte 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92
190+
.byte 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda
191+
.byte 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84
192+
.byte 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a
193+
.byte 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06
194+
.byte 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02
195+
.byte 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b
196+
.byte 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea
197+
.byte 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73
198+
.byte 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85
199+
.byte 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e
200+
.byte 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89
201+
.byte 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b
202+
.byte 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20
203+
.byte 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4
204+
.byte 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31
205+
.byte 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f
206+
.byte 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d
207+
.byte 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef
208+
.byte 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0
209+
.byte 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61
210+
.byte 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26
211+
.byte 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
212+
.size __aes_arm_inverse_sbox, . - __aes_arm_inverse_sbox
213+
173214
ENTRY(__aes_arm_encrypt)
174-
do_crypt fround, crypto_ft_tab, crypto_fl_tab
215+
do_crypt fround, crypto_ft_tab, crypto_ft_tab + 1, 2
175216
ENDPROC(__aes_arm_encrypt)
176217

218+
.align 5
177219
ENTRY(__aes_arm_decrypt)
178-
do_crypt iround, crypto_it_tab, crypto_il_tab
220+
do_crypt iround, crypto_it_tab, __aes_arm_inverse_sbox, 0
179221
ENDPROC(__aes_arm_decrypt)

arch/arm/crypto/aes-neonbs-glue.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,8 @@ static int ctr_encrypt(struct skcipher_request *req)
221221
u8 *dst = walk.dst.virt.addr + blocks * AES_BLOCK_SIZE;
222222
u8 *src = walk.src.virt.addr + blocks * AES_BLOCK_SIZE;
223223

224-
if (dst != src)
225-
memcpy(dst, src, walk.total % AES_BLOCK_SIZE);
226-
crypto_xor(dst, final, walk.total % AES_BLOCK_SIZE);
224+
crypto_xor_cpy(dst, src, final,
225+
walk.total % AES_BLOCK_SIZE);
227226

228227
err = skcipher_walk_done(&walk, 0);
229228
break;

0 commit comments

Comments
 (0)