Skip to content

Commit 37dc795

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.15: API: - Disambiguate EBUSY when queueing crypto request by adding ENOSPC. This change touches code outside the crypto API. - Reset settings when empty string is written to rng_current. Algorithms: - Add OSCCA SM3 secure hash. Drivers: - Remove old mv_cesa driver (replaced by marvell/cesa). - Enable rfc3686/ecb/cfb/ofb AES in crypto4xx. - Add ccm/gcm AES in crypto4xx. - Add support for BCM7278 in iproc-rng200. - Add hash support on Exynos in s5p-sss. - Fix fallback-induced error in vmx. - Fix output IV in atmel-aes. - Fix empty GCM hash in mediatek. Others: - Fix DoS potential in lib/mpi. - Fix potential out-of-order issues with padata" * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (162 commits) lib/mpi: call cond_resched() from mpi_powm() loop crypto: stm32/hash - Fix return issue on update crypto: dh - Remove pointless checks for NULL 'p' and 'g' crypto: qat - Clean up error handling in qat_dh_set_secret() crypto: dh - Don't permit 'key' or 'g' size longer than 'p' crypto: dh - Don't permit 'p' to be 0 crypto: dh - Fix double free of ctx->p hwrng: iproc-rng200 - Add support for BCM7278 dt-bindings: rng: Document BCM7278 RNG200 compatible crypto: chcr - Replace _manual_ swap with swap macro crypto: marvell - Add a NULL entry at the end of mv_cesa_plat_id_table[] hwrng: virtio - Virtio RNG devices need to be re-registered after suspend/resume crypto: atmel - remove empty functions crypto: ecdh - remove empty exit() MAINTAINERS: update maintainer for qat crypto: caam - remove unused param of ctx_map_to_sec4_sg() crypto: caam - remove unneeded edesc zeroization crypto: atmel-aes - Reset the controller before each use crypto: atmel-aes - properly set IV after {en,de}crypt hwrng: core - Reset user selected rng by writing "" to rng_current ...
2 parents 894025f + 1d9ddde commit 37dc795

File tree

135 files changed

+5701
-4648
lines changed

Some content is hidden

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

135 files changed

+5701
-4648
lines changed

Documentation/crypto/api-samples.rst

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,59 +7,27 @@ Code Example For Symmetric Key Cipher Operation
77
::
88

99

10-
struct tcrypt_result {
11-
struct completion completion;
12-
int err;
13-
};
14-
1510
/* tie all data structures together */
1611
struct skcipher_def {
1712
struct scatterlist sg;
1813
struct crypto_skcipher *tfm;
1914
struct skcipher_request *req;
20-
struct tcrypt_result result;
15+
struct crypto_wait wait;
2116
};
2217

23-
/* Callback function */
24-
static void test_skcipher_cb(struct crypto_async_request *req, int error)
25-
{
26-
struct tcrypt_result *result = req->data;
27-
28-
if (error == -EINPROGRESS)
29-
return;
30-
result->err = error;
31-
complete(&result->completion);
32-
pr_info("Encryption finished successfully\n");
33-
}
34-
3518
/* Perform cipher operation */
3619
static unsigned int test_skcipher_encdec(struct skcipher_def *sk,
3720
int enc)
3821
{
39-
int rc = 0;
22+
int rc;
4023

4124
if (enc)
42-
rc = crypto_skcipher_encrypt(sk->req);
25+
rc = crypto_wait_req(crypto_skcipher_encrypt(sk->req), &sk->wait);
4326
else
44-
rc = crypto_skcipher_decrypt(sk->req);
45-
46-
switch (rc) {
47-
case 0:
48-
break;
49-
case -EINPROGRESS:
50-
case -EBUSY:
51-
rc = wait_for_completion_interruptible(
52-
&sk->result.completion);
53-
if (!rc && !sk->result.err) {
54-
reinit_completion(&sk->result.completion);
55-
break;
56-
}
57-
default:
58-
pr_info("skcipher encrypt returned with %d result %d\n",
59-
rc, sk->result.err);
60-
break;
61-
}
62-
init_completion(&sk->result.completion);
27+
rc = crypto_wait_req(crypto_skcipher_decrypt(sk->req), &sk->wait);
28+
29+
if (rc)
30+
pr_info("skcipher encrypt returned with result %d\n", rc);
6331

6432
return rc;
6533
}
@@ -89,8 +57,8 @@ Code Example For Symmetric Key Cipher Operation
8957
}
9058

9159
skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
92-
test_skcipher_cb,
93-
&sk.result);
60+
crypto_req_done,
61+
&sk.wait);
9462

9563
/* AES 256 with random key */
9664
get_random_bytes(&key, 32);
@@ -122,7 +90,7 @@ Code Example For Symmetric Key Cipher Operation
12290
/* We encrypt one block */
12391
sg_init_one(&sk.sg, scratchpad, 16);
12492
skcipher_request_set_crypt(req, &sk.sg, &sk.sg, 16, ivdata);
125-
init_completion(&sk.result.completion);
93+
crypto_init_wait(&sk.wait);
12694

12795
/* encrypt data */
12896
ret = test_skcipher_encdec(&sk, 1);

Documentation/devicetree/bindings/rng/brcm,iproc-rng200.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
HWRNG support for the iproc-rng200 driver
22

33
Required properties:
4-
- compatible : "brcm,iproc-rng200"
4+
- compatible : Must be one of:
5+
"brcm,bcm7278-rng200"
6+
"brcm,iproc-rng200"
57
- reg : base address and size of control register block
68

79
Example:

MAINTAINERS

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5484,7 +5484,7 @@ F: include/uapi/linux/fb.h
54845484

54855485
FREESCALE CAAM (Cryptographic Acceleration and Assurance Module) DRIVER
54865486
M: Horia Geantă <horia.geanta@nxp.com>
5487-
M: Dan Douglass <dan.douglass@nxp.com>
5487+
M: Aymen Sghaier <aymen.sghaier@nxp.com>
54885488
L: linux-crypto@vger.kernel.org
54895489
S: Maintained
54905490
F: drivers/crypto/caam/
@@ -11060,7 +11060,6 @@ F: drivers/mtd/nand/pxa3xx_nand.c
1106011060

1106111061
QAT DRIVER
1106211062
M: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
11063-
M: Salvatore Benedetto <salvatore.benedetto@intel.com>
1106411063
L: qat-linux@intel.com
1106511064
S: Supported
1106611065
F: drivers/crypto/qat/
@@ -11793,7 +11792,7 @@ L: linux-crypto@vger.kernel.org
1179311792
L: linux-samsung-soc@vger.kernel.org
1179411793
S: Maintained
1179511794
F: drivers/crypto/exynos-rng.c
11796-
F: Documentation/devicetree/bindings/rng/samsung,exynos-rng4.txt
11795+
F: Documentation/devicetree/bindings/crypto/samsung,exynos-rng4.txt
1179711796

1179811797
SAMSUNG FRAMEBUFFER DRIVER
1179911798
M: Jingoo Han <jingoohan1@gmail.com>

arch/arm/configs/dove_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,6 @@ CONFIG_CRYPTO_TWOFISH=y
140140
CONFIG_CRYPTO_DEFLATE=y
141141
CONFIG_CRYPTO_LZO=y
142142
# CONFIG_CRYPTO_ANSI_CPRNG is not set
143-
CONFIG_CRYPTO_DEV_MV_CESA=y
143+
CONFIG_CRYPTO_DEV_MARVELL_CESA=y
144144
CONFIG_CRC_CCITT=y
145145
CONFIG_LIBCRC32C=y

arch/arm/configs/multi_v5_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,6 @@ CONFIG_DEBUG_KERNEL=y
279279
CONFIG_DEBUG_USER=y
280280
CONFIG_CRYPTO_CBC=m
281281
CONFIG_CRYPTO_PCBC=m
282-
CONFIG_CRYPTO_DEV_MV_CESA=y
282+
CONFIG_CRYPTO_DEV_MARVELL_CESA=y
283283
CONFIG_CRC_CCITT=y
284284
CONFIG_LIBCRC32C=y

arch/arm/configs/orion5x_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,5 @@ CONFIG_CRYPTO_CBC=m
163163
CONFIG_CRYPTO_ECB=m
164164
CONFIG_CRYPTO_PCBC=m
165165
# CONFIG_CRYPTO_ANSI_CPRNG is not set
166-
CONFIG_CRYPTO_DEV_MV_CESA=y
166+
CONFIG_CRYPTO_DEV_MARVELL_CESA=y
167167
CONFIG_CRC_T10DIF=y

arch/x86/crypto/aesni-intel_glue.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <crypto/cryptd.h>
2929
#include <crypto/ctr.h>
3030
#include <crypto/b128ops.h>
31+
#include <crypto/gcm.h>
3132
#include <crypto/xts.h>
3233
#include <asm/cpu_device_id.h>
3334
#include <asm/fpu/api.h>
@@ -1067,9 +1068,10 @@ static struct skcipher_alg aesni_skciphers[] = {
10671068
}
10681069
};
10691070

1071+
static
10701072
struct simd_skcipher_alg *aesni_simd_skciphers[ARRAY_SIZE(aesni_skciphers)];
10711073

1072-
struct {
1074+
static struct {
10731075
const char *algname;
10741076
const char *drvname;
10751077
const char *basename;
@@ -1131,7 +1133,7 @@ static struct aead_alg aesni_aead_algs[] = { {
11311133
.setauthsize = common_rfc4106_set_authsize,
11321134
.encrypt = helper_rfc4106_encrypt,
11331135
.decrypt = helper_rfc4106_decrypt,
1134-
.ivsize = 8,
1136+
.ivsize = GCM_RFC4106_IV_SIZE,
11351137
.maxauthsize = 16,
11361138
.base = {
11371139
.cra_name = "__gcm-aes-aesni",
@@ -1149,7 +1151,7 @@ static struct aead_alg aesni_aead_algs[] = { {
11491151
.setauthsize = rfc4106_set_authsize,
11501152
.encrypt = rfc4106_encrypt,
11511153
.decrypt = rfc4106_decrypt,
1152-
.ivsize = 8,
1154+
.ivsize = GCM_RFC4106_IV_SIZE,
11531155
.maxauthsize = 16,
11541156
.base = {
11551157
.cra_name = "rfc4106(gcm(aes))",
@@ -1165,7 +1167,7 @@ static struct aead_alg aesni_aead_algs[] = { {
11651167
.setauthsize = generic_gcmaes_set_authsize,
11661168
.encrypt = generic_gcmaes_encrypt,
11671169
.decrypt = generic_gcmaes_decrypt,
1168-
.ivsize = 12,
1170+
.ivsize = GCM_AES_IV_SIZE,
11691171
.maxauthsize = 16,
11701172
.base = {
11711173
.cra_name = "gcm(aes)",

arch/x86/crypto/crc32-pclmul_asm.S

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <asm/inst.h>
4242

4343

44+
.section .rodata
4445
.align 16
4546
/*
4647
* [x4*128+32 mod P(x) << 32)]' << 1 = 0x154442bd4
@@ -111,19 +112,13 @@ ENTRY(crc32_pclmul_le_16) /* buffer and buffer size are 16 bytes aligned */
111112
pxor CONSTANT, %xmm1
112113
sub $0x40, LEN
113114
add $0x40, BUF
114-
#ifndef __x86_64__
115-
/* This is for position independent code(-fPIC) support for 32bit */
116-
call delta
117-
delta:
118-
pop %ecx
119-
#endif
120115
cmp $0x40, LEN
121116
jb less_64
122117

123118
#ifdef __x86_64__
124119
movdqa .Lconstant_R2R1(%rip), CONSTANT
125120
#else
126-
movdqa .Lconstant_R2R1 - delta(%ecx), CONSTANT
121+
movdqa .Lconstant_R2R1, CONSTANT
127122
#endif
128123

129124
loop_64:/* 64 bytes Full cache line folding */
@@ -172,7 +167,7 @@ less_64:/* Folding cache line into 128bit */
172167
#ifdef __x86_64__
173168
movdqa .Lconstant_R4R3(%rip), CONSTANT
174169
#else
175-
movdqa .Lconstant_R4R3 - delta(%ecx), CONSTANT
170+
movdqa .Lconstant_R4R3, CONSTANT
176171
#endif
177172
prefetchnta (BUF)
178173

@@ -220,8 +215,8 @@ fold_64:
220215
movdqa .Lconstant_R5(%rip), CONSTANT
221216
movdqa .Lconstant_mask32(%rip), %xmm3
222217
#else
223-
movdqa .Lconstant_R5 - delta(%ecx), CONSTANT
224-
movdqa .Lconstant_mask32 - delta(%ecx), %xmm3
218+
movdqa .Lconstant_R5, CONSTANT
219+
movdqa .Lconstant_mask32, %xmm3
225220
#endif
226221
psrldq $0x04, %xmm2
227222
pand %xmm3, %xmm1
@@ -232,7 +227,7 @@ fold_64:
232227
#ifdef __x86_64__
233228
movdqa .Lconstant_RUpoly(%rip), CONSTANT
234229
#else
235-
movdqa .Lconstant_RUpoly - delta(%ecx), CONSTANT
230+
movdqa .Lconstant_RUpoly, CONSTANT
236231
#endif
237232
movdqa %xmm1, %xmm2
238233
pand %xmm3, %xmm1

crypto/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,17 @@ config CRYPTO_SHA3
860860
References:
861861
http://keccak.noekeon.org/
862862

863+
config CRYPTO_SM3
864+
tristate "SM3 digest algorithm"
865+
select CRYPTO_HASH
866+
help
867+
SM3 secure hash function as defined by OSCCA GM/T 0004-2012 SM3).
868+
It is part of the Chinese Commercial Cryptography suite.
869+
870+
References:
871+
http://www.oscca.gov.cn/UpFile/20101222141857786.pdf
872+
https://datatracker.ietf.org/doc/html/draft-shen-sm3-hash
873+
863874
config CRYPTO_TGR192
864875
tristate "Tiger digest algorithms"
865876
select CRYPTO_HASH

0 commit comments

Comments
 (0)