aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 21:51:14 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 21:51:14 -0500
commitc597b6bcd5c624534afc3df65cdc42bb05173bca (patch)
tree8fedd26c5dc0357a10db08a6bef31085e2508280 /include
parent60b7eca1dc2ec066916b3b7ac6ad89bea13cb9af (diff)
parent48d627648141479c8be8acd110191072e24eba25 (diff)
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 ...
Diffstat (limited to 'include')
-rw-r--r--include/crypto/aead.h1
-rw-r--r--include/crypto/akcipher.h10
-rw-r--r--include/crypto/internal/akcipher.h78
-rw-r--r--include/crypto/internal/rsa.h2
-rw-r--r--include/crypto/md5.h2
-rw-r--r--include/crypto/sha.h6
6 files changed, 94 insertions, 5 deletions
diff --git a/include/crypto/aead.h b/include/crypto/aead.h
index 077cae1e6b51..84d13b11ad7b 100644
--- a/include/crypto/aead.h
+++ b/include/crypto/aead.h
@@ -128,6 +128,7 @@ struct aead_request {
128 * @exit: Deinitialize the cryptographic transformation object. This is a 128 * @exit: Deinitialize the cryptographic transformation object. This is a
129 * counterpart to @init, used to remove various changes set in 129 * counterpart to @init, used to remove various changes set in
130 * @init. 130 * @init.
131 * @base: Definition of a generic crypto cipher algorithm.
131 * 132 *
132 * All fields except @ivsize is mandatory and must be filled. 133 * All fields except @ivsize is mandatory and must be filled.
133 */ 134 */
diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
index 45cd5b328040..354de15cea6b 100644
--- a/include/crypto/akcipher.h
+++ b/include/crypto/akcipher.h
@@ -21,9 +21,9 @@
21 * @src: Source data 21 * @src: Source data
22 * @dst: Destination data 22 * @dst: Destination data
23 * @src_len: Size of the input buffer 23 * @src_len: Size of the input buffer
24 * @dst_len: Size of the output buffer. It needs to be at leaset 24 * @dst_len: Size of the output buffer. It needs to be at least
25 * as big as the expected result depending on the operation 25 * as big as the expected result depending on the operation
26 * After operation it will be updated with the acctual size of the 26 * After operation it will be updated with the actual size of the
27 * result. 27 * result.
28 * In case of error where the dst sgl size was insufficient, 28 * In case of error where the dst sgl size was insufficient,
29 * it will be updated to the size required for the operation. 29 * it will be updated to the size required for the operation.
@@ -59,7 +59,7 @@ struct crypto_akcipher {
59 * algorithm. In case of error, where the dst_len was insufficient, 59 * algorithm. In case of error, where the dst_len was insufficient,
60 * the req->dst_len will be updated to the size required for the 60 * the req->dst_len will be updated to the size required for the
61 * operation 61 * operation
62 * @encrypt: Function performs an encrytp operation as defined by public key 62 * @encrypt: Function performs an encrypt operation as defined by public key
63 * algorithm. In case of error, where the dst_len was insufficient, 63 * algorithm. In case of error, where the dst_len was insufficient,
64 * the req->dst_len will be updated to the size required for the 64 * the req->dst_len will be updated to the size required for the
65 * operation 65 * operation
@@ -73,7 +73,7 @@ struct crypto_akcipher {
73 * @set_priv_key: Function invokes the algorithm specific set private key 73 * @set_priv_key: Function invokes the algorithm specific set private key
74 * function, which knows how to decode and interpret 74 * function, which knows how to decode and interpret
75 * the BER encoded private key 75 * the BER encoded private key
76 * @max_size: Function returns dest buffer size reqired for a given key. 76 * @max_size: Function returns dest buffer size required for a given key.
77 * @init: Initialize the cryptographic transformation object. 77 * @init: Initialize the cryptographic transformation object.
78 * This function is used to initialize the cryptographic 78 * This function is used to initialize the cryptographic
79 * transformation object. This function is called only once at 79 * transformation object. This function is called only once at
@@ -232,7 +232,7 @@ static inline void akcipher_request_set_callback(struct akcipher_request *req,
232} 232}
233 233
234/** 234/**
235 * akcipher_request_set_crypt() -- Sets reqest parameters 235 * akcipher_request_set_crypt() -- Sets request parameters
236 * 236 *
237 * Sets parameters required by crypto operation 237 * Sets parameters required by crypto operation
238 * 238 *
diff --git a/include/crypto/internal/akcipher.h b/include/crypto/internal/akcipher.h
index 9a2bda15e454..479a0078f0f7 100644
--- a/include/crypto/internal/akcipher.h
+++ b/include/crypto/internal/akcipher.h
@@ -13,6 +13,22 @@
13#ifndef _CRYPTO_AKCIPHER_INT_H 13#ifndef _CRYPTO_AKCIPHER_INT_H
14#define _CRYPTO_AKCIPHER_INT_H 14#define _CRYPTO_AKCIPHER_INT_H
15#include <crypto/akcipher.h> 15#include <crypto/akcipher.h>
16#include <crypto/algapi.h>
17
18struct akcipher_instance {
19 void (*free)(struct akcipher_instance *inst);
20 union {
21 struct {
22 char head[offsetof(struct akcipher_alg, base)];
23 struct crypto_instance base;
24 } s;
25 struct akcipher_alg alg;
26 };
27};
28
29struct crypto_akcipher_spawn {
30 struct crypto_spawn base;
31};
16 32
17/* 33/*
18 * Transform internal helpers. 34 * Transform internal helpers.
@@ -38,6 +54,56 @@ static inline const char *akcipher_alg_name(struct crypto_akcipher *tfm)
38 return crypto_akcipher_tfm(tfm)->__crt_alg->cra_name; 54 return crypto_akcipher_tfm(tfm)->__crt_alg->cra_name;
39} 55}
40 56
57static inline struct crypto_instance *akcipher_crypto_instance(
58 struct akcipher_instance *inst)
59{
60 return container_of(&inst->alg.base, struct crypto_instance, alg);
61}
62
63static inline struct akcipher_instance *akcipher_instance(
64 struct crypto_instance *inst)
65{
66 return container_of(&inst->alg, struct akcipher_instance, alg.base);
67}
68
69static inline struct akcipher_instance *akcipher_alg_instance(
70 struct crypto_akcipher *akcipher)
71{
72 return akcipher_instance(crypto_tfm_alg_instance(&akcipher->base));
73}
74
75static inline void *akcipher_instance_ctx(struct akcipher_instance *inst)
76{
77 return crypto_instance_ctx(akcipher_crypto_instance(inst));
78}
79
80static inline void crypto_set_akcipher_spawn(
81 struct crypto_akcipher_spawn *spawn,
82 struct crypto_instance *inst)
83{
84 crypto_set_spawn(&spawn->base, inst);
85}
86
87int crypto_grab_akcipher(struct crypto_akcipher_spawn *spawn, const char *name,
88 u32 type, u32 mask);
89
90static inline struct crypto_akcipher *crypto_spawn_akcipher(
91 struct crypto_akcipher_spawn *spawn)
92{
93 return crypto_spawn_tfm2(&spawn->base);
94}
95
96static inline void crypto_drop_akcipher(struct crypto_akcipher_spawn *spawn)
97{
98 crypto_drop_spawn(&spawn->base);
99}
100
101static inline struct akcipher_alg *crypto_spawn_akcipher_alg(
102 struct crypto_akcipher_spawn *spawn)
103{
104 return container_of(spawn->base.alg, struct akcipher_alg, base);
105}
106
41/** 107/**
42 * crypto_register_akcipher() -- Register public key algorithm 108 * crypto_register_akcipher() -- Register public key algorithm
43 * 109 *
@@ -57,4 +123,16 @@ int crypto_register_akcipher(struct akcipher_alg *alg);
57 * @alg: algorithm definition 123 * @alg: algorithm definition
58 */ 124 */
59void crypto_unregister_akcipher(struct akcipher_alg *alg); 125void crypto_unregister_akcipher(struct akcipher_alg *alg);
126
127/**
128 * akcipher_register_instance() -- Unregister public key template instance
129 *
130 * Function registers an implementation of an asymmetric key algorithm
131 * created from a template
132 *
133 * @tmpl: the template from which the algorithm was created
134 * @inst: the template instance
135 */
136int akcipher_register_instance(struct crypto_template *tmpl,
137 struct akcipher_instance *inst);
60#endif 138#endif
diff --git a/include/crypto/internal/rsa.h b/include/crypto/internal/rsa.h
index f997e2d29b5a..c7585bdecbc2 100644
--- a/include/crypto/internal/rsa.h
+++ b/include/crypto/internal/rsa.h
@@ -27,4 +27,6 @@ int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key,
27 unsigned int key_len); 27 unsigned int key_len);
28 28
29void rsa_free_key(struct rsa_key *rsa_key); 29void rsa_free_key(struct rsa_key *rsa_key);
30
31extern struct crypto_template rsa_pkcs1pad_tmpl;
30#endif 32#endif
diff --git a/include/crypto/md5.h b/include/crypto/md5.h
index 146af825eedb..327deac963c0 100644
--- a/include/crypto/md5.h
+++ b/include/crypto/md5.h
@@ -13,6 +13,8 @@
13#define MD5_H2 0x98badcfeUL 13#define MD5_H2 0x98badcfeUL
14#define MD5_H3 0x10325476UL 14#define MD5_H3 0x10325476UL
15 15
16extern const u8 md5_zero_message_hash[MD5_DIGEST_SIZE];
17
16struct md5_state { 18struct md5_state {
17 u32 hash[MD5_HASH_WORDS]; 19 u32 hash[MD5_HASH_WORDS];
18 u32 block[MD5_BLOCK_WORDS]; 20 u32 block[MD5_BLOCK_WORDS];
diff --git a/include/crypto/sha.h b/include/crypto/sha.h
index dd7905a3c22e..c94d3eb1cefd 100644
--- a/include/crypto/sha.h
+++ b/include/crypto/sha.h
@@ -64,6 +64,12 @@
64#define SHA512_H6 0x1f83d9abfb41bd6bULL 64#define SHA512_H6 0x1f83d9abfb41bd6bULL
65#define SHA512_H7 0x5be0cd19137e2179ULL 65#define SHA512_H7 0x5be0cd19137e2179ULL
66 66
67extern const u8 sha1_zero_message_hash[SHA1_DIGEST_SIZE];
68
69extern const u8 sha224_zero_message_hash[SHA224_DIGEST_SIZE];
70
71extern const u8 sha256_zero_message_hash[SHA256_DIGEST_SIZE];
72
67struct sha1_state { 73struct sha1_state {
68 u32 state[SHA1_DIGEST_SIZE / 4]; 74 u32 state[SHA1_DIGEST_SIZE / 4];
69 u64 count; 75 u64 count;