Skip to content

Commit c597b6b

Browse files
committed
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto update from Herbert Xu: "Algorithms: - Add RSA padding algorithm Drivers: - Add GCM mode support to atmel - Add atmel support for SAMA5D2 devices - Add cipher modes to talitos - Add rockchip driver for rk3288 - Add qat support for C3XXX and C62X" * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (103 commits) crypto: hifn_795x, picoxcell - use ablkcipher_request_cast crypto: qat - fix SKU definiftion for c3xxx dev crypto: qat - Fix random config build issue crypto: ccp - use to_pci_dev and to_platform_device crypto: qat - Rename dh895xcc mmp firmware crypto: 842 - remove WARN inside printk crypto: atmel-aes - add debug facilities to monitor register accesses. crypto: atmel-aes - add support to GCM mode crypto: atmel-aes - change the DMA threshold crypto: atmel-aes - fix the counter overflow in CTR mode crypto: atmel-aes - fix atmel-ctr-aes driver for RFC 3686 crypto: atmel-aes - create sections to regroup functions by usage crypto: atmel-aes - fix typo and indentation crypto: atmel-aes - use SIZE_IN_WORDS() helper macro crypto: atmel-aes - improve performances of data transfer crypto: atmel-aes - fix atmel_aes_remove() crypto: atmel-aes - remove useless AES_FLAGS_DMA flag crypto: atmel-aes - reduce latency of DMA completion crypto: atmel-aes - remove unused 'err' member of struct atmel_aes_dev crypto: atmel-aes - rework crypto request completion ...
2 parents 60b7eca + 48d6276 commit c597b6b

File tree

113 files changed

+7343
-1604
lines changed

Some content is hidden

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

113 files changed

+7343
-1604
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Rockchip Electronics And Security Accelerator
2+
3+
Required properties:
4+
- compatible: Should be "rockchip,rk3288-crypto"
5+
- reg: Base physical address of the engine and length of memory mapped
6+
region
7+
- interrupts: Interrupt number
8+
- clocks: Reference to the clocks about crypto
9+
- clock-names: "aclk" used to clock data
10+
"hclk" used to clock data
11+
"sclk" used to clock crypto accelerator
12+
"apb_pclk" used to clock dma
13+
- resets: Must contain an entry for each entry in reset-names.
14+
See ../reset/reset.txt for details.
15+
- reset-names: Must include the name "crypto-rst".
16+
17+
Examples:
18+
19+
crypto: cypto-controller@ff8a0000 {
20+
compatible = "rockchip,rk3288-crypto";
21+
reg = <0xff8a0000 0x4000>;
22+
interrupts = <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
23+
clocks = <&cru ACLK_CRYPTO>, <&cru HCLK_CRYPTO>,
24+
<&cru SCLK_CRYPTO>, <&cru ACLK_DMAC1>;
25+
clock-names = "aclk", "hclk", "sclk", "apb_pclk";
26+
resets = <&cru SRST_CRYPTO>;
27+
reset-names = "crypto-rst";
28+
status = "okay";
29+
};

arch/powerpc/include/asm/icswx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ struct coprocessor_request_block {
164164
#define ICSWX_INITIATED (0x8)
165165
#define ICSWX_BUSY (0x4)
166166
#define ICSWX_REJECTED (0x2)
167+
#define ICSWX_XERS0 (0x1) /* undefined or set from XERSO. */
167168

168169
static inline int icswx(__be32 ccw, struct coprocessor_request_block *crb)
169170
{

arch/x86/crypto/ghash-clmulni-intel_glue.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,29 @@ static int ghash_async_final(struct ahash_request *req)
219219
}
220220
}
221221

222+
static int ghash_async_import(struct ahash_request *req, const void *in)
223+
{
224+
struct ahash_request *cryptd_req = ahash_request_ctx(req);
225+
struct shash_desc *desc = cryptd_shash_desc(cryptd_req);
226+
struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
227+
228+
ghash_async_init(req);
229+
memcpy(dctx, in, sizeof(*dctx));
230+
return 0;
231+
232+
}
233+
234+
static int ghash_async_export(struct ahash_request *req, void *out)
235+
{
236+
struct ahash_request *cryptd_req = ahash_request_ctx(req);
237+
struct shash_desc *desc = cryptd_shash_desc(cryptd_req);
238+
struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
239+
240+
memcpy(out, dctx, sizeof(*dctx));
241+
return 0;
242+
243+
}
244+
222245
static int ghash_async_digest(struct ahash_request *req)
223246
{
224247
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
@@ -288,8 +311,11 @@ static struct ahash_alg ghash_async_alg = {
288311
.final = ghash_async_final,
289312
.setkey = ghash_async_setkey,
290313
.digest = ghash_async_digest,
314+
.export = ghash_async_export,
315+
.import = ghash_async_import,
291316
.halg = {
292317
.digestsize = GHASH_DIGEST_SIZE,
318+
.statesize = sizeof(struct ghash_desc_ctx),
293319
.base = {
294320
.cra_name = "ghash",
295321
.cra_driver_name = "ghash-clmulni",

crypto/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ rsa_generic-y := rsapubkey-asn1.o
4040
rsa_generic-y += rsaprivkey-asn1.o
4141
rsa_generic-y += rsa.o
4242
rsa_generic-y += rsa_helper.o
43+
rsa_generic-y += rsa-pkcs1pad.o
4344
obj-$(CONFIG_CRYPTO_RSA) += rsa_generic.o
4445

4546
cryptomgr-y := algboss.o testmgr.o

crypto/akcipher.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/cryptouser.h>
2222
#include <net/netlink.h>
2323
#include <crypto/akcipher.h>
24+
#include <crypto/internal/akcipher.h>
2425
#include "internal.h"
2526

2627
#ifdef CONFIG_NET
@@ -75,9 +76,17 @@ static int crypto_akcipher_init_tfm(struct crypto_tfm *tfm)
7576
return 0;
7677
}
7778

79+
static void crypto_akcipher_free_instance(struct crypto_instance *inst)
80+
{
81+
struct akcipher_instance *akcipher = akcipher_instance(inst);
82+
83+
akcipher->free(akcipher);
84+
}
85+
7886
static const struct crypto_type crypto_akcipher_type = {
7987
.extsize = crypto_alg_extsize,
8088
.init_tfm = crypto_akcipher_init_tfm,
89+
.free = crypto_akcipher_free_instance,
8190
#ifdef CONFIG_PROC_FS
8291
.show = crypto_akcipher_show,
8392
#endif
@@ -88,20 +97,35 @@ static const struct crypto_type crypto_akcipher_type = {
8897
.tfmsize = offsetof(struct crypto_akcipher, base),
8998
};
9099

100+
int crypto_grab_akcipher(struct crypto_akcipher_spawn *spawn, const char *name,
101+
u32 type, u32 mask)
102+
{
103+
spawn->base.frontend = &crypto_akcipher_type;
104+
return crypto_grab_spawn(&spawn->base, name, type, mask);
105+
}
106+
EXPORT_SYMBOL_GPL(crypto_grab_akcipher);
107+
91108
struct crypto_akcipher *crypto_alloc_akcipher(const char *alg_name, u32 type,
92109
u32 mask)
93110
{
94111
return crypto_alloc_tfm(alg_name, &crypto_akcipher_type, type, mask);
95112
}
96113
EXPORT_SYMBOL_GPL(crypto_alloc_akcipher);
97114

98-
int crypto_register_akcipher(struct akcipher_alg *alg)
115+
static void akcipher_prepare_alg(struct akcipher_alg *alg)
99116
{
100117
struct crypto_alg *base = &alg->base;
101118

102119
base->cra_type = &crypto_akcipher_type;
103120
base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
104121
base->cra_flags |= CRYPTO_ALG_TYPE_AKCIPHER;
122+
}
123+
124+
int crypto_register_akcipher(struct akcipher_alg *alg)
125+
{
126+
struct crypto_alg *base = &alg->base;
127+
128+
akcipher_prepare_alg(alg);
105129
return crypto_register_alg(base);
106130
}
107131
EXPORT_SYMBOL_GPL(crypto_register_akcipher);
@@ -112,5 +136,13 @@ void crypto_unregister_akcipher(struct akcipher_alg *alg)
112136
}
113137
EXPORT_SYMBOL_GPL(crypto_unregister_akcipher);
114138

139+
int akcipher_register_instance(struct crypto_template *tmpl,
140+
struct akcipher_instance *inst)
141+
{
142+
akcipher_prepare_alg(&inst->alg);
143+
return crypto_register_instance(tmpl, akcipher_crypto_instance(inst));
144+
}
145+
EXPORT_SYMBOL_GPL(akcipher_register_instance);
146+
115147
MODULE_LICENSE("GPL");
116148
MODULE_DESCRIPTION("Generic public key cipher type");

crypto/algapi.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,15 @@ static struct list_head *crypto_more_spawns(struct crypto_alg *alg,
9393
{
9494
struct crypto_spawn *spawn, *n;
9595

96-
if (list_empty(stack))
96+
spawn = list_first_entry_or_null(stack, struct crypto_spawn, list);
97+
if (!spawn)
9798
return NULL;
9899

99-
spawn = list_first_entry(stack, struct crypto_spawn, list);
100-
n = list_entry(spawn->list.next, struct crypto_spawn, list);
100+
n = list_next_entry(spawn, list);
101101

102102
if (spawn->alg && &n->list != stack && !n->alg)
103103
n->alg = (n->list.next == stack) ? alg :
104-
&list_entry(n->list.next, struct crypto_spawn,
105-
list)->inst->alg;
104+
&list_next_entry(n, list)->inst->alg;
106105

107106
list_move(&spawn->list, secondary_spawns);
108107

crypto/algif_aead.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static int aead_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
213213
}
214214

215215
while (size) {
216-
unsigned long len = size;
216+
size_t len = size;
217217
struct scatterlist *sg = NULL;
218218

219219
/* use the existing memory in an allocated page */
@@ -247,7 +247,7 @@ static int aead_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
247247
/* allocate a new page */
248248
len = min_t(unsigned long, size, aead_sndbuf(sk));
249249
while (len) {
250-
int plen = 0;
250+
size_t plen = 0;
251251

252252
if (sgl->cur >= ALG_MAX_PAGES) {
253253
aead_put_sgl(sk);
@@ -256,7 +256,7 @@ static int aead_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
256256
}
257257

258258
sg = sgl->sg + sgl->cur;
259-
plen = min_t(int, len, PAGE_SIZE);
259+
plen = min_t(size_t, len, PAGE_SIZE);
260260

261261
sg_assign_page(sg, alloc_page(GFP_KERNEL));
262262
err = -ENOMEM;

crypto/algif_skcipher.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct skcipher_ctx {
4040
struct af_alg_completion completion;
4141

4242
atomic_t inflight;
43-
unsigned used;
43+
size_t used;
4444

4545
unsigned int len;
4646
bool more;
@@ -153,7 +153,7 @@ static int skcipher_alloc_sgl(struct sock *sk)
153153
return 0;
154154
}
155155

156-
static void skcipher_pull_sgl(struct sock *sk, int used, int put)
156+
static void skcipher_pull_sgl(struct sock *sk, size_t used, int put)
157157
{
158158
struct alg_sock *ask = alg_sk(sk);
159159
struct skcipher_ctx *ctx = ask->private;
@@ -167,7 +167,7 @@ static void skcipher_pull_sgl(struct sock *sk, int used, int put)
167167
sg = sgl->sg;
168168

169169
for (i = 0; i < sgl->cur; i++) {
170-
int plen = min_t(int, used, sg[i].length);
170+
size_t plen = min_t(size_t, used, sg[i].length);
171171

172172
if (!sg_page(sg + i))
173173
continue;
@@ -348,7 +348,7 @@ static int skcipher_sendmsg(struct socket *sock, struct msghdr *msg,
348348
while (size) {
349349
struct scatterlist *sg;
350350
unsigned long len = size;
351-
int plen;
351+
size_t plen;
352352

353353
if (ctx->merge) {
354354
sgl = list_entry(ctx->tsgl.prev,
@@ -390,7 +390,7 @@ static int skcipher_sendmsg(struct socket *sock, struct msghdr *msg,
390390
sg_unmark_end(sg + sgl->cur);
391391
do {
392392
i = sgl->cur;
393-
plen = min_t(int, len, PAGE_SIZE);
393+
plen = min_t(size_t, len, PAGE_SIZE);
394394

395395
sg_assign_page(sg + i, alloc_page(GFP_KERNEL));
396396
err = -ENOMEM;

crypto/asymmetric_keys/signature.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#define pr_fmt(fmt) "SIG: "fmt
1515
#include <keys/asymmetric-subtype.h>
16-
#include <linux/module.h>
16+
#include <linux/export.h>
1717
#include <linux/err.h>
1818
#include <crypto/public_key.h>
1919
#include "asymmetric_keys.h"

crypto/chacha20poly1305.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ static int chacha_decrypt(struct aead_request *req)
130130
struct scatterlist *src, *dst;
131131
int err;
132132

133+
if (rctx->cryptlen == 0)
134+
goto skip;
135+
133136
chacha_iv(creq->iv, req, 1);
134137

135138
sg_init_table(rctx->src, 2);
@@ -150,6 +153,7 @@ static int chacha_decrypt(struct aead_request *req)
150153
if (err)
151154
return err;
152155

156+
skip:
153157
return poly_verify_tag(req);
154158
}
155159

@@ -415,6 +419,9 @@ static int chacha_encrypt(struct aead_request *req)
415419
struct scatterlist *src, *dst;
416420
int err;
417421

422+
if (req->cryptlen == 0)
423+
goto skip;
424+
418425
chacha_iv(creq->iv, req, 1);
419426

420427
sg_init_table(rctx->src, 2);
@@ -435,6 +442,7 @@ static int chacha_encrypt(struct aead_request *req)
435442
if (err)
436443
return err;
437444

445+
skip:
438446
return poly_genkey(req);
439447
}
440448

crypto/cryptd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
637637
inst->alg.halg.base.cra_flags = type;
638638

639639
inst->alg.halg.digestsize = salg->digestsize;
640+
inst->alg.halg.statesize = salg->statesize;
640641
inst->alg.halg.base.cra_ctxsize = sizeof(struct cryptd_hash_ctx);
641642

642643
inst->alg.halg.base.cra_init = cryptd_hash_init_tfm;
@@ -887,8 +888,7 @@ struct cryptd_ablkcipher *cryptd_alloc_ablkcipher(const char *alg_name,
887888
if (snprintf(cryptd_alg_name, CRYPTO_MAX_ALG_NAME,
888889
"cryptd(%s)", alg_name) >= CRYPTO_MAX_ALG_NAME)
889890
return ERR_PTR(-EINVAL);
890-
type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_GENIV);
891-
type |= CRYPTO_ALG_TYPE_BLKCIPHER;
891+
type = crypto_skcipher_type(type);
892892
mask &= ~CRYPTO_ALG_TYPE_MASK;
893893
mask |= (CRYPTO_ALG_GENIV | CRYPTO_ALG_TYPE_BLKCIPHER_MASK);
894894
tfm = crypto_alloc_base(cryptd_alg_name, type, mask);

crypto/drbg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ static int drbg_ctr_generate(struct drbg_state *drbg,
626626
return len;
627627
}
628628

629-
static struct drbg_state_ops drbg_ctr_ops = {
629+
static const struct drbg_state_ops drbg_ctr_ops = {
630630
.update = drbg_ctr_update,
631631
.generate = drbg_ctr_generate,
632632
.crypto_init = drbg_init_sym_kernel,
@@ -752,7 +752,7 @@ static int drbg_hmac_generate(struct drbg_state *drbg,
752752
return len;
753753
}
754754

755-
static struct drbg_state_ops drbg_hmac_ops = {
755+
static const struct drbg_state_ops drbg_hmac_ops = {
756756
.update = drbg_hmac_update,
757757
.generate = drbg_hmac_generate,
758758
.crypto_init = drbg_init_hash_kernel,
@@ -1032,7 +1032,7 @@ static int drbg_hash_generate(struct drbg_state *drbg,
10321032
* scratchpad usage: as update and generate are used isolated, both
10331033
* can use the scratchpad
10341034
*/
1035-
static struct drbg_state_ops drbg_hash_ops = {
1035+
static const struct drbg_state_ops drbg_hash_ops = {
10361036
.update = drbg_hash_update,
10371037
.generate = drbg_hash_generate,
10381038
.crypto_init = drbg_init_hash_kernel,

crypto/mcryptd.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,9 @@ static void mcryptd_opportunistic_flush(void)
128128
flist = per_cpu_ptr(mcryptd_flist, smp_processor_id());
129129
while (single_task_running()) {
130130
mutex_lock(&flist->lock);
131-
if (list_empty(&flist->list)) {
132-
mutex_unlock(&flist->lock);
133-
return;
134-
}
135-
cstate = list_entry(flist->list.next,
131+
cstate = list_first_entry_or_null(&flist->list,
136132
struct mcryptd_alg_cstate, flush_list);
137-
if (!cstate->flusher_engaged) {
133+
if (!cstate || !cstate->flusher_engaged) {
138134
mutex_unlock(&flist->lock);
139135
return;
140136
}

crypto/md5.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
#include <linux/cryptohash.h>
2525
#include <asm/byteorder.h>
2626

27+
const u8 md5_zero_message_hash[MD5_DIGEST_SIZE] = {
28+
0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04,
29+
0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e,
30+
};
31+
EXPORT_SYMBOL_GPL(md5_zero_message_hash);
32+
2733
/* XXX: this stuff can be optimized */
2834
static inline void le32_to_cpu_array(u32 *buf, unsigned int words)
2935
{

0 commit comments

Comments
 (0)