aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-03-17 14:22:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-17 14:22:54 -0400
commit70477371dc350746d10431d74f0f213a8d59924c (patch)
tree6271978b6e4ee4b1e6f22775ad7fc0930c09d3ee /include
parent09fd671ccb2475436bd5f597f751ca4a7d177aea (diff)
parent34074205bb9f04b416efb3cbedcd90f418c86200 (diff)
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto update from Herbert Xu: "Here is the crypto update for 4.6: API: - Convert remaining crypto_hash users to shash or ahash, also convert blkcipher/ablkcipher users to skcipher. - Remove crypto_hash interface. - Remove crypto_pcomp interface. - Add crypto engine for async cipher drivers. - Add akcipher documentation. - Add skcipher documentation. Algorithms: - Rename crypto/crc32 to avoid name clash with lib/crc32. - Fix bug in keywrap where we zero the wrong pointer. Drivers: - Support T5/M5, T7/M7 SPARC CPUs in n2 hwrng driver. - Add PIC32 hwrng driver. - Support BCM6368 in bcm63xx hwrng driver. - Pack structs for 32-bit compat users in qat. - Use crypto engine in omap-aes. - Add support for sama5d2x SoCs in atmel-sha. - Make atmel-sha available again. - Make sahara hashing available again. - Make ccp hashing available again. - Make sha1-mb available again. - Add support for multiple devices in ccp. - Improve DMA performance in caam. - Add hashing support to rockchip" * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (116 commits) crypto: qat - remove redundant arbiter configuration crypto: ux500 - fix checks of error code returned by devm_ioremap_resource() crypto: atmel - fix checks of error code returned by devm_ioremap_resource() crypto: qat - Change the definition of icp_qat_uof_regtype hwrng: exynos - use __maybe_unused to hide pm functions crypto: ccp - Add abstraction for device-specific calls crypto: ccp - CCP versioning support crypto: ccp - Support for multiple CCPs crypto: ccp - Remove check for x86 family and model crypto: ccp - memset request context to zero during import lib/mpi: use "static inline" instead of "extern inline" lib/mpi: avoid assembler warning hwrng: bcm63xx - fix non device tree compatibility crypto: testmgr - allow rfc3686 aes-ctr variants in fips mode. crypto: qat - The AE id should be less than the maximal AE number lib/mpi: Endianness fix crypto: rockchip - add hash support for crypto engine in rk3288 crypto: xts - fix compile errors crypto: doc - add skcipher API documentation crypto: doc - update AEAD AD handling ...
Diffstat (limited to 'include')
-rw-r--r--include/crypto/aead.h6
-rw-r--r--include/crypto/akcipher.h28
-rw-r--r--include/crypto/algapi.h92
-rw-r--r--include/crypto/compress.h145
-rw-r--r--include/crypto/drbg.h4
-rw-r--r--include/crypto/hash.h45
-rw-r--r--include/crypto/internal/aead.h6
-rw-r--r--include/crypto/internal/compress.h28
-rw-r--r--include/crypto/internal/hash.h3
-rw-r--r--include/crypto/skcipher.h24
-rw-r--r--include/crypto/xts.h27
-rw-r--r--include/linux/ccp.h17
-rw-r--r--include/linux/crypto.h252
-rw-r--r--include/linux/sunrpc/gss_krb5.h32
-rw-r--r--include/net/sctp/auth.h4
-rw-r--r--include/net/sctp/structs.h6
-rw-r--r--include/net/tcp.h6
-rw-r--r--include/scsi/libiscsi_tcp.h13
-rw-r--r--include/target/iscsi/iscsi_target_core.h4
19 files changed, 238 insertions, 504 deletions
diff --git a/include/crypto/aead.h b/include/crypto/aead.h
index 84d13b11ad7b..957bb8763219 100644
--- a/include/crypto/aead.h
+++ b/include/crypto/aead.h
@@ -31,10 +31,10 @@
31 * 31 *
32 * For example: authenc(hmac(sha256), cbc(aes)) 32 * For example: authenc(hmac(sha256), cbc(aes))
33 * 33 *
34 * The example code provided for the asynchronous block cipher operation 34 * The example code provided for the symmetric key cipher operation
35 * applies here as well. Naturally all *ablkcipher* symbols must be exchanged 35 * applies here as well. Naturally all *skcipher* symbols must be exchanged
36 * the *aead* pendants discussed in the following. In addition, for the AEAD 36 * the *aead* pendants discussed in the following. In addition, for the AEAD
37 * operation, the aead_request_set_assoc function must be used to set the 37 * operation, the aead_request_set_ad function must be used to set the
38 * pointer to the associated data memory location before performing the 38 * pointer to the associated data memory location before performing the
39 * encryption or decryption operation. In case of an encryption, the associated 39 * encryption or decryption operation. In case of an encryption, the associated
40 * data memory is filled during the encryption operation. For decryption, the 40 * data memory is filled during the encryption operation. For decryption, the
diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
index 354de15cea6b..c37cc59e9bf2 100644
--- a/include/crypto/akcipher.h
+++ b/include/crypto/akcipher.h
@@ -114,7 +114,7 @@ struct akcipher_alg {
114 */ 114 */
115 115
116/** 116/**
117 * crypto_alloc_akcipher() -- allocate AKCIPHER tfm handle 117 * crypto_alloc_akcipher() - allocate AKCIPHER tfm handle
118 * @alg_name: is the cra_name / name or cra_driver_name / driver name of the 118 * @alg_name: is the cra_name / name or cra_driver_name / driver name of the
119 * public key algorithm e.g. "rsa" 119 * public key algorithm e.g. "rsa"
120 * @type: specifies the type of the algorithm 120 * @type: specifies the type of the algorithm
@@ -171,7 +171,7 @@ static inline struct crypto_akcipher *crypto_akcipher_reqtfm(
171} 171}
172 172
173/** 173/**
174 * crypto_free_akcipher() -- free AKCIPHER tfm handle 174 * crypto_free_akcipher() - free AKCIPHER tfm handle
175 * 175 *
176 * @tfm: AKCIPHER tfm handle allocated with crypto_alloc_akcipher() 176 * @tfm: AKCIPHER tfm handle allocated with crypto_alloc_akcipher()
177 */ 177 */
@@ -181,7 +181,7 @@ static inline void crypto_free_akcipher(struct crypto_akcipher *tfm)
181} 181}
182 182
183/** 183/**
184 * akcipher_request_alloc() -- allocates public key request 184 * akcipher_request_alloc() - allocates public key request
185 * 185 *
186 * @tfm: AKCIPHER tfm handle allocated with crypto_alloc_akcipher() 186 * @tfm: AKCIPHER tfm handle allocated with crypto_alloc_akcipher()
187 * @gfp: allocation flags 187 * @gfp: allocation flags
@@ -201,7 +201,7 @@ static inline struct akcipher_request *akcipher_request_alloc(
201} 201}
202 202
203/** 203/**
204 * akcipher_request_free() -- zeroize and free public key request 204 * akcipher_request_free() - zeroize and free public key request
205 * 205 *
206 * @req: request to free 206 * @req: request to free
207 */ 207 */
@@ -211,14 +211,14 @@ static inline void akcipher_request_free(struct akcipher_request *req)
211} 211}
212 212
213/** 213/**
214 * akcipher_request_set_callback() -- Sets an asynchronous callback. 214 * akcipher_request_set_callback() - Sets an asynchronous callback.
215 * 215 *
216 * Callback will be called when an asynchronous operation on a given 216 * Callback will be called when an asynchronous operation on a given
217 * request is finished. 217 * request is finished.
218 * 218 *
219 * @req: request that the callback will be set for 219 * @req: request that the callback will be set for
220 * @flgs: specify for instance if the operation may backlog 220 * @flgs: specify for instance if the operation may backlog
221 * @cmlp: callback which will be called 221 * @cmpl: callback which will be called
222 * @data: private data used by the caller 222 * @data: private data used by the caller
223 */ 223 */
224static inline void akcipher_request_set_callback(struct akcipher_request *req, 224static inline void akcipher_request_set_callback(struct akcipher_request *req,
@@ -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 request 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 *
@@ -255,7 +255,7 @@ static inline void akcipher_request_set_crypt(struct akcipher_request *req,
255} 255}
256 256
257/** 257/**
258 * crypto_akcipher_maxsize() -- Get len for output buffer 258 * crypto_akcipher_maxsize() - Get len for output buffer
259 * 259 *
260 * Function returns the dest buffer size required for a given key 260 * Function returns the dest buffer size required for a given key
261 * 261 *
@@ -271,7 +271,7 @@ static inline int crypto_akcipher_maxsize(struct crypto_akcipher *tfm)
271} 271}
272 272
273/** 273/**
274 * crypto_akcipher_encrypt() -- Invoke public key encrypt operation 274 * crypto_akcipher_encrypt() - Invoke public key encrypt operation
275 * 275 *
276 * Function invokes the specific public key encrypt operation for a given 276 * Function invokes the specific public key encrypt operation for a given
277 * public key algorithm 277 * public key algorithm
@@ -289,7 +289,7 @@ static inline int crypto_akcipher_encrypt(struct akcipher_request *req)
289} 289}
290 290
291/** 291/**
292 * crypto_akcipher_decrypt() -- Invoke public key decrypt operation 292 * crypto_akcipher_decrypt() - Invoke public key decrypt operation
293 * 293 *
294 * Function invokes the specific public key decrypt operation for a given 294 * Function invokes the specific public key decrypt operation for a given
295 * public key algorithm 295 * public key algorithm
@@ -307,7 +307,7 @@ static inline int crypto_akcipher_decrypt(struct akcipher_request *req)
307} 307}
308 308
309/** 309/**
310 * crypto_akcipher_sign() -- Invoke public key sign operation 310 * crypto_akcipher_sign() - Invoke public key sign operation
311 * 311 *
312 * Function invokes the specific public key sign operation for a given 312 * Function invokes the specific public key sign operation for a given
313 * public key algorithm 313 * public key algorithm
@@ -325,7 +325,7 @@ static inline int crypto_akcipher_sign(struct akcipher_request *req)
325} 325}
326 326
327/** 327/**
328 * crypto_akcipher_verify() -- Invoke public key verify operation 328 * crypto_akcipher_verify() - Invoke public key verify operation
329 * 329 *
330 * Function invokes the specific public key verify operation for a given 330 * Function invokes the specific public key verify operation for a given
331 * public key algorithm 331 * public key algorithm
@@ -343,7 +343,7 @@ static inline int crypto_akcipher_verify(struct akcipher_request *req)
343} 343}
344 344
345/** 345/**
346 * crypto_akcipher_set_pub_key() -- Invoke set public key operation 346 * crypto_akcipher_set_pub_key() - Invoke set public key operation
347 * 347 *
348 * Function invokes the algorithm specific set key function, which knows 348 * Function invokes the algorithm specific set key function, which knows
349 * how to decode and interpret the encoded key 349 * how to decode and interpret the encoded key
@@ -364,7 +364,7 @@ static inline int crypto_akcipher_set_pub_key(struct crypto_akcipher *tfm,
364} 364}
365 365
366/** 366/**
367 * crypto_akcipher_set_priv_key() -- Invoke set private key operation 367 * crypto_akcipher_set_priv_key() - Invoke set private key operation
368 * 368 *
369 * Function invokes the algorithm specific set key function, which knows 369 * Function invokes the algorithm specific set key function, which knows
370 * how to decode and interpret the encoded key 370 * how to decode and interpret the encoded key
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index c9fe145f7dd3..eeafd21afb44 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -15,6 +15,7 @@
15#include <linux/crypto.h> 15#include <linux/crypto.h>
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/kthread.h>
18#include <linux/skbuff.h> 19#include <linux/skbuff.h>
19 20
20struct crypto_aead; 21struct crypto_aead;
@@ -128,6 +129,75 @@ struct ablkcipher_walk {
128 unsigned int blocksize; 129 unsigned int blocksize;
129}; 130};
130 131
132#define ENGINE_NAME_LEN 30
133/*
134 * struct crypto_engine - crypto hardware engine
135 * @name: the engine name
136 * @idling: the engine is entering idle state
137 * @busy: request pump is busy
138 * @running: the engine is on working
139 * @cur_req_prepared: current request is prepared
140 * @list: link with the global crypto engine list
141 * @queue_lock: spinlock to syncronise access to request queue
142 * @queue: the crypto queue of the engine
143 * @rt: whether this queue is set to run as a realtime task
144 * @prepare_crypt_hardware: a request will soon arrive from the queue
145 * so the subsystem requests the driver to prepare the hardware
146 * by issuing this call
147 * @unprepare_crypt_hardware: there are currently no more requests on the
148 * queue so the subsystem notifies the driver that it may relax the
149 * hardware by issuing this call
150 * @prepare_request: do some prepare if need before handle the current request
151 * @unprepare_request: undo any work done by prepare_message()
152 * @crypt_one_request: do encryption for current request
153 * @kworker: thread struct for request pump
154 * @kworker_task: pointer to task for request pump kworker thread
155 * @pump_requests: work struct for scheduling work to the request pump
156 * @priv_data: the engine private data
157 * @cur_req: the current request which is on processing
158 */
159struct crypto_engine {
160 char name[ENGINE_NAME_LEN];
161 bool idling;
162 bool busy;
163 bool running;
164 bool cur_req_prepared;
165
166 struct list_head list;
167 spinlock_t queue_lock;
168 struct crypto_queue queue;
169
170 bool rt;
171
172 int (*prepare_crypt_hardware)(struct crypto_engine *engine);
173 int (*unprepare_crypt_hardware)(struct crypto_engine *engine);
174
175 int (*prepare_request)(struct crypto_engine *engine,
176 struct ablkcipher_request *req);
177 int (*unprepare_request)(struct crypto_engine *engine,
178 struct ablkcipher_request *req);
179 int (*crypt_one_request)(struct crypto_engine *engine,
180 struct ablkcipher_request *req);
181
182 struct kthread_worker kworker;
183 struct task_struct *kworker_task;
184 struct kthread_work pump_requests;
185
186 void *priv_data;
187 struct ablkcipher_request *cur_req;
188};
189
190int crypto_transfer_request(struct crypto_engine *engine,
191 struct ablkcipher_request *req, bool need_pump);
192int crypto_transfer_request_to_engine(struct crypto_engine *engine,
193 struct ablkcipher_request *req);
194void crypto_finalize_request(struct crypto_engine *engine,
195 struct ablkcipher_request *req, int err);
196int crypto_engine_start(struct crypto_engine *engine);
197int crypto_engine_stop(struct crypto_engine *engine);
198struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt);
199int crypto_engine_exit(struct crypto_engine *engine);
200
131extern const struct crypto_type crypto_ablkcipher_type; 201extern const struct crypto_type crypto_ablkcipher_type;
132extern const struct crypto_type crypto_blkcipher_type; 202extern const struct crypto_type crypto_blkcipher_type;
133 203
@@ -184,6 +254,10 @@ int crypto_enqueue_request(struct crypto_queue *queue,
184 struct crypto_async_request *request); 254 struct crypto_async_request *request);
185struct crypto_async_request *crypto_dequeue_request(struct crypto_queue *queue); 255struct crypto_async_request *crypto_dequeue_request(struct crypto_queue *queue);
186int crypto_tfm_in_queue(struct crypto_queue *queue, struct crypto_tfm *tfm); 256int crypto_tfm_in_queue(struct crypto_queue *queue, struct crypto_tfm *tfm);
257static inline unsigned int crypto_queue_len(struct crypto_queue *queue)
258{
259 return queue->qlen;
260}
187 261
188/* These functions require the input/output to be aligned as u32. */ 262/* These functions require the input/output to be aligned as u32. */
189void crypto_inc(u8 *a, unsigned int size); 263void crypto_inc(u8 *a, unsigned int size);
@@ -275,24 +349,6 @@ static inline struct cipher_alg *crypto_cipher_alg(struct crypto_cipher *tfm)
275 return &crypto_cipher_tfm(tfm)->__crt_alg->cra_cipher; 349 return &crypto_cipher_tfm(tfm)->__crt_alg->cra_cipher;
276} 350}
277 351
278static inline struct crypto_hash *crypto_spawn_hash(struct crypto_spawn *spawn)
279{
280 u32 type = CRYPTO_ALG_TYPE_HASH;
281 u32 mask = CRYPTO_ALG_TYPE_HASH_MASK;
282
283 return __crypto_hash_cast(crypto_spawn_tfm(spawn, type, mask));
284}
285
286static inline void *crypto_hash_ctx(struct crypto_hash *tfm)
287{
288 return crypto_tfm_ctx(&tfm->base);
289}
290
291static inline void *crypto_hash_ctx_aligned(struct crypto_hash *tfm)
292{
293 return crypto_tfm_ctx_aligned(&tfm->base);
294}
295
296static inline void blkcipher_walk_init(struct blkcipher_walk *walk, 352static inline void blkcipher_walk_init(struct blkcipher_walk *walk,
297 struct scatterlist *dst, 353 struct scatterlist *dst,
298 struct scatterlist *src, 354 struct scatterlist *src,
diff --git a/include/crypto/compress.h b/include/crypto/compress.h
deleted file mode 100644
index 5b67af834d83..000000000000
--- a/include/crypto/compress.h
+++ /dev/null
@@ -1,145 +0,0 @@
1/*
2 * Compress: Compression algorithms under the cryptographic API.
3 *
4 * Copyright 2008 Sony Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.
17 * If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef _CRYPTO_COMPRESS_H
21#define _CRYPTO_COMPRESS_H
22
23#include <linux/crypto.h>
24
25
26struct comp_request {
27 const void *next_in; /* next input byte */
28 void *next_out; /* next output byte */
29 unsigned int avail_in; /* bytes available at next_in */
30 unsigned int avail_out; /* bytes available at next_out */
31};
32
33enum zlib_comp_params {
34 ZLIB_COMP_LEVEL = 1, /* e.g. Z_DEFAULT_COMPRESSION */
35 ZLIB_COMP_METHOD, /* e.g. Z_DEFLATED */
36 ZLIB_COMP_WINDOWBITS, /* e.g. MAX_WBITS */
37 ZLIB_COMP_MEMLEVEL, /* e.g. DEF_MEM_LEVEL */
38 ZLIB_COMP_STRATEGY, /* e.g. Z_DEFAULT_STRATEGY */
39 __ZLIB_COMP_MAX,
40};
41
42#define ZLIB_COMP_MAX (__ZLIB_COMP_MAX - 1)
43
44
45enum zlib_decomp_params {
46 ZLIB_DECOMP_WINDOWBITS = 1, /* e.g. DEF_WBITS */
47 __ZLIB_DECOMP_MAX,
48};
49
50#define ZLIB_DECOMP_MAX (__ZLIB_DECOMP_MAX - 1)
51
52
53struct crypto_pcomp {
54 struct crypto_tfm base;
55};
56
57struct pcomp_alg {
58 int (*compress_setup)(struct crypto_pcomp *tfm, const void *params,
59 unsigned int len);
60 int (*compress_init)(struct crypto_pcomp *tfm);
61 int (*compress_update)(struct crypto_pcomp *tfm,
62 struct comp_request *req);
63 int (*compress_final)(struct crypto_pcomp *tfm,
64 struct comp_request *req);
65 int (*decompress_setup)(struct crypto_pcomp *tfm, const void *params,
66 unsigned int len);
67 int (*decompress_init)(struct crypto_pcomp *tfm);
68 int (*decompress_update)(struct crypto_pcomp *tfm,
69 struct comp_request *req);
70 int (*decompress_final)(struct crypto_pcomp *tfm,
71 struct comp_request *req);
72
73 struct crypto_alg base;
74};
75
76extern struct crypto_pcomp *crypto_alloc_pcomp(const char *alg_name, u32 type,
77 u32 mask);
78
79static inline struct crypto_tfm *crypto_pcomp_tfm(struct crypto_pcomp *tfm)
80{
81 return &tfm->base;
82}
83
84static inline void crypto_free_pcomp(struct crypto_pcomp *tfm)
85{
86 crypto_destroy_tfm(tfm, crypto_pcomp_tfm(tfm));
87}
88
89static inline struct pcomp_alg *__crypto_pcomp_alg(struct crypto_alg *alg)
90{
91 return container_of(alg, struct pcomp_alg, base);
92}
93
94static inline struct pcomp_alg *crypto_pcomp_alg(struct crypto_pcomp *tfm)
95{
96 return __crypto_pcomp_alg(crypto_pcomp_tfm(tfm)->__crt_alg);
97}
98
99static inline int crypto_compress_setup(struct crypto_pcomp *tfm,
100 const void *params, unsigned int len)
101{
102 return crypto_pcomp_alg(tfm)->compress_setup(tfm, params, len);
103}
104
105static inline int crypto_compress_init(struct crypto_pcomp *tfm)
106{
107 return crypto_pcomp_alg(tfm)->compress_init(tfm);
108}
109
110static inline int crypto_compress_update(struct crypto_pcomp *tfm,
111 struct comp_request *req)
112{
113 return crypto_pcomp_alg(tfm)->compress_update(tfm, req);
114}
115
116static inline int crypto_compress_final(struct crypto_pcomp *tfm,
117 struct comp_request *req)
118{
119 return crypto_pcomp_alg(tfm)->compress_final(tfm, req);
120}
121
122static inline int crypto_decompress_setup(struct crypto_pcomp *tfm,
123 const void *params, unsigned int len)
124{
125 return crypto_pcomp_alg(tfm)->decompress_setup(tfm, params, len);
126}
127
128static inline int crypto_decompress_init(struct crypto_pcomp *tfm)
129{
130 return crypto_pcomp_alg(tfm)->decompress_init(tfm);
131}
132
133static inline int crypto_decompress_update(struct crypto_pcomp *tfm,
134 struct comp_request *req)
135{
136 return crypto_pcomp_alg(tfm)->decompress_update(tfm, req);
137}
138
139static inline int crypto_decompress_final(struct crypto_pcomp *tfm,
140 struct comp_request *req)
141{
142 return crypto_pcomp_alg(tfm)->decompress_final(tfm, req);
143}
144
145#endif /* _CRYPTO_COMPRESS_H */
diff --git a/include/crypto/drbg.h b/include/crypto/drbg.h
index 9756c70899d8..d961b2b16f55 100644
--- a/include/crypto/drbg.h
+++ b/include/crypto/drbg.h
@@ -117,10 +117,6 @@ struct drbg_state {
117 void *priv_data; /* Cipher handle */ 117 void *priv_data; /* Cipher handle */
118 bool seeded; /* DRBG fully seeded? */ 118 bool seeded; /* DRBG fully seeded? */
119 bool pr; /* Prediction resistance enabled? */ 119 bool pr; /* Prediction resistance enabled? */
120#ifdef CONFIG_CRYPTO_FIPS
121 bool fips_primed; /* Continuous test primed? */
122 unsigned char *prev; /* FIPS 140-2 continuous test value */
123#endif
124 struct work_struct seed_work; /* asynchronous seeding support */ 120 struct work_struct seed_work; /* asynchronous seeding support */
125 struct crypto_rng *jent; 121 struct crypto_rng *jent;
126 const struct drbg_state_ops *d_ops; 122 const struct drbg_state_ops *d_ops;
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index 6361892ea737..1969f1416658 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -14,6 +14,7 @@
14#define _CRYPTO_HASH_H 14#define _CRYPTO_HASH_H
15 15
16#include <linux/crypto.h> 16#include <linux/crypto.h>
17#include <linux/string.h>
17 18
18struct crypto_ahash; 19struct crypto_ahash;
19 20
@@ -259,6 +260,28 @@ static inline void crypto_free_ahash(struct crypto_ahash *tfm)
259 crypto_destroy_tfm(tfm, crypto_ahash_tfm(tfm)); 260 crypto_destroy_tfm(tfm, crypto_ahash_tfm(tfm));
260} 261}
261 262
263/**
264 * crypto_has_ahash() - Search for the availability of an ahash.
265 * @alg_name: is the cra_name / name or cra_driver_name / driver name of the
266 * ahash
267 * @type: specifies the type of the ahash
268 * @mask: specifies the mask for the ahash
269 *
270 * Return: true when the ahash is known to the kernel crypto API; false
271 * otherwise
272 */
273int crypto_has_ahash(const char *alg_name, u32 type, u32 mask);
274
275static inline const char *crypto_ahash_alg_name(struct crypto_ahash *tfm)
276{
277 return crypto_tfm_alg_name(crypto_ahash_tfm(tfm));
278}
279
280static inline const char *crypto_ahash_driver_name(struct crypto_ahash *tfm)
281{
282 return crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm));
283}
284
262static inline unsigned int crypto_ahash_alignmask( 285static inline unsigned int crypto_ahash_alignmask(
263 struct crypto_ahash *tfm) 286 struct crypto_ahash *tfm)
264{ 287{
@@ -550,6 +573,12 @@ static inline void ahash_request_free(struct ahash_request *req)
550 kzfree(req); 573 kzfree(req);
551} 574}
552 575
576static inline void ahash_request_zero(struct ahash_request *req)
577{
578 memzero_explicit(req, sizeof(*req) +
579 crypto_ahash_reqsize(crypto_ahash_reqtfm(req)));
580}
581
553static inline struct ahash_request *ahash_request_cast( 582static inline struct ahash_request *ahash_request_cast(
554 struct crypto_async_request *req) 583 struct crypto_async_request *req)
555{ 584{
@@ -657,6 +686,16 @@ static inline void crypto_free_shash(struct crypto_shash *tfm)
657 crypto_destroy_tfm(tfm, crypto_shash_tfm(tfm)); 686 crypto_destroy_tfm(tfm, crypto_shash_tfm(tfm));
658} 687}
659 688
689static inline const char *crypto_shash_alg_name(struct crypto_shash *tfm)
690{
691 return crypto_tfm_alg_name(crypto_shash_tfm(tfm));
692}
693
694static inline const char *crypto_shash_driver_name(struct crypto_shash *tfm)
695{
696 return crypto_tfm_alg_driver_name(crypto_shash_tfm(tfm));
697}
698
660static inline unsigned int crypto_shash_alignmask( 699static inline unsigned int crypto_shash_alignmask(
661 struct crypto_shash *tfm) 700 struct crypto_shash *tfm)
662{ 701{
@@ -872,4 +911,10 @@ int crypto_shash_final(struct shash_desc *desc, u8 *out);
872int crypto_shash_finup(struct shash_desc *desc, const u8 *data, 911int crypto_shash_finup(struct shash_desc *desc, const u8 *data,
873 unsigned int len, u8 *out); 912 unsigned int len, u8 *out);
874 913
914static inline void shash_desc_zero(struct shash_desc *desc)
915{
916 memzero_explicit(desc,
917 sizeof(*desc) + crypto_shash_descsize(desc->tfm));
918}
919
875#endif /* _CRYPTO_HASH_H */ 920#endif /* _CRYPTO_HASH_H */
diff --git a/include/crypto/internal/aead.h b/include/crypto/internal/aead.h
index 5554cdd8d6c1..da3864991d4c 100644
--- a/include/crypto/internal/aead.h
+++ b/include/crypto/internal/aead.h
@@ -80,6 +80,12 @@ static inline u32 aead_request_flags(struct aead_request *req)
80 return req->base.flags; 80 return req->base.flags;
81} 81}
82 82
83static inline struct aead_request *aead_request_cast(
84 struct crypto_async_request *req)
85{
86 return container_of(req, struct aead_request, base);
87}
88
83static inline void crypto_set_aead_spawn( 89static inline void crypto_set_aead_spawn(
84 struct crypto_aead_spawn *spawn, struct crypto_instance *inst) 90 struct crypto_aead_spawn *spawn, struct crypto_instance *inst)
85{ 91{
diff --git a/include/crypto/internal/compress.h b/include/crypto/internal/compress.h
deleted file mode 100644
index 178a888d1d93..000000000000
--- a/include/crypto/internal/compress.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * Compress: Compression algorithms under the cryptographic API.
3 *
4 * Copyright 2008 Sony Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.
17 * If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef _CRYPTO_INTERNAL_COMPRESS_H
21#define _CRYPTO_INTERNAL_COMPRESS_H
22
23#include <crypto/compress.h>
24
25extern int crypto_register_pcomp(struct pcomp_alg *alg);
26extern int crypto_unregister_pcomp(struct pcomp_alg *alg);
27
28#endif /* _CRYPTO_INTERNAL_COMPRESS_H */
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h
index 3b4af1d7c7e9..49dae16f8929 100644
--- a/include/crypto/internal/hash.h
+++ b/include/crypto/internal/hash.h
@@ -57,9 +57,6 @@ int crypto_hash_walk_first(struct ahash_request *req,
57 struct crypto_hash_walk *walk); 57 struct crypto_hash_walk *walk);
58int crypto_ahash_walk_first(struct ahash_request *req, 58int crypto_ahash_walk_first(struct ahash_request *req,
59 struct crypto_hash_walk *walk); 59 struct crypto_hash_walk *walk);
60int crypto_hash_walk_first_compat(struct hash_desc *hdesc,
61 struct crypto_hash_walk *walk,
62 struct scatterlist *sg, unsigned int len);
63 60
64static inline int crypto_ahash_walk_done(struct crypto_hash_walk *walk, 61static inline int crypto_ahash_walk_done(struct crypto_hash_walk *walk,
65 int err) 62 int err)
diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h
index fd8742a40ff3..905490c1da89 100644
--- a/include/crypto/skcipher.h
+++ b/include/crypto/skcipher.h
@@ -60,8 +60,7 @@ struct crypto_skcipher {
60 60
61 unsigned int ivsize; 61 unsigned int ivsize;
62 unsigned int reqsize; 62 unsigned int reqsize;
63 63 unsigned int keysize;
64 bool has_setkey;
65 64
66 struct crypto_tfm base; 65 struct crypto_tfm base;
67}; 66};
@@ -232,6 +231,12 @@ static inline int crypto_has_skcipher(const char *alg_name, u32 type,
232 crypto_skcipher_mask(mask)); 231 crypto_skcipher_mask(mask));
233} 232}
234 233
234static inline const char *crypto_skcipher_driver_name(
235 struct crypto_skcipher *tfm)
236{
237 return crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm));
238}
239
235/** 240/**
236 * crypto_skcipher_ivsize() - obtain IV size 241 * crypto_skcipher_ivsize() - obtain IV size
237 * @tfm: cipher handle 242 * @tfm: cipher handle
@@ -309,7 +314,13 @@ static inline int crypto_skcipher_setkey(struct crypto_skcipher *tfm,
309 314
310static inline bool crypto_skcipher_has_setkey(struct crypto_skcipher *tfm) 315static inline bool crypto_skcipher_has_setkey(struct crypto_skcipher *tfm)
311{ 316{
312 return tfm->has_setkey; 317 return tfm->keysize;
318}
319
320static inline unsigned int crypto_skcipher_default_keysize(
321 struct crypto_skcipher *tfm)
322{
323 return tfm->keysize;
313} 324}
314 325
315/** 326/**
@@ -440,6 +451,13 @@ static inline void skcipher_request_free(struct skcipher_request *req)
440 kzfree(req); 451 kzfree(req);
441} 452}
442 453
454static inline void skcipher_request_zero(struct skcipher_request *req)
455{
456 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
457
458 memzero_explicit(req, sizeof(*req) + crypto_skcipher_reqsize(tfm));
459}
460
443/** 461/**
444 * skcipher_request_set_callback() - set asynchronous callback function 462 * skcipher_request_set_callback() - set asynchronous callback function
445 * @req: request handle 463 * @req: request handle
diff --git a/include/crypto/xts.h b/include/crypto/xts.h
index 72c09eb56437..ede6b97b24cc 100644
--- a/include/crypto/xts.h
+++ b/include/crypto/xts.h
@@ -2,6 +2,9 @@
2#define _CRYPTO_XTS_H 2#define _CRYPTO_XTS_H
3 3
4#include <crypto/b128ops.h> 4#include <crypto/b128ops.h>
5#include <linux/crypto.h>
6#include <crypto/algapi.h>
7#include <linux/fips.h>
5 8
6struct scatterlist; 9struct scatterlist;
7struct blkcipher_desc; 10struct blkcipher_desc;
@@ -24,4 +27,28 @@ int xts_crypt(struct blkcipher_desc *desc, struct scatterlist *dst,
24 struct scatterlist *src, unsigned int nbytes, 27 struct scatterlist *src, unsigned int nbytes,
25 struct xts_crypt_req *req); 28 struct xts_crypt_req *req);
26 29
30static inline int xts_check_key(struct crypto_tfm *tfm,
31 const u8 *key, unsigned int keylen)
32{
33 u32 *flags = &tfm->crt_flags;
34
35 /*
36 * key consists of keys of equal size concatenated, therefore
37 * the length must be even.
38 */
39 if (keylen % 2) {
40 *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
41 return -EINVAL;
42 }
43
44 /* ensure that the AES and tweak key are not identical */
45 if (fips_enabled &&
46 !crypto_memneq(key, key + (keylen / 2), keylen / 2)) {
47 *flags |= CRYPTO_TFM_RES_WEAK_KEY;
48 return -EINVAL;
49 }
50
51 return 0;
52}
53
27#endif /* _CRYPTO_XTS_H */ 54#endif /* _CRYPTO_XTS_H */
diff --git a/include/linux/ccp.h b/include/linux/ccp.h
index 7f437036baa4..915af3095b39 100644
--- a/include/linux/ccp.h
+++ b/include/linux/ccp.h
@@ -33,6 +33,18 @@ struct ccp_cmd;
33 */ 33 */
34int ccp_present(void); 34int ccp_present(void);
35 35
36#define CCP_VSIZE 16
37#define CCP_VMASK ((unsigned int)((1 << CCP_VSIZE) - 1))
38#define CCP_VERSION(v, r) ((unsigned int)((v << CCP_VSIZE) \
39 | (r & CCP_VMASK)))
40
41/**
42 * ccp_version - get the version of the CCP
43 *
44 * Returns a positive version number, or zero if no CCP
45 */
46unsigned int ccp_version(void);
47
36/** 48/**
37 * ccp_enqueue_cmd - queue an operation for processing by the CCP 49 * ccp_enqueue_cmd - queue an operation for processing by the CCP
38 * 50 *
@@ -65,6 +77,11 @@ static inline int ccp_present(void)
65 return -ENODEV; 77 return -ENODEV;
66} 78}
67 79
80static inline unsigned int ccp_version(void)
81{
82 return 0;
83}
84
68static inline int ccp_enqueue_cmd(struct ccp_cmd *cmd) 85static inline int ccp_enqueue_cmd(struct ccp_cmd *cmd)
69{ 86{
70 return -ENODEV; 87 return -ENODEV;
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index e71cb70a1ac2..99c94899ad0f 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -54,7 +54,6 @@
54#define CRYPTO_ALG_TYPE_AHASH 0x0000000a 54#define CRYPTO_ALG_TYPE_AHASH 0x0000000a
55#define CRYPTO_ALG_TYPE_RNG 0x0000000c 55#define CRYPTO_ALG_TYPE_RNG 0x0000000c
56#define CRYPTO_ALG_TYPE_AKCIPHER 0x0000000d 56#define CRYPTO_ALG_TYPE_AKCIPHER 0x0000000d
57#define CRYPTO_ALG_TYPE_PCOMPRESS 0x0000000f
58 57
59#define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e 58#define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e
60#define CRYPTO_ALG_TYPE_AHASH_MASK 0x0000000c 59#define CRYPTO_ALG_TYPE_AHASH_MASK 0x0000000c
@@ -137,7 +136,6 @@ struct scatterlist;
137struct crypto_ablkcipher; 136struct crypto_ablkcipher;
138struct crypto_async_request; 137struct crypto_async_request;
139struct crypto_blkcipher; 138struct crypto_blkcipher;
140struct crypto_hash;
141struct crypto_tfm; 139struct crypto_tfm;
142struct crypto_type; 140struct crypto_type;
143struct skcipher_givcrypt_request; 141struct skcipher_givcrypt_request;
@@ -187,11 +185,6 @@ struct cipher_desc {
187 void *info; 185 void *info;
188}; 186};
189 187
190struct hash_desc {
191 struct crypto_hash *tfm;
192 u32 flags;
193};
194
195/** 188/**
196 * DOC: Block Cipher Algorithm Definitions 189 * DOC: Block Cipher Algorithm Definitions
197 * 190 *
@@ -519,18 +512,6 @@ struct cipher_tfm {
519 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src); 512 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
520}; 513};
521 514
522struct hash_tfm {
523 int (*init)(struct hash_desc *desc);
524 int (*update)(struct hash_desc *desc,
525 struct scatterlist *sg, unsigned int nsg);
526 int (*final)(struct hash_desc *desc, u8 *out);
527 int (*digest)(struct hash_desc *desc, struct scatterlist *sg,
528 unsigned int nsg, u8 *out);
529 int (*setkey)(struct crypto_hash *tfm, const u8 *key,
530 unsigned int keylen);
531 unsigned int digestsize;
532};
533
534struct compress_tfm { 515struct compress_tfm {
535 int (*cot_compress)(struct crypto_tfm *tfm, 516 int (*cot_compress)(struct crypto_tfm *tfm,
536 const u8 *src, unsigned int slen, 517 const u8 *src, unsigned int slen,
@@ -543,7 +524,6 @@ struct compress_tfm {
543#define crt_ablkcipher crt_u.ablkcipher 524#define crt_ablkcipher crt_u.ablkcipher
544#define crt_blkcipher crt_u.blkcipher 525#define crt_blkcipher crt_u.blkcipher
545#define crt_cipher crt_u.cipher 526#define crt_cipher crt_u.cipher
546#define crt_hash crt_u.hash
547#define crt_compress crt_u.compress 527#define crt_compress crt_u.compress
548 528
549struct crypto_tfm { 529struct crypto_tfm {
@@ -554,7 +534,6 @@ struct crypto_tfm {
554 struct ablkcipher_tfm ablkcipher; 534 struct ablkcipher_tfm ablkcipher;
555 struct blkcipher_tfm blkcipher; 535 struct blkcipher_tfm blkcipher;
556 struct cipher_tfm cipher; 536 struct cipher_tfm cipher;
557 struct hash_tfm hash;
558 struct compress_tfm compress; 537 struct compress_tfm compress;
559 } crt_u; 538 } crt_u;
560 539
@@ -581,10 +560,6 @@ struct crypto_comp {
581 struct crypto_tfm base; 560 struct crypto_tfm base;
582}; 561};
583 562
584struct crypto_hash {
585 struct crypto_tfm base;
586};
587
588enum { 563enum {
589 CRYPTOA_UNSPEC, 564 CRYPTOA_UNSPEC,
590 CRYPTOA_ALG, 565 CRYPTOA_ALG,
@@ -1577,233 +1552,6 @@ static inline void crypto_cipher_decrypt_one(struct crypto_cipher *tfm,
1577 dst, src); 1552 dst, src);
1578} 1553}
1579 1554
1580/**
1581 * DOC: Synchronous Message Digest API
1582 *
1583 * The synchronous message digest API is used with the ciphers of type
1584 * CRYPTO_ALG_TYPE_HASH (listed as type "hash" in /proc/crypto)
1585 */
1586
1587static inline struct crypto_hash *__crypto_hash_cast(struct crypto_tfm *tfm)
1588{
1589 return (struct crypto_hash *)tfm;
1590}
1591
1592static inline struct crypto_hash *crypto_hash_cast(struct crypto_tfm *tfm)
1593{
1594 BUG_ON((crypto_tfm_alg_type(tfm) ^ CRYPTO_ALG_TYPE_HASH) &
1595 CRYPTO_ALG_TYPE_HASH_MASK);
1596 return __crypto_hash_cast(tfm);
1597}
1598
1599/**
1600 * crypto_alloc_hash() - allocate synchronous message digest handle
1601 * @alg_name: is the cra_name / name or cra_driver_name / driver name of the
1602 * message digest cipher
1603 * @type: specifies the type of the cipher
1604 * @mask: specifies the mask for the cipher
1605 *
1606 * Allocate a cipher handle for a message digest. The returned struct
1607 * crypto_hash is the cipher handle that is required for any subsequent
1608 * API invocation for that message digest.
1609 *
1610 * Return: allocated cipher handle in case of success; IS_ERR() is true in case
1611 * of an error, PTR_ERR() returns the error code.
1612 */
1613static inline struct crypto_hash *crypto_alloc_hash(const char *alg_name,
1614 u32 type, u32 mask)
1615{
1616 type &= ~CRYPTO_ALG_TYPE_MASK;
1617 mask &= ~CRYPTO_ALG_TYPE_MASK;
1618 type |= CRYPTO_ALG_TYPE_HASH;
1619 mask |= CRYPTO_ALG_TYPE_HASH_MASK;
1620
1621 return __crypto_hash_cast(crypto_alloc_base(alg_name, type, mask));
1622}
1623
1624static inline struct crypto_tfm *crypto_hash_tfm(struct crypto_hash *tfm)
1625{
1626 return &tfm->base;
1627}
1628
1629/**
1630 * crypto_free_hash() - zeroize and free message digest handle
1631 * @tfm: cipher handle to be freed
1632 */
1633static inline void crypto_free_hash(struct crypto_hash *tfm)
1634{
1635 crypto_free_tfm(crypto_hash_tfm(tfm));
1636}
1637
1638/**
1639 * crypto_has_hash() - Search for the availability of a message digest
1640 * @alg_name: is the cra_name / name or cra_driver_name / driver name of the
1641 * message digest cipher
1642 * @type: specifies the type of the cipher
1643 * @mask: specifies the mask for the cipher
1644 *
1645 * Return: true when the message digest cipher is known to the kernel crypto
1646 * API; false otherwise
1647 */
1648static inline int crypto_has_hash(const char *alg_name, u32 type, u32 mask)
1649{
1650 type &= ~CRYPTO_ALG_TYPE_MASK;
1651 mask &= ~CRYPTO_ALG_TYPE_MASK;
1652 type |= CRYPTO_ALG_TYPE_HASH;
1653 mask |= CRYPTO_ALG_TYPE_HASH_MASK;
1654
1655 return crypto_has_alg(alg_name, type, mask);
1656}
1657
1658static inline struct hash_tfm *crypto_hash_crt(struct crypto_hash *tfm)
1659{
1660 return &crypto_hash_tfm(tfm)->crt_hash;
1661}
1662
1663/**
1664 * crypto_hash_blocksize() - obtain block size for message digest
1665 * @tfm: cipher handle
1666 *
1667 * The block size for the message digest cipher referenced with the cipher
1668 * handle is returned.
1669 *
1670 * Return: block size of cipher
1671 */
1672static inline unsigned int crypto_hash_blocksize(struct crypto_hash *tfm)
1673{
1674 return crypto_tfm_alg_blocksize(crypto_hash_tfm(tfm));
1675}
1676
1677static inline unsigned int crypto_hash_alignmask(struct crypto_hash *tfm)
1678{
1679 return crypto_tfm_alg_alignmask(crypto_hash_tfm(tfm));
1680}
1681
1682/**
1683 * crypto_hash_digestsize() - obtain message digest size
1684 * @tfm: cipher handle
1685 *
1686 * The size for the message digest created by the message digest cipher
1687 * referenced with the cipher handle is returned.
1688 *
1689 * Return: message digest size
1690 */
1691static inline unsigned int crypto_hash_digestsize(struct crypto_hash *tfm)
1692{
1693 return crypto_hash_crt(tfm)->digestsize;
1694}
1695
1696static inline u32 crypto_hash_get_flags(struct crypto_hash *tfm)
1697{
1698 return crypto_tfm_get_flags(crypto_hash_tfm(tfm));
1699}
1700
1701static inline void crypto_hash_set_flags(struct crypto_hash *tfm, u32 flags)
1702{
1703 crypto_tfm_set_flags(crypto_hash_tfm(tfm), flags);
1704}
1705
1706static inline void crypto_hash_clear_flags(struct crypto_hash *tfm, u32 flags)
1707{
1708 crypto_tfm_clear_flags(crypto_hash_tfm(tfm), flags);
1709}
1710
1711/**
1712 * crypto_hash_init() - (re)initialize message digest handle
1713 * @desc: cipher request handle that to be filled by caller --
1714 * desc.tfm is filled with the hash cipher handle;
1715 * desc.flags is filled with either CRYPTO_TFM_REQ_MAY_SLEEP or 0.
1716 *
1717 * The call (re-)initializes the message digest referenced by the hash cipher
1718 * request handle. Any potentially existing state created by previous
1719 * operations is discarded.
1720 *
1721 * Return: 0 if the message digest initialization was successful; < 0 if an
1722 * error occurred
1723 */
1724static inline int crypto_hash_init(struct hash_desc *desc)
1725{
1726 return crypto_hash_crt(desc->tfm)->init(desc);
1727}
1728
1729/**
1730 * crypto_hash_update() - add data to message digest for processing
1731 * @desc: cipher request handle
1732 * @sg: scatter / gather list pointing to the data to be added to the message
1733 * digest
1734 * @nbytes: number of bytes to be processed from @sg
1735 *
1736 * Updates the message digest state of the cipher handle pointed to by the
1737 * hash cipher request handle with the input data pointed to by the
1738 * scatter/gather list.
1739 *
1740 * Return: 0 if the message digest update was successful; < 0 if an error
1741 * occurred
1742 */
1743static inline int crypto_hash_update(struct hash_desc *desc,
1744 struct scatterlist *sg,
1745 unsigned int nbytes)
1746{
1747 return crypto_hash_crt(desc->tfm)->update(desc, sg, nbytes);
1748}
1749
1750/**
1751 * crypto_hash_final() - calculate message digest
1752 * @desc: cipher request handle
1753 * @out: message digest output buffer -- The caller must ensure that the out
1754 * buffer has a sufficient size (e.g. by using the crypto_hash_digestsize
1755 * function).
1756 *
1757 * Finalize the message digest operation and create the message digest
1758 * based on all data added to the cipher handle. The message digest is placed
1759 * into the output buffer.
1760 *
1761 * Return: 0 if the message digest creation was successful; < 0 if an error
1762 * occurred
1763 */
1764static inline int crypto_hash_final(struct hash_desc *desc, u8 *out)
1765{
1766 return crypto_hash_crt(desc->tfm)->final(desc, out);
1767}
1768
1769/**
1770 * crypto_hash_digest() - calculate message digest for a buffer
1771 * @desc: see crypto_hash_final()
1772 * @sg: see crypto_hash_update()
1773 * @nbytes: see crypto_hash_update()
1774 * @out: see crypto_hash_final()
1775 *
1776 * This function is a "short-hand" for the function calls of crypto_hash_init,
1777 * crypto_hash_update and crypto_hash_final. The parameters have the same
1778 * meaning as discussed for those separate three functions.
1779 *
1780 * Return: 0 if the message digest creation was successful; < 0 if an error
1781 * occurred
1782 */
1783static inline int crypto_hash_digest(struct hash_desc *desc,
1784 struct scatterlist *sg,
1785 unsigned int nbytes, u8 *out)
1786{
1787 return crypto_hash_crt(desc->tfm)->digest(desc, sg, nbytes, out);
1788}
1789
1790/**
1791 * crypto_hash_setkey() - set key for message digest
1792 * @hash: cipher handle
1793 * @key: buffer holding the key
1794 * @keylen: length of the key in bytes
1795 *
1796 * The caller provided key is set for the message digest cipher. The cipher
1797 * handle must point to a keyed hash in order for this function to succeed.
1798 *
1799 * Return: 0 if the setting of the key was successful; < 0 if an error occurred
1800 */
1801static inline int crypto_hash_setkey(struct crypto_hash *hash,
1802 const u8 *key, unsigned int keylen)
1803{
1804 return crypto_hash_crt(hash)->setkey(hash, key, keylen);
1805}
1806
1807static inline struct crypto_comp *__crypto_comp_cast(struct crypto_tfm *tfm) 1555static inline struct crypto_comp *__crypto_comp_cast(struct crypto_tfm *tfm)
1808{ 1556{
1809 return (struct crypto_comp *)tfm; 1557 return (struct crypto_comp *)tfm;
diff --git a/include/linux/sunrpc/gss_krb5.h b/include/linux/sunrpc/gss_krb5.h
index df02a4188487..7df625d41e35 100644
--- a/include/linux/sunrpc/gss_krb5.h
+++ b/include/linux/sunrpc/gss_krb5.h
@@ -36,7 +36,7 @@
36 * 36 *
37 */ 37 */
38 38
39#include <linux/crypto.h> 39#include <crypto/skcipher.h>
40#include <linux/sunrpc/auth_gss.h> 40#include <linux/sunrpc/auth_gss.h>
41#include <linux/sunrpc/gss_err.h> 41#include <linux/sunrpc/gss_err.h>
42#include <linux/sunrpc/gss_asn1.h> 42#include <linux/sunrpc/gss_asn1.h>
@@ -71,10 +71,10 @@ struct gss_krb5_enctype {
71 const u32 keyed_cksum; /* is it a keyed cksum? */ 71 const u32 keyed_cksum; /* is it a keyed cksum? */
72 const u32 keybytes; /* raw key len, in bytes */ 72 const u32 keybytes; /* raw key len, in bytes */
73 const u32 keylength; /* final key len, in bytes */ 73 const u32 keylength; /* final key len, in bytes */
74 u32 (*encrypt) (struct crypto_blkcipher *tfm, 74 u32 (*encrypt) (struct crypto_skcipher *tfm,
75 void *iv, void *in, void *out, 75 void *iv, void *in, void *out,
76 int length); /* encryption function */ 76 int length); /* encryption function */
77 u32 (*decrypt) (struct crypto_blkcipher *tfm, 77 u32 (*decrypt) (struct crypto_skcipher *tfm,
78 void *iv, void *in, void *out, 78 void *iv, void *in, void *out,
79 int length); /* decryption function */ 79 int length); /* decryption function */
80 u32 (*mk_key) (const struct gss_krb5_enctype *gk5e, 80 u32 (*mk_key) (const struct gss_krb5_enctype *gk5e,
@@ -98,12 +98,12 @@ struct krb5_ctx {
98 u32 enctype; 98 u32 enctype;
99 u32 flags; 99 u32 flags;
100 const struct gss_krb5_enctype *gk5e; /* enctype-specific info */ 100 const struct gss_krb5_enctype *gk5e; /* enctype-specific info */
101 struct crypto_blkcipher *enc; 101 struct crypto_skcipher *enc;
102 struct crypto_blkcipher *seq; 102 struct crypto_skcipher *seq;
103 struct crypto_blkcipher *acceptor_enc; 103 struct crypto_skcipher *acceptor_enc;
104 struct crypto_blkcipher *initiator_enc; 104 struct crypto_skcipher *initiator_enc;
105 struct crypto_blkcipher *acceptor_enc_aux; 105 struct crypto_skcipher *acceptor_enc_aux;
106 struct crypto_blkcipher *initiator_enc_aux; 106 struct crypto_skcipher *initiator_enc_aux;
107 u8 Ksess[GSS_KRB5_MAX_KEYLEN]; /* session key */ 107 u8 Ksess[GSS_KRB5_MAX_KEYLEN]; /* session key */
108 u8 cksum[GSS_KRB5_MAX_KEYLEN]; 108 u8 cksum[GSS_KRB5_MAX_KEYLEN];
109 s32 endtime; 109 s32 endtime;
@@ -262,24 +262,24 @@ gss_unwrap_kerberos(struct gss_ctx *ctx_id, int offset,
262 262
263 263
264u32 264u32
265krb5_encrypt(struct crypto_blkcipher *key, 265krb5_encrypt(struct crypto_skcipher *key,
266 void *iv, void *in, void *out, int length); 266 void *iv, void *in, void *out, int length);
267 267
268u32 268u32
269krb5_decrypt(struct crypto_blkcipher *key, 269krb5_decrypt(struct crypto_skcipher *key,
270 void *iv, void *in, void *out, int length); 270 void *iv, void *in, void *out, int length);
271 271
272int 272int
273gss_encrypt_xdr_buf(struct crypto_blkcipher *tfm, struct xdr_buf *outbuf, 273gss_encrypt_xdr_buf(struct crypto_skcipher *tfm, struct xdr_buf *outbuf,
274 int offset, struct page **pages); 274 int offset, struct page **pages);
275 275
276int 276int
277gss_decrypt_xdr_buf(struct crypto_blkcipher *tfm, struct xdr_buf *inbuf, 277gss_decrypt_xdr_buf(struct crypto_skcipher *tfm, struct xdr_buf *inbuf,
278 int offset); 278 int offset);
279 279
280s32 280s32
281krb5_make_seq_num(struct krb5_ctx *kctx, 281krb5_make_seq_num(struct krb5_ctx *kctx,
282 struct crypto_blkcipher *key, 282 struct crypto_skcipher *key,
283 int direction, 283 int direction,
284 u32 seqnum, unsigned char *cksum, unsigned char *buf); 284 u32 seqnum, unsigned char *cksum, unsigned char *buf);
285 285
@@ -320,12 +320,12 @@ gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset,
320 320
321int 321int
322krb5_rc4_setup_seq_key(struct krb5_ctx *kctx, 322krb5_rc4_setup_seq_key(struct krb5_ctx *kctx,
323 struct crypto_blkcipher *cipher, 323 struct crypto_skcipher *cipher,
324 unsigned char *cksum); 324 unsigned char *cksum);
325 325
326int 326int
327krb5_rc4_setup_enc_key(struct krb5_ctx *kctx, 327krb5_rc4_setup_enc_key(struct krb5_ctx *kctx,
328 struct crypto_blkcipher *cipher, 328 struct crypto_skcipher *cipher,
329 s32 seqnum); 329 s32 seqnum);
330void 330void
331gss_krb5_make_confounder(char *p, u32 conflen); 331gss_krb5_make_confounder(char *p, u32 conflen);
diff --git a/include/net/sctp/auth.h b/include/net/sctp/auth.h
index f2d58aa37a6f..9b9fb122b31f 100644
--- a/include/net/sctp/auth.h
+++ b/include/net/sctp/auth.h
@@ -31,12 +31,12 @@
31#define __sctp_auth_h__ 31#define __sctp_auth_h__
32 32
33#include <linux/list.h> 33#include <linux/list.h>
34#include <linux/crypto.h>
35 34
36struct sctp_endpoint; 35struct sctp_endpoint;
37struct sctp_association; 36struct sctp_association;
38struct sctp_authkey; 37struct sctp_authkey;
39struct sctp_hmacalgo; 38struct sctp_hmacalgo;
39struct crypto_shash;
40 40
41/* 41/*
42 * Define a generic struct that will hold all the info 42 * Define a generic struct that will hold all the info
@@ -90,7 +90,7 @@ int sctp_auth_asoc_copy_shkeys(const struct sctp_endpoint *ep,
90 struct sctp_association *asoc, 90 struct sctp_association *asoc,
91 gfp_t gfp); 91 gfp_t gfp);
92int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp); 92int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp);
93void sctp_auth_destroy_hmacs(struct crypto_hash *auth_hmacs[]); 93void sctp_auth_destroy_hmacs(struct crypto_shash *auth_hmacs[]);
94struct sctp_hmac *sctp_auth_get_hmac(__u16 hmac_id); 94struct sctp_hmac *sctp_auth_get_hmac(__u16 hmac_id);
95struct sctp_hmac *sctp_auth_asoc_get_hmac(const struct sctp_association *asoc); 95struct sctp_hmac *sctp_auth_asoc_get_hmac(const struct sctp_association *asoc);
96void sctp_auth_asoc_set_default_hmac(struct sctp_association *asoc, 96void sctp_auth_asoc_set_default_hmac(struct sctp_association *asoc,
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 205630bb5010..5a57409da37b 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -82,7 +82,7 @@ struct sctp_bind_addr;
82struct sctp_ulpq; 82struct sctp_ulpq;
83struct sctp_ep_common; 83struct sctp_ep_common;
84struct sctp_ssnmap; 84struct sctp_ssnmap;
85struct crypto_hash; 85struct crypto_shash;
86 86
87 87
88#include <net/sctp/tsnmap.h> 88#include <net/sctp/tsnmap.h>
@@ -166,7 +166,7 @@ struct sctp_sock {
166 struct sctp_pf *pf; 166 struct sctp_pf *pf;
167 167
168 /* Access to HMAC transform. */ 168 /* Access to HMAC transform. */
169 struct crypto_hash *hmac; 169 struct crypto_shash *hmac;
170 char *sctp_hmac_alg; 170 char *sctp_hmac_alg;
171 171
172 /* What is our base endpointer? */ 172 /* What is our base endpointer? */
@@ -1234,7 +1234,7 @@ struct sctp_endpoint {
1234 /* SCTP AUTH: array of the HMACs that will be allocated 1234 /* SCTP AUTH: array of the HMACs that will be allocated
1235 * we need this per association so that we don't serialize 1235 * we need this per association so that we don't serialize
1236 */ 1236 */
1237 struct crypto_hash **auth_hmacs; 1237 struct crypto_shash **auth_hmacs;
1238 1238
1239 /* SCTP-AUTH: hmacs for the endpoint encoded into parameter */ 1239 /* SCTP-AUTH: hmacs for the endpoint encoded into parameter */
1240 struct sctp_hmac_algo_param *auth_hmacs_list; 1240 struct sctp_hmac_algo_param *auth_hmacs_list;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index ae6468f5c9f3..b04bc989ad6c 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -27,7 +27,6 @@
27#include <linux/cache.h> 27#include <linux/cache.h>
28#include <linux/percpu.h> 28#include <linux/percpu.h>
29#include <linux/skbuff.h> 29#include <linux/skbuff.h>
30#include <linux/crypto.h>
31#include <linux/cryptohash.h> 30#include <linux/cryptohash.h>
32#include <linux/kref.h> 31#include <linux/kref.h>
33#include <linux/ktime.h> 32#include <linux/ktime.h>
@@ -1325,9 +1324,6 @@ static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp)
1325 tp->retransmit_skb_hint = NULL; 1324 tp->retransmit_skb_hint = NULL;
1326} 1325}
1327 1326
1328/* MD5 Signature */
1329struct crypto_hash;
1330
1331union tcp_md5_addr { 1327union tcp_md5_addr {
1332 struct in_addr a4; 1328 struct in_addr a4;
1333#if IS_ENABLED(CONFIG_IPV6) 1329#if IS_ENABLED(CONFIG_IPV6)
@@ -1376,7 +1372,7 @@ union tcp_md5sum_block {
1376 1372
1377/* - pool: digest algorithm, hash description and scratch buffer */ 1373/* - pool: digest algorithm, hash description and scratch buffer */
1378struct tcp_md5sig_pool { 1374struct tcp_md5sig_pool {
1379 struct hash_desc md5_desc; 1375 struct ahash_request *md5_req;
1380 union tcp_md5sum_block md5_blk; 1376 union tcp_md5sum_block md5_blk;
1381}; 1377};
1382 1378
diff --git a/include/scsi/libiscsi_tcp.h b/include/scsi/libiscsi_tcp.h
index 2a7aa75dd009..30520d5ee3d1 100644
--- a/include/scsi/libiscsi_tcp.h
+++ b/include/scsi/libiscsi_tcp.h
@@ -26,7 +26,7 @@
26struct iscsi_tcp_conn; 26struct iscsi_tcp_conn;
27struct iscsi_segment; 27struct iscsi_segment;
28struct sk_buff; 28struct sk_buff;
29struct hash_desc; 29struct ahash_request;
30 30
31typedef int iscsi_segment_done_fn_t(struct iscsi_tcp_conn *, 31typedef int iscsi_segment_done_fn_t(struct iscsi_tcp_conn *,
32 struct iscsi_segment *); 32 struct iscsi_segment *);
@@ -38,7 +38,7 @@ struct iscsi_segment {
38 unsigned int total_size; 38 unsigned int total_size;
39 unsigned int total_copied; 39 unsigned int total_copied;
40 40
41 struct hash_desc *hash; 41 struct ahash_request *hash;
42 unsigned char padbuf[ISCSI_PAD_LEN]; 42 unsigned char padbuf[ISCSI_PAD_LEN];
43 unsigned char recv_digest[ISCSI_DIGEST_SIZE]; 43 unsigned char recv_digest[ISCSI_DIGEST_SIZE];
44 unsigned char digest[ISCSI_DIGEST_SIZE]; 44 unsigned char digest[ISCSI_DIGEST_SIZE];
@@ -73,7 +73,7 @@ struct iscsi_tcp_conn {
73 /* control data */ 73 /* control data */
74 struct iscsi_tcp_recv in; /* TCP receive context */ 74 struct iscsi_tcp_recv in; /* TCP receive context */
75 /* CRC32C (Rx) LLD should set this is they do not offload */ 75 /* CRC32C (Rx) LLD should set this is they do not offload */
76 struct hash_desc *rx_hash; 76 struct ahash_request *rx_hash;
77}; 77};
78 78
79struct iscsi_tcp_task { 79struct iscsi_tcp_task {
@@ -111,15 +111,16 @@ extern void iscsi_tcp_segment_unmap(struct iscsi_segment *segment);
111extern void iscsi_segment_init_linear(struct iscsi_segment *segment, 111extern void iscsi_segment_init_linear(struct iscsi_segment *segment,
112 void *data, size_t size, 112 void *data, size_t size,
113 iscsi_segment_done_fn_t *done, 113 iscsi_segment_done_fn_t *done,
114 struct hash_desc *hash); 114 struct ahash_request *hash);
115extern int 115extern int
116iscsi_segment_seek_sg(struct iscsi_segment *segment, 116iscsi_segment_seek_sg(struct iscsi_segment *segment,
117 struct scatterlist *sg_list, unsigned int sg_count, 117 struct scatterlist *sg_list, unsigned int sg_count,
118 unsigned int offset, size_t size, 118 unsigned int offset, size_t size,
119 iscsi_segment_done_fn_t *done, struct hash_desc *hash); 119 iscsi_segment_done_fn_t *done,
120 struct ahash_request *hash);
120 121
121/* digest helpers */ 122/* digest helpers */
122extern void iscsi_tcp_dgst_header(struct hash_desc *hash, const void *hdr, 123extern void iscsi_tcp_dgst_header(struct ahash_request *hash, const void *hdr,
123 size_t hdrlen, 124 size_t hdrlen,
124 unsigned char digest[ISCSI_DIGEST_SIZE]); 125 unsigned char digest[ISCSI_DIGEST_SIZE]);
125extern struct iscsi_cls_conn * 126extern struct iscsi_cls_conn *
diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h
index 373d3342002b..c3371fa548cb 100644
--- a/include/target/iscsi/iscsi_target_core.h
+++ b/include/target/iscsi/iscsi_target_core.h
@@ -570,8 +570,8 @@ struct iscsi_conn {
570 spinlock_t response_queue_lock; 570 spinlock_t response_queue_lock;
571 spinlock_t state_lock; 571 spinlock_t state_lock;
572 /* libcrypto RX and TX contexts for crc32c */ 572 /* libcrypto RX and TX contexts for crc32c */
573 struct hash_desc conn_rx_hash; 573 struct ahash_request *conn_rx_hash;
574 struct hash_desc conn_tx_hash; 574 struct ahash_request *conn_tx_hash;
575 /* Used for scheduling TX and RX connection kthreads */ 575 /* Used for scheduling TX and RX connection kthreads */
576 cpumask_var_t conn_cpumask; 576 cpumask_var_t conn_cpumask;
577 unsigned int conn_rx_reset_cpumask:1; 577 unsigned int conn_rx_reset_cpumask:1;