Skip to content

Commit 5a0387a

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.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 ...
2 parents 204f144 + 929562b commit 5a0387a

137 files changed

Lines changed: 13710 additions & 2480 deletions

File tree

Some content is hidden

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

‎Documentation/crypto/api-samples.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ Code Example For Use of Operational State Memory With SHASH
155155
char ctx[];
156156
};
157157

158-
static struct sdescinit_sdesc(struct crypto_shash *alg)
158+
static struct sdesc init_sdesc(struct crypto_shash *alg)
159159
{
160-
struct sdescsdesc;
160+
struct sdesc sdesc;
161161
int size;
162162

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

178178
sdesc = init_sdesc(alg);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
* STMicroelectronics STM32 CRC
2+
3+
Required properties:
4+
- compatible: Should be "st,stm32f7-crc".
5+
- reg: The address and length of the peripheral registers space
6+
- clocks: The input clock of the CRC instance
7+
8+
Optional properties: none
9+
10+
Example:
11+
12+
crc: crc@40023000 {
13+
compatible = "st,stm32f7-crc";
14+
reg = <0x40023000 0x400>;
15+
clocks = <&rcc 0 12>;
16+
};

‎Documentation/devicetree/bindings/rng/amlogic,meson-rng.txt‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ Required properties:
66
- compatible : should be "amlogic,meson-rng"
77
- reg : Specifies base physical address and size of the registers.
88

9+
Optional properties:
10+
11+
- clocks : phandle to the following named clocks
12+
- clock-names: Name of core clock, must be "core"
13+
914
Example:
1015

1116
rng {
12-
compatible = "amlogic,meson-rng";
13-
reg = <0x0 0xc8834000 0x0 0x4>;
17+
compatible = "amlogic,meson-rng";
18+
reg = <0x0 0xc8834000 0x0 0x4>;
19+
clocks = <&clkc CLKID_RNG0>;
20+
clock-names = "core";
1421
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Device-Tree bindings for Mediatek random number generator
2+
found in Mediatek SoC family
3+
4+
Required properties:
5+
- compatible : Should be "mediatek,mt7623-rng"
6+
- clocks : list of clock specifiers, corresponding to
7+
entries in clock-names property;
8+
- clock-names : Should contain "rng" entries;
9+
- reg : Specifies base physical address and size of the registers
10+
11+
Example:
12+
13+
rng: rng@1020f000 {
14+
compatible = "mediatek,mt7623-rng";
15+
reg = <0 0x1020f000 0 0x1000>;
16+
clocks = <&infracfg CLK_INFRA_TRNG>;
17+
clock-names = "rng";
18+
};

‎MAINTAINERS‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6242,7 +6242,7 @@ F: drivers/crypto/nx/nx_csbcpb.h
62426242
F: drivers/crypto/nx/nx_debugfs.h
62436243

62446244
IBM Power 842 compression accelerator
6245-
M: Dan Streetman <ddstreet@ieee.org>
6245+
M: Haren Myneni <haren@us.ibm.com>
62466246
S: Supported
62476247
F: drivers/crypto/nx/Makefile
62486248
F: drivers/crypto/nx/Kconfig
@@ -10954,6 +10954,14 @@ L: alsa-devel@alsa-project.org (moderated for non-subscribers)
1095410954
S: Supported
1095510955
F: sound/soc/samsung/
1095610956

10957+
SAMSUNG EXYNOS PSEUDO RANDOM NUMBER GENERATOR (RNG) DRIVER
10958+
M: Krzysztof Kozlowski <krzk@kernel.org>
10959+
L: linux-crypto@vger.kernel.org
10960+
L: linux-samsung-soc@vger.kernel.org
10961+
S: Maintained
10962+
F: drivers/crypto/exynos-rng.c
10963+
F: Documentation/devicetree/bindings/rng/samsung,exynos-rng4.txt
10964+
1095710965
SAMSUNG FRAMEBUFFER DRIVER
1095810966
M: Jingoo Han <jingoohan1@gmail.com>
1095910967
L: linux-fbdev@vger.kernel.org
@@ -10978,6 +10986,14 @@ F: Documentation/devicetree/bindings/regulator/samsung,s2m*.txt
1097810986
F: Documentation/devicetree/bindings/regulator/samsung,s5m*.txt
1097910987
F: Documentation/devicetree/bindings/clock/samsung,s2mps11.txt
1098010988

10989+
SAMSUNG S5P Security SubSystem (SSS) DRIVER
10990+
M: Krzysztof Kozlowski <krzk@kernel.org>
10991+
M: Vladimir Zapolskiy <vz@mleia.com>
10992+
L: linux-crypto@vger.kernel.org
10993+
L: linux-samsung-soc@vger.kernel.org
10994+
S: Maintained
10995+
F: drivers/crypto/s5p-sss.c
10996+
1098110997
SAMSUNG S5P/EXYNOS4 SOC SERIES CAMERA SUBSYSTEM DRIVERS
1098210998
M: Kyungmin Park <kyungmin.park@samsung.com>
1098310999
M: Sylwester Nawrocki <s.nawrocki@samsung.com>

‎arch/arm/boot/dts/stm32746g-eval.dts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@
8989
clock-frequency = <25000000>;
9090
};
9191

92+
&crc {
93+
status = "okay";
94+
};
95+
9296
&usart1 {
9397
pinctrl-0 = <&usart1_pins_a>;
9498
pinctrl-names = "default";

‎arch/arm/boot/dts/stm32f746.dtsi‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@
289289
};
290290
};
291291

292+
crc: crc@40023000 {
293+
compatible = "st,stm32f7-crc";
294+
reg = <0x40023000 0x400>;
295+
clocks = <&rcc 0 12>;
296+
status = "disabled";
297+
};
298+
292299
rcc: rcc@40023800 {
293300
#clock-cells = <2>;
294301
compatible = "st,stm32f42xx-rcc", "st,stm32-rcc";

‎arch/arm/configs/stm32_defconfig‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,7 @@ CONFIG_MAGIC_SYSRQ=y
7575
# CONFIG_SCHED_DEBUG is not set
7676
# CONFIG_DEBUG_BUGVERBOSE is not set
7777
# CONFIG_FTRACE is not set
78+
CONFIG_CRYPTO=y
79+
CONFIG_CRYPTO_DEV_STM32=y
7880
CONFIG_CRC_ITU_T=y
7981
CONFIG_CRC7=y

‎arch/arm/crypto/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ config CRYPTO_AES_ARM_BS
7373
depends on KERNEL_MODE_NEON
7474
select CRYPTO_BLKCIPHER
7575
select CRYPTO_SIMD
76-
select CRYPTO_AES_ARM
76+
select CRYPTO_AES
7777
help
7878
Use a faster and more secure NEON based implementation of AES in CBC,
7979
CTR and XTS modes

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

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,19 @@ asmlinkage void aesbs_xts_encrypt(u8 out[], u8 const in[], u8 const rk[],
4242
asmlinkage void aesbs_xts_decrypt(u8 out[], u8 const in[], u8 const rk[],
4343
int rounds, int blocks, u8 iv[]);
4444

45-
asmlinkage void __aes_arm_encrypt(const u32 rk[], int rounds, const u8 in[],
46-
u8 out[]);
47-
4845
struct aesbs_ctx {
4946
int rounds;
5047
u8 rk[13 * (8 * AES_BLOCK_SIZE) + 32] __aligned(AES_BLOCK_SIZE);
5148
};
5249

5350
struct aesbs_cbc_ctx {
5451
struct aesbs_ctx key;
55-
u32 enc[AES_MAX_KEYLENGTH_U32];
52+
struct crypto_cipher *enc_tfm;
5653
};
5754

5855
struct aesbs_xts_ctx {
5956
struct aesbs_ctx key;
60-
u32 twkey[AES_MAX_KEYLENGTH_U32];
57+
struct crypto_cipher *tweak_tfm;
6158
};
6259

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

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

135-
memcpy(ctx->enc, rk.key_enc, sizeof(ctx->enc));
136-
137132
kernel_neon_begin();
138133
aesbs_convert_key(ctx->key.rk, rk.key_enc, ctx->key.rounds);
139134
kernel_neon_end();
140135

141-
return 0;
136+
return crypto_cipher_setkey(ctx->enc_tfm, in_key, key_len);
142137
}
143138

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

148-
__aes_arm_encrypt(ctx->enc, ctx->key.rounds, src, dst);
143+
crypto_cipher_encrypt_one(ctx->enc_tfm, dst, src);
149144
}
150145

151146
static int cbc_encrypt(struct skcipher_request *req)
@@ -181,6 +176,23 @@ static int cbc_decrypt(struct skcipher_request *req)
181176
return err;
182177
}
183178

179+
static int cbc_init(struct crypto_tfm *tfm)
180+
{
181+
struct aesbs_cbc_ctx *ctx = crypto_tfm_ctx(tfm);
182+
183+
ctx->enc_tfm = crypto_alloc_cipher("aes", 0, 0);
184+
if (IS_ERR(ctx->enc_tfm))
185+
return PTR_ERR(ctx->enc_tfm);
186+
return 0;
187+
}
188+
189+
static void cbc_exit(struct crypto_tfm *tfm)
190+
{
191+
struct aesbs_cbc_ctx *ctx = crypto_tfm_ctx(tfm);
192+
193+
crypto_free_cipher(ctx->enc_tfm);
194+
}
195+
184196
static int ctr_encrypt(struct skcipher_request *req)
185197
{
186198
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
@@ -228,23 +240,37 @@ static int aesbs_xts_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
228240
unsigned int key_len)
229241
{
230242
struct aesbs_xts_ctx *ctx = crypto_skcipher_ctx(tfm);
231-
struct crypto_aes_ctx rk;
232243
int err;
233244

234245
err = xts_verify_key(tfm, in_key, key_len);
235246
if (err)
236247
return err;
237248

238249
key_len /= 2;
239-
err = crypto_aes_expand_key(&rk, in_key + key_len, key_len);
250+
err = crypto_cipher_setkey(ctx->tweak_tfm, in_key + key_len, key_len);
240251
if (err)
241252
return err;
242253

243-
memcpy(ctx->twkey, rk.key_enc, sizeof(ctx->twkey));
244-
245254
return aesbs_setkey(tfm, in_key, key_len);
246255
}
247256

257+
static int xts_init(struct crypto_tfm *tfm)
258+
{
259+
struct aesbs_xts_ctx *ctx = crypto_tfm_ctx(tfm);
260+
261+
ctx->tweak_tfm = crypto_alloc_cipher("aes", 0, 0);
262+
if (IS_ERR(ctx->tweak_tfm))
263+
return PTR_ERR(ctx->tweak_tfm);
264+
return 0;
265+
}
266+
267+
static void xts_exit(struct crypto_tfm *tfm)
268+
{
269+
struct aesbs_xts_ctx *ctx = crypto_tfm_ctx(tfm);
270+
271+
crypto_free_cipher(ctx->tweak_tfm);
272+
}
273+
248274
static int __xts_crypt(struct skcipher_request *req,
249275
void (*fn)(u8 out[], u8 const in[], u8 const rk[],
250276
int rounds, int blocks, u8 iv[]))
@@ -256,7 +282,7 @@ static int __xts_crypt(struct skcipher_request *req,
256282

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

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

261287
kernel_neon_begin();
262288
while (walk.nbytes >= AES_BLOCK_SIZE) {
@@ -309,6 +335,8 @@ static struct skcipher_alg aes_algs[] = { {
309335
.base.cra_ctxsize = sizeof(struct aesbs_cbc_ctx),
310336
.base.cra_module = THIS_MODULE,
311337
.base.cra_flags = CRYPTO_ALG_INTERNAL,
338+
.base.cra_init = cbc_init,
339+
.base.cra_exit = cbc_exit,
312340

313341
.min_keysize = AES_MIN_KEY_SIZE,
314342
.max_keysize = AES_MAX_KEY_SIZE,
@@ -342,6 +370,8 @@ static struct skcipher_alg aes_algs[] = { {
342370
.base.cra_ctxsize = sizeof(struct aesbs_xts_ctx),
343371
.base.cra_module = THIS_MODULE,
344372
.base.cra_flags = CRYPTO_ALG_INTERNAL,
373+
.base.cra_init = xts_init,
374+
.base.cra_exit = xts_exit,
345375

346376
.min_keysize = 2 * AES_MIN_KEY_SIZE,
347377
.max_keysize = 2 * AES_MAX_KEY_SIZE,
@@ -402,5 +432,5 @@ static int __init aes_init(void)
402432
return err;
403433
}
404434

405-
module_init(aes_init);
435+
late_initcall(aes_init);
406436
module_exit(aes_exit);

0 commit comments

Comments
 (0)