Blame view

include/crypto/hash.h 31.5 KB
18e33e6d5   Herbert Xu   crypto: hash - Mo...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  /*
   * Hash: Hash algorithms under the crypto API
   * 
   * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
   *
   * This program is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License as published by the Free
   * Software Foundation; either version 2 of the License, or (at your option) 
   * any later version.
   *
   */
  
  #ifndef _CRYPTO_HASH_H
  #define _CRYPTO_HASH_H
  
  #include <linux/crypto.h>
e67ffe0af   Herbert Xu   crypto: hash - Ad...
17
  #include <linux/string.h>
18e33e6d5   Herbert Xu   crypto: hash - Mo...
18

88056ec34   Herbert Xu   crypto: ahash - C...
19
  struct crypto_ahash;
5d8c723f6   Stephan Mueller   crypto: doc - has...
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  /**
   * DOC: Message Digest Algorithm Definitions
   *
   * These data structures define modular message digest algorithm
   * implementations, managed via crypto_register_ahash(),
   * crypto_register_shash(), crypto_unregister_ahash() and
   * crypto_unregister_shash().
   */
  
  /**
   * struct hash_alg_common - define properties of message digest
   * @digestsize: Size of the result of the transformation. A buffer of this size
   *	        must be available to the @final and @finup calls, so they can
   *	        store the resulting hash into it. For various predefined sizes,
   *	        search include/crypto/ using
   *	        git grep _DIGEST_SIZE include/crypto.
   * @statesize: Size of the block for partial state of the transformation. A
   *	       buffer of this size must be passed to the @export function as it
   *	       will save the partial state of the transformation into it. On the
   *	       other side, the @import function will load the state from a
   *	       buffer of this size as well.
52744af3a   Stephan Mueller   crypto: doc - doc...
41
42
43
44
   * @base: Start of data structure of cipher algorithm. The common data
   *	  structure of crypto_alg contains information common to all ciphers.
   *	  The hash_alg_common data structure now adds the hash-specific
   *	  information.
5d8c723f6   Stephan Mueller   crypto: doc - has...
45
   */
88056ec34   Herbert Xu   crypto: ahash - C...
46
47
48
49
50
51
52
53
54
55
56
57
58
  struct hash_alg_common {
  	unsigned int digestsize;
  	unsigned int statesize;
  
  	struct crypto_alg base;
  };
  
  struct ahash_request {
  	struct crypto_async_request base;
  
  	unsigned int nbytes;
  	struct scatterlist *src;
  	u8 *result;
66f6ce5e5   Herbert Xu   crypto: ahash - A...
59
60
  	/* This field may only be used by the ahash API code. */
  	void *priv;
88056ec34   Herbert Xu   crypto: ahash - C...
61
62
  	void *__ctx[] CRYPTO_MINALIGN_ATTR;
  };
d4421c54c   Herbert Xu   crypto: hash - Ad...
63
64
65
66
  #define AHASH_REQUEST_ON_STACK(name, ahash) \
  	char __##name##_desc[sizeof(struct ahash_request) + \
  		crypto_ahash_reqsize(ahash)] CRYPTO_MINALIGN_ATTR; \
  	struct ahash_request *name = (void *)__##name##_desc
5d8c723f6   Stephan Mueller   crypto: doc - has...
67
68
  /**
   * struct ahash_alg - asynchronous message digest definition
b40fa82cd   tcharding   crypto: doc - cle...
69
   * @init: **[mandatory]** Initialize the transformation context. Intended only to initialize the
12f7c14aa   Masanari Iida   crypto: doc - Fix...
70
   *	  state of the HASH transformation at the beginning. This shall fill in
5d8c723f6   Stephan Mueller   crypto: doc - has...
71
   *	  the internal structures used during the entire duration of the whole
3d053d53f   Kamil Konieczny   crypto: hash - Pr...
72
73
   *	  transformation. No data processing happens at this point. Driver code
   *	  implementation must not use req->result.
b40fa82cd   tcharding   crypto: doc - cle...
74
   * @update: **[mandatory]** Push a chunk of data into the driver for transformation. This
5d8c723f6   Stephan Mueller   crypto: doc - has...
75
76
77
78
79
80
81
   *	   function actually pushes blocks of data from upper layers into the
   *	   driver, which then passes those to the hardware as seen fit. This
   *	   function must not finalize the HASH transformation by calculating the
   *	   final message digest as this only adds more data into the
   *	   transformation. This function shall not modify the transformation
   *	   context, as this function may be called in parallel with the same
   *	   transformation object. Data processing can happen synchronously
3d053d53f   Kamil Konieczny   crypto: hash - Pr...
82
83
   *	   [SHASH] or asynchronously [AHASH] at this point. Driver must not use
   *	   req->result.
b40fa82cd   tcharding   crypto: doc - cle...
84
   * @final: **[mandatory]** Retrieve result from the driver. This function finalizes the
5d8c723f6   Stephan Mueller   crypto: doc - has...
85
86
   *	   transformation and retrieves the resulting hash from the driver and
   *	   pushes it back to upper layers. No data processing happens at this
560b1a82e   Kamil Konieczny   crypto: doc - cla...
87
88
   *	   point unless hardware requires it to finish the transformation
   *	   (then the data buffered by the device driver is processed).
b40fa82cd   tcharding   crypto: doc - cle...
89
   * @finup: **[optional]** Combination of @update and @final. This function is effectively a
5d8c723f6   Stephan Mueller   crypto: doc - has...
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
   *	   combination of @update and @final calls issued in sequence. As some
   *	   hardware cannot do @update and @final separately, this callback was
   *	   added to allow such hardware to be used at least by IPsec. Data
   *	   processing can happen synchronously [SHASH] or asynchronously [AHASH]
   *	   at this point.
   * @digest: Combination of @init and @update and @final. This function
   *	    effectively behaves as the entire chain of operations, @init,
   *	    @update and @final issued in sequence. Just like @finup, this was
   *	    added for hardware which cannot do even the @finup, but can only do
   *	    the whole transformation in one run. Data processing can happen
   *	    synchronously [SHASH] or asynchronously [AHASH] at this point.
   * @setkey: Set optional key used by the hashing algorithm. Intended to push
   *	    optional key used by the hashing algorithm from upper layers into
   *	    the driver. This function can store the key in the transformation
   *	    context or can outright program it into the hardware. In the former
   *	    case, one must be careful to program the key into the hardware at
   *	    appropriate time and one must be careful that .setkey() can be
   *	    called multiple times during the existence of the transformation
   *	    object. Not  all hashing algorithms do implement this function as it
   *	    is only needed for keyed message digests. SHAx/MDx/CRCx do NOT
   *	    implement this function. HMAC(MDx)/HMAC(SHAx)/CMAC(AES) do implement
   *	    this function. This function must be called before any other of the
   *	    @init, @update, @final, @finup, @digest is called. No data
   *	    processing happens at this point.
   * @export: Export partial state of the transformation. This function dumps the
   *	    entire state of the ongoing transformation into a provided block of
   *	    data so it can be @import 'ed back later on. This is useful in case
   *	    you want to save partial result of the transformation after
   *	    processing certain amount of data and reload this partial result
   *	    multiple times later on for multiple re-use. No data processing
3d053d53f   Kamil Konieczny   crypto: hash - Pr...
120
   *	    happens at this point. Driver must not use req->result.
5d8c723f6   Stephan Mueller   crypto: doc - has...
121
122
123
   * @import: Import partial state of the transformation. This function loads the
   *	    entire state of the ongoing transformation from a provided block of
   *	    data so the transformation can continue from this point onward. No
3d053d53f   Kamil Konieczny   crypto: hash - Pr...
124
125
   *	    data processing happens at this point. Driver must not use
   *	    req->result.
52744af3a   Stephan Mueller   crypto: doc - doc...
126
   * @halg: see struct hash_alg_common
5d8c723f6   Stephan Mueller   crypto: doc - has...
127
   */
88056ec34   Herbert Xu   crypto: ahash - C...
128
129
130
131
132
133
134
135
136
137
138
139
140
  struct ahash_alg {
  	int (*init)(struct ahash_request *req);
  	int (*update)(struct ahash_request *req);
  	int (*final)(struct ahash_request *req);
  	int (*finup)(struct ahash_request *req);
  	int (*digest)(struct ahash_request *req);
  	int (*export)(struct ahash_request *req, void *out);
  	int (*import)(struct ahash_request *req, const void *in);
  	int (*setkey)(struct crypto_ahash *tfm, const u8 *key,
  		      unsigned int keylen);
  
  	struct hash_alg_common halg;
  };
7b5a080b3   Herbert Xu   crypto: hash - Ad...
141
142
143
144
145
146
  struct shash_desc {
  	struct crypto_shash *tfm;
  	u32 flags;
  
  	void *__ctx[] CRYPTO_MINALIGN_ATTR;
  };
a0a77af14   Behan Webster   crypto: LLVMLinux...
147
148
149
150
  #define SHASH_DESC_ON_STACK(shash, ctx)				  \
  	char __##shash##_desc[sizeof(struct shash_desc) +	  \
  		crypto_shash_descsize(ctx)] CRYPTO_MINALIGN_ATTR; \
  	struct shash_desc *shash = (struct shash_desc *)__##shash##_desc
5d8c723f6   Stephan Mueller   crypto: doc - has...
151
152
153
154
155
156
157
158
159
160
161
162
  /**
   * struct shash_alg - synchronous message digest definition
   * @init: see struct ahash_alg
   * @update: see struct ahash_alg
   * @final: see struct ahash_alg
   * @finup: see struct ahash_alg
   * @digest: see struct ahash_alg
   * @export: see struct ahash_alg
   * @import: see struct ahash_alg
   * @setkey: see struct ahash_alg
   * @digestsize: see struct ahash_alg
   * @statesize: see struct ahash_alg
52744af3a   Stephan Mueller   crypto: doc - doc...
163
   * @descsize: Size of the operational state for the message digest. This state
5d8c723f6   Stephan Mueller   crypto: doc - has...
164
165
166
167
   * 	      size is the memory size that needs to be allocated for
   *	      shash_desc.__ctx
   * @base: internally used
   */
7b5a080b3   Herbert Xu   crypto: hash - Ad...
168
169
170
171
172
173
174
175
176
  struct shash_alg {
  	int (*init)(struct shash_desc *desc);
  	int (*update)(struct shash_desc *desc, const u8 *data,
  		      unsigned int len);
  	int (*final)(struct shash_desc *desc, u8 *out);
  	int (*finup)(struct shash_desc *desc, const u8 *data,
  		     unsigned int len, u8 *out);
  	int (*digest)(struct shash_desc *desc, const u8 *data,
  		      unsigned int len, u8 *out);
99d27e1c5   Herbert Xu   crypto: shash - E...
177
178
  	int (*export)(struct shash_desc *desc, void *out);
  	int (*import)(struct shash_desc *desc, const void *in);
7b5a080b3   Herbert Xu   crypto: hash - Ad...
179
180
181
182
  	int (*setkey)(struct crypto_shash *tfm, const u8 *key,
  		      unsigned int keylen);
  
  	unsigned int descsize;
88056ec34   Herbert Xu   crypto: ahash - C...
183
184
  
  	/* These fields must match hash_alg_common. */
fa6496647   Herbert Xu   crypto: shash - F...
185
186
  	unsigned int digestsize
  		__attribute__ ((aligned(__alignof__(struct hash_alg_common))));
99d27e1c5   Herbert Xu   crypto: shash - E...
187
  	unsigned int statesize;
7b5a080b3   Herbert Xu   crypto: hash - Ad...
188
189
190
  
  	struct crypto_alg base;
  };
18e33e6d5   Herbert Xu   crypto: hash - Mo...
191
  struct crypto_ahash {
88056ec34   Herbert Xu   crypto: ahash - C...
192
193
194
195
196
197
198
199
200
  	int (*init)(struct ahash_request *req);
  	int (*update)(struct ahash_request *req);
  	int (*final)(struct ahash_request *req);
  	int (*finup)(struct ahash_request *req);
  	int (*digest)(struct ahash_request *req);
  	int (*export)(struct ahash_request *req, void *out);
  	int (*import)(struct ahash_request *req, const void *in);
  	int (*setkey)(struct crypto_ahash *tfm, const u8 *key,
  		      unsigned int keylen);
88056ec34   Herbert Xu   crypto: ahash - C...
201
  	unsigned int reqsize;
18e33e6d5   Herbert Xu   crypto: hash - Mo...
202
203
  	struct crypto_tfm base;
  };
7b5a080b3   Herbert Xu   crypto: hash - Ad...
204
  struct crypto_shash {
113adefc7   Herbert Xu   crypto: shash - M...
205
  	unsigned int descsize;
7b5a080b3   Herbert Xu   crypto: hash - Ad...
206
207
  	struct crypto_tfm base;
  };
90240ffb1   Stephan Mueller   crypto: doc - AHA...
208
209
210
211
212
213
214
215
216
  /**
   * DOC: Asynchronous Message Digest API
   *
   * The asynchronous message digest API is used with the ciphers of type
   * CRYPTO_ALG_TYPE_AHASH (listed as type "ahash" in /proc/crypto)
   *
   * The asynchronous cipher operation discussion provided for the
   * CRYPTO_ALG_TYPE_ABLKCIPHER API applies here as well.
   */
18e33e6d5   Herbert Xu   crypto: hash - Mo...
217
218
  static inline struct crypto_ahash *__crypto_ahash_cast(struct crypto_tfm *tfm)
  {
88056ec34   Herbert Xu   crypto: ahash - C...
219
  	return container_of(tfm, struct crypto_ahash, base);
18e33e6d5   Herbert Xu   crypto: hash - Mo...
220
  }
90240ffb1   Stephan Mueller   crypto: doc - AHA...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
  /**
   * crypto_alloc_ahash() - allocate ahash cipher handle
   * @alg_name: is the cra_name / name or cra_driver_name / driver name of the
   *	      ahash cipher
   * @type: specifies the type of the cipher
   * @mask: specifies the mask for the cipher
   *
   * Allocate a cipher handle for an ahash. The returned struct
   * crypto_ahash is the cipher handle that is required for any subsequent
   * API invocation for that ahash.
   *
   * Return: allocated cipher handle in case of success; IS_ERR() is true in case
   *	   of an error, PTR_ERR() returns the error code.
   */
88056ec34   Herbert Xu   crypto: ahash - C...
235
236
  struct crypto_ahash *crypto_alloc_ahash(const char *alg_name, u32 type,
  					u32 mask);
18e33e6d5   Herbert Xu   crypto: hash - Mo...
237
238
239
240
241
  
  static inline struct crypto_tfm *crypto_ahash_tfm(struct crypto_ahash *tfm)
  {
  	return &tfm->base;
  }
90240ffb1   Stephan Mueller   crypto: doc - AHA...
242
243
244
245
  /**
   * crypto_free_ahash() - zeroize and free the ahash handle
   * @tfm: cipher handle to be freed
   */
18e33e6d5   Herbert Xu   crypto: hash - Mo...
246
247
  static inline void crypto_free_ahash(struct crypto_ahash *tfm)
  {
88056ec34   Herbert Xu   crypto: ahash - C...
248
  	crypto_destroy_tfm(tfm, crypto_ahash_tfm(tfm));
18e33e6d5   Herbert Xu   crypto: hash - Mo...
249
  }
8d18e34c1   Herbert Xu   crypto: hash - Ad...
250
251
252
253
254
255
256
257
258
259
260
  /**
   * crypto_has_ahash() - Search for the availability of an ahash.
   * @alg_name: is the cra_name / name or cra_driver_name / driver name of the
   *	      ahash
   * @type: specifies the type of the ahash
   * @mask: specifies the mask for the ahash
   *
   * Return: true when the ahash is known to the kernel crypto API; false
   *	   otherwise
   */
  int crypto_has_ahash(const char *alg_name, u32 type, u32 mask);
d12481bc5   Herbert Xu   crypto: hash - Ad...
261
262
263
264
265
266
267
268
269
  static inline const char *crypto_ahash_alg_name(struct crypto_ahash *tfm)
  {
  	return crypto_tfm_alg_name(crypto_ahash_tfm(tfm));
  }
  
  static inline const char *crypto_ahash_driver_name(struct crypto_ahash *tfm)
  {
  	return crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm));
  }
18e33e6d5   Herbert Xu   crypto: hash - Mo...
270
271
272
273
274
  static inline unsigned int crypto_ahash_alignmask(
  	struct crypto_ahash *tfm)
  {
  	return crypto_tfm_alg_alignmask(crypto_ahash_tfm(tfm));
  }
524e56c31   Herbert Xu   crypto: ahash - A...
275
276
277
278
279
280
281
282
283
284
285
286
287
  /**
   * crypto_ahash_blocksize() - obtain block size for cipher
   * @tfm: cipher handle
   *
   * The block size for the message digest cipher referenced with the cipher
   * handle is returned.
   *
   * Return: block size of cipher
   */
  static inline unsigned int crypto_ahash_blocksize(struct crypto_ahash *tfm)
  {
  	return crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm));
  }
88056ec34   Herbert Xu   crypto: ahash - C...
288
289
290
291
292
293
294
295
  static inline struct hash_alg_common *__crypto_hash_alg_common(
  	struct crypto_alg *alg)
  {
  	return container_of(alg, struct hash_alg_common, base);
  }
  
  static inline struct hash_alg_common *crypto_hash_alg_common(
  	struct crypto_ahash *tfm)
18e33e6d5   Herbert Xu   crypto: hash - Mo...
296
  {
88056ec34   Herbert Xu   crypto: ahash - C...
297
  	return __crypto_hash_alg_common(crypto_ahash_tfm(tfm)->__crt_alg);
18e33e6d5   Herbert Xu   crypto: hash - Mo...
298
  }
90240ffb1   Stephan Mueller   crypto: doc - AHA...
299
300
301
302
303
304
305
306
307
308
  /**
   * crypto_ahash_digestsize() - obtain message digest size
   * @tfm: cipher handle
   *
   * The size for the message digest created by the message digest cipher
   * referenced with the cipher handle is returned.
   *
   *
   * Return: message digest size of cipher
   */
18e33e6d5   Herbert Xu   crypto: hash - Mo...
309
310
  static inline unsigned int crypto_ahash_digestsize(struct crypto_ahash *tfm)
  {
500b3e3c3   Herbert Xu   crypto: ahash - R...
311
  	return crypto_hash_alg_common(tfm)->digestsize;
88056ec34   Herbert Xu   crypto: ahash - C...
312
  }
379d972b8   Rabin Vincent   crypto: doc - Fix...
313
314
315
316
317
318
319
320
321
322
  /**
   * crypto_ahash_statesize() - obtain size of the ahash state
   * @tfm: cipher handle
   *
   * Return the size of the ahash state. With the crypto_ahash_export()
   * function, the caller can export the state into a buffer whose size is
   * defined with this function.
   *
   * Return: size of the ahash state
   */
88056ec34   Herbert Xu   crypto: ahash - C...
323
324
325
  static inline unsigned int crypto_ahash_statesize(struct crypto_ahash *tfm)
  {
  	return crypto_hash_alg_common(tfm)->statesize;
18e33e6d5   Herbert Xu   crypto: hash - Mo...
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
  }
  
  static inline u32 crypto_ahash_get_flags(struct crypto_ahash *tfm)
  {
  	return crypto_tfm_get_flags(crypto_ahash_tfm(tfm));
  }
  
  static inline void crypto_ahash_set_flags(struct crypto_ahash *tfm, u32 flags)
  {
  	crypto_tfm_set_flags(crypto_ahash_tfm(tfm), flags);
  }
  
  static inline void crypto_ahash_clear_flags(struct crypto_ahash *tfm, u32 flags)
  {
  	crypto_tfm_clear_flags(crypto_ahash_tfm(tfm), flags);
  }
90240ffb1   Stephan Mueller   crypto: doc - AHA...
342
343
344
345
346
347
348
349
350
351
  /**
   * crypto_ahash_reqtfm() - obtain cipher handle from request
   * @req: asynchronous request handle that contains the reference to the ahash
   *	 cipher handle
   *
   * Return the ahash cipher handle that is registered with the asynchronous
   * request handle ahash_request.
   *
   * Return: ahash cipher handle
   */
18e33e6d5   Herbert Xu   crypto: hash - Mo...
352
353
354
355
356
  static inline struct crypto_ahash *crypto_ahash_reqtfm(
  	struct ahash_request *req)
  {
  	return __crypto_ahash_cast(req->base.tfm);
  }
90240ffb1   Stephan Mueller   crypto: doc - AHA...
357
358
359
360
  /**
   * crypto_ahash_reqsize() - obtain size of the request data structure
   * @tfm: cipher handle
   *
379d972b8   Rabin Vincent   crypto: doc - Fix...
361
   * Return: size of the request data
90240ffb1   Stephan Mueller   crypto: doc - AHA...
362
   */
18e33e6d5   Herbert Xu   crypto: hash - Mo...
363
364
  static inline unsigned int crypto_ahash_reqsize(struct crypto_ahash *tfm)
  {
88056ec34   Herbert Xu   crypto: ahash - C...
365
  	return tfm->reqsize;
18e33e6d5   Herbert Xu   crypto: hash - Mo...
366
  }
dec8b7860   Herbert Xu   crypto: hash - Ad...
367
368
369
370
  static inline void *ahash_request_ctx(struct ahash_request *req)
  {
  	return req->__ctx;
  }
90240ffb1   Stephan Mueller   crypto: doc - AHA...
371
372
373
374
375
376
377
378
379
380
381
  /**
   * crypto_ahash_setkey - set key for cipher handle
   * @tfm: cipher handle
   * @key: buffer holding the key
   * @keylen: length of the key in bytes
   *
   * The caller provided key is set for the ahash cipher. The cipher
   * handle must point to a keyed hash in order for this function to succeed.
   *
   * Return: 0 if the setting of the key was successful; < 0 if an error occurred
   */
66f6ce5e5   Herbert Xu   crypto: ahash - A...
382
383
  int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
  			unsigned int keylen);
90240ffb1   Stephan Mueller   crypto: doc - AHA...
384
385
386
387
388
389
390
  
  /**
   * crypto_ahash_finup() - update and finalize message digest
   * @req: reference to the ahash_request handle that holds all information
   *	 needed to perform the cipher operation
   *
   * This function is a "short-hand" for the function calls of
560b1a82e   Kamil Konieczny   crypto: doc - cla...
391
   * crypto_ahash_update and crypto_ahash_final. The parameters have the same
90240ffb1   Stephan Mueller   crypto: doc - AHA...
392
393
   * meaning as discussed for those separate functions.
   *
560b1a82e   Kamil Konieczny   crypto: doc - cla...
394
   * Return: see crypto_ahash_final()
90240ffb1   Stephan Mueller   crypto: doc - AHA...
395
   */
66f6ce5e5   Herbert Xu   crypto: ahash - A...
396
  int crypto_ahash_finup(struct ahash_request *req);
90240ffb1   Stephan Mueller   crypto: doc - AHA...
397
398
399
400
401
402
403
404
405
406
  
  /**
   * crypto_ahash_final() - calculate message digest
   * @req: reference to the ahash_request handle that holds all information
   *	 needed to perform the cipher operation
   *
   * Finalize the message digest operation and create the message digest
   * based on all data added to the cipher handle. The message digest is placed
   * into the output buffer registered with the ahash_request handle.
   *
560b1a82e   Kamil Konieczny   crypto: doc - cla...
407
408
409
410
411
   * Return:
   * 0		if the message digest was successfully calculated;
   * -EINPROGRESS	if data is feeded into hardware (DMA) or queued for later;
   * -EBUSY	if queue is full and request should be resubmitted later;
   * other < 0	if an error occurred
90240ffb1   Stephan Mueller   crypto: doc - AHA...
412
   */
66f6ce5e5   Herbert Xu   crypto: ahash - A...
413
  int crypto_ahash_final(struct ahash_request *req);
90240ffb1   Stephan Mueller   crypto: doc - AHA...
414
415
416
417
418
419
420
421
422
423
  
  /**
   * crypto_ahash_digest() - calculate message digest for a buffer
   * @req: reference to the ahash_request handle that holds all information
   *	 needed to perform the cipher operation
   *
   * This function is a "short-hand" for the function calls of crypto_ahash_init,
   * crypto_ahash_update and crypto_ahash_final. The parameters have the same
   * meaning as discussed for those separate three functions.
   *
560b1a82e   Kamil Konieczny   crypto: doc - cla...
424
   * Return: see crypto_ahash_final()
90240ffb1   Stephan Mueller   crypto: doc - AHA...
425
   */
66f6ce5e5   Herbert Xu   crypto: ahash - A...
426
  int crypto_ahash_digest(struct ahash_request *req);
18e33e6d5   Herbert Xu   crypto: hash - Mo...
427

90240ffb1   Stephan Mueller   crypto: doc - AHA...
428
429
430
431
432
433
434
  /**
   * crypto_ahash_export() - extract current message digest state
   * @req: reference to the ahash_request handle whose state is exported
   * @out: output buffer of sufficient size that can hold the hash state
   *
   * This function exports the hash state of the ahash_request handle into the
   * caller-allocated output buffer out which must have sufficient size (e.g. by
379d972b8   Rabin Vincent   crypto: doc - Fix...
435
   * calling crypto_ahash_statesize()).
90240ffb1   Stephan Mueller   crypto: doc - AHA...
436
437
438
   *
   * Return: 0 if the export was successful; < 0 if an error occurred
   */
88056ec34   Herbert Xu   crypto: ahash - C...
439
  static inline int crypto_ahash_export(struct ahash_request *req, void *out)
dec8b7860   Herbert Xu   crypto: hash - Ad...
440
  {
88056ec34   Herbert Xu   crypto: ahash - C...
441
  	return crypto_ahash_reqtfm(req)->export(req, out);
dec8b7860   Herbert Xu   crypto: hash - Ad...
442
  }
90240ffb1   Stephan Mueller   crypto: doc - AHA...
443
444
445
446
447
448
449
450
451
452
453
  /**
   * crypto_ahash_import() - import message digest state
   * @req: reference to ahash_request handle the state is imported into
   * @in: buffer holding the state
   *
   * This function imports the hash state into the ahash_request handle from the
   * input buffer. That buffer should have been generated with the
   * crypto_ahash_export function.
   *
   * Return: 0 if the import was successful; < 0 if an error occurred
   */
88056ec34   Herbert Xu   crypto: ahash - C...
454
455
  static inline int crypto_ahash_import(struct ahash_request *req, const void *in)
  {
9fa68f620   Eric Biggers   crypto: hash - pr...
456
457
458
459
460
461
  	struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
  
  	if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
  		return -ENOKEY;
  
  	return tfm->import(req, in);
88056ec34   Herbert Xu   crypto: ahash - C...
462
  }
dec8b7860   Herbert Xu   crypto: hash - Ad...
463

90240ffb1   Stephan Mueller   crypto: doc - AHA...
464
465
466
467
468
469
470
471
472
  /**
   * crypto_ahash_init() - (re)initialize message digest handle
   * @req: ahash_request handle that already is initialized with all necessary
   *	 data using the ahash_request_* API functions
   *
   * The call (re-)initializes the message digest referenced by the ahash_request
   * handle. Any potentially existing state created by previous operations is
   * discarded.
   *
560b1a82e   Kamil Konieczny   crypto: doc - cla...
473
   * Return: see crypto_ahash_final()
90240ffb1   Stephan Mueller   crypto: doc - AHA...
474
   */
318e53139   Herbert Xu   crypto: hash - Ad...
475
476
  static inline int crypto_ahash_init(struct ahash_request *req)
  {
9fa68f620   Eric Biggers   crypto: hash - pr...
477
478
479
480
481
482
  	struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
  
  	if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
  		return -ENOKEY;
  
  	return tfm->init(req);
318e53139   Herbert Xu   crypto: hash - Ad...
483
  }
90240ffb1   Stephan Mueller   crypto: doc - AHA...
484
485
486
487
488
489
490
491
492
  /**
   * crypto_ahash_update() - add data to message digest for processing
   * @req: ahash_request handle that was previously initialized with the
   *	 crypto_ahash_init call.
   *
   * Updates the message digest state of the &ahash_request handle. The input data
   * is pointed to by the scatter/gather list registered in the &ahash_request
   * handle
   *
560b1a82e   Kamil Konieczny   crypto: doc - cla...
493
   * Return: see crypto_ahash_final()
90240ffb1   Stephan Mueller   crypto: doc - AHA...
494
   */
318e53139   Herbert Xu   crypto: hash - Ad...
495
496
  static inline int crypto_ahash_update(struct ahash_request *req)
  {
88056ec34   Herbert Xu   crypto: ahash - C...
497
  	return crypto_ahash_reqtfm(req)->update(req);
318e53139   Herbert Xu   crypto: hash - Ad...
498
  }
90240ffb1   Stephan Mueller   crypto: doc - AHA...
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
  /**
   * DOC: Asynchronous Hash Request Handle
   *
   * The &ahash_request data structure contains all pointers to data
   * required for the asynchronous cipher operation. This includes the cipher
   * handle (which can be used by multiple &ahash_request instances), pointer
   * to plaintext and the message digest output buffer, asynchronous callback
   * function, etc. It acts as a handle to the ahash_request_* API calls in a
   * similar way as ahash handle to the crypto_ahash_* API calls.
   */
  
  /**
   * ahash_request_set_tfm() - update cipher handle reference in request
   * @req: request handle to be modified
   * @tfm: cipher handle that shall be added to the request handle
   *
   * Allow the caller to replace the existing ahash handle in the request
   * data structure with a different one.
   */
18e33e6d5   Herbert Xu   crypto: hash - Mo...
518
519
520
521
522
  static inline void ahash_request_set_tfm(struct ahash_request *req,
  					 struct crypto_ahash *tfm)
  {
  	req->base.tfm = crypto_ahash_tfm(tfm);
  }
90240ffb1   Stephan Mueller   crypto: doc - AHA...
523
524
525
526
527
528
529
530
531
532
  /**
   * ahash_request_alloc() - allocate request data structure
   * @tfm: cipher handle to be registered with the request
   * @gfp: memory allocation flag that is handed to kmalloc by the API call.
   *
   * Allocate the request data structure that must be used with the ahash
   * message digest API calls. During
   * the allocation, the provided ahash handle
   * is registered in the request data structure.
   *
6eae29e7e   Eric Biggers   crypto: doc - doc...
533
   * Return: allocated request handle in case of success, or NULL if out of memory
90240ffb1   Stephan Mueller   crypto: doc - AHA...
534
   */
18e33e6d5   Herbert Xu   crypto: hash - Mo...
535
536
537
538
539
540
541
542
543
544
545
546
547
  static inline struct ahash_request *ahash_request_alloc(
  	struct crypto_ahash *tfm, gfp_t gfp)
  {
  	struct ahash_request *req;
  
  	req = kmalloc(sizeof(struct ahash_request) +
  		      crypto_ahash_reqsize(tfm), gfp);
  
  	if (likely(req))
  		ahash_request_set_tfm(req, tfm);
  
  	return req;
  }
90240ffb1   Stephan Mueller   crypto: doc - AHA...
548
549
550
551
  /**
   * ahash_request_free() - zeroize and free the request data structure
   * @req: request data structure cipher handle to be freed
   */
18e33e6d5   Herbert Xu   crypto: hash - Mo...
552
553
  static inline void ahash_request_free(struct ahash_request *req)
  {
aef73cfcb   Herbert Xu   crypto: async - U...
554
  	kzfree(req);
18e33e6d5   Herbert Xu   crypto: hash - Mo...
555
  }
e67ffe0af   Herbert Xu   crypto: hash - Ad...
556
557
558
559
560
  static inline void ahash_request_zero(struct ahash_request *req)
  {
  	memzero_explicit(req, sizeof(*req) +
  			      crypto_ahash_reqsize(crypto_ahash_reqtfm(req)));
  }
18e33e6d5   Herbert Xu   crypto: hash - Mo...
561
562
563
564
565
  static inline struct ahash_request *ahash_request_cast(
  	struct crypto_async_request *req)
  {
  	return container_of(req, struct ahash_request, base);
  }
90240ffb1   Stephan Mueller   crypto: doc - AHA...
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
  /**
   * ahash_request_set_callback() - set asynchronous callback function
   * @req: request handle
   * @flags: specify zero or an ORing of the flags
   *	   CRYPTO_TFM_REQ_MAY_BACKLOG the request queue may back log and
   *	   increase the wait queue beyond the initial maximum size;
   *	   CRYPTO_TFM_REQ_MAY_SLEEP the request processing may sleep
   * @compl: callback function pointer to be registered with the request handle
   * @data: The data pointer refers to memory that is not used by the kernel
   *	  crypto API, but provided to the callback function for it to use. Here,
   *	  the caller can provide a reference to memory the callback function can
   *	  operate on. As the callback function is invoked asynchronously to the
   *	  related functionality, it may need to access data structures of the
   *	  related functionality which can be referenced using this pointer. The
   *	  callback function can access the memory via the "data" field in the
   *	  &crypto_async_request data structure provided to the callback function.
   *
   * This function allows setting the callback function that is triggered once
   * the cipher operation completes.
   *
   * The callback function is registered with the &ahash_request handle and
0184cfe72   Stephan Mueller   crypto: doc - fix...
587
   * must comply with the following template::
90240ffb1   Stephan Mueller   crypto: doc - AHA...
588
589
590
   *
   *	void callback_function(struct crypto_async_request *req, int error)
   */
18e33e6d5   Herbert Xu   crypto: hash - Mo...
591
592
  static inline void ahash_request_set_callback(struct ahash_request *req,
  					      u32 flags,
3e3dc25fe   Mark Rustad   crypto: Resolve s...
593
  					      crypto_completion_t compl,
18e33e6d5   Herbert Xu   crypto: hash - Mo...
594
595
  					      void *data)
  {
3e3dc25fe   Mark Rustad   crypto: Resolve s...
596
  	req->base.complete = compl;
18e33e6d5   Herbert Xu   crypto: hash - Mo...
597
598
599
  	req->base.data = data;
  	req->base.flags = flags;
  }
90240ffb1   Stephan Mueller   crypto: doc - AHA...
600
601
602
603
604
605
606
607
608
609
610
611
612
  /**
   * ahash_request_set_crypt() - set data buffers
   * @req: ahash_request handle to be updated
   * @src: source scatter/gather list
   * @result: buffer that is filled with the message digest -- the caller must
   *	    ensure that the buffer has sufficient space by, for example, calling
   *	    crypto_ahash_digestsize()
   * @nbytes: number of bytes to process from the source scatter/gather list
   *
   * By using this call, the caller references the source scatter/gather list.
   * The source scatter/gather list points to the data the message digest is to
   * be calculated for.
   */
18e33e6d5   Herbert Xu   crypto: hash - Mo...
613
614
615
616
617
618
619
620
  static inline void ahash_request_set_crypt(struct ahash_request *req,
  					   struct scatterlist *src, u8 *result,
  					   unsigned int nbytes)
  {
  	req->src = src;
  	req->nbytes = nbytes;
  	req->result = result;
  }
968ab2910   Stephan Mueller   crypto: doc - SHA...
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
  /**
   * DOC: Synchronous Message Digest API
   *
   * The synchronous message digest API is used with the ciphers of type
   * CRYPTO_ALG_TYPE_SHASH (listed as type "shash" in /proc/crypto)
   *
   * The message digest API is able to maintain state information for the
   * caller.
   *
   * The synchronous message digest API can store user-related context in in its
   * shash_desc request data structure.
   */
  
  /**
   * crypto_alloc_shash() - allocate message digest handle
   * @alg_name: is the cra_name / name or cra_driver_name / driver name of the
   *	      message digest cipher
   * @type: specifies the type of the cipher
   * @mask: specifies the mask for the cipher
   *
   * Allocate a cipher handle for a message digest. The returned &struct
   * crypto_shash is the cipher handle that is required for any subsequent
   * API invocation for that message digest.
   *
   * Return: allocated cipher handle in case of success; IS_ERR() is true in case
   *	   of an error, PTR_ERR() returns the error code.
   */
7b5a080b3   Herbert Xu   crypto: hash - Ad...
648
649
650
651
652
653
654
  struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type,
  					u32 mask);
  
  static inline struct crypto_tfm *crypto_shash_tfm(struct crypto_shash *tfm)
  {
  	return &tfm->base;
  }
968ab2910   Stephan Mueller   crypto: doc - SHA...
655
656
657
658
  /**
   * crypto_free_shash() - zeroize and free the message digest handle
   * @tfm: cipher handle to be freed
   */
7b5a080b3   Herbert Xu   crypto: hash - Ad...
659
660
  static inline void crypto_free_shash(struct crypto_shash *tfm)
  {
412e87ae5   Herbert Xu   crypto: shash - F...
661
  	crypto_destroy_tfm(tfm, crypto_shash_tfm(tfm));
7b5a080b3   Herbert Xu   crypto: hash - Ad...
662
  }
d12481bc5   Herbert Xu   crypto: hash - Ad...
663
664
665
666
667
668
669
670
671
  static inline const char *crypto_shash_alg_name(struct crypto_shash *tfm)
  {
  	return crypto_tfm_alg_name(crypto_shash_tfm(tfm));
  }
  
  static inline const char *crypto_shash_driver_name(struct crypto_shash *tfm)
  {
  	return crypto_tfm_alg_driver_name(crypto_shash_tfm(tfm));
  }
7b5a080b3   Herbert Xu   crypto: hash - Ad...
672
673
674
675
676
  static inline unsigned int crypto_shash_alignmask(
  	struct crypto_shash *tfm)
  {
  	return crypto_tfm_alg_alignmask(crypto_shash_tfm(tfm));
  }
968ab2910   Stephan Mueller   crypto: doc - SHA...
677
678
679
680
681
682
683
684
685
  /**
   * crypto_shash_blocksize() - obtain block size for cipher
   * @tfm: cipher handle
   *
   * The block size for the message digest cipher referenced with the cipher
   * handle is returned.
   *
   * Return: block size of cipher
   */
974959863   Herbert Xu   crypto: shash - A...
686
687
688
689
  static inline unsigned int crypto_shash_blocksize(struct crypto_shash *tfm)
  {
  	return crypto_tfm_alg_blocksize(crypto_shash_tfm(tfm));
  }
7b5a080b3   Herbert Xu   crypto: hash - Ad...
690
691
692
693
694
695
696
697
698
  static inline struct shash_alg *__crypto_shash_alg(struct crypto_alg *alg)
  {
  	return container_of(alg, struct shash_alg, base);
  }
  
  static inline struct shash_alg *crypto_shash_alg(struct crypto_shash *tfm)
  {
  	return __crypto_shash_alg(crypto_shash_tfm(tfm)->__crt_alg);
  }
968ab2910   Stephan Mueller   crypto: doc - SHA...
699
700
701
702
703
704
705
706
707
  /**
   * crypto_shash_digestsize() - obtain message digest size
   * @tfm: cipher handle
   *
   * The size for the message digest created by the message digest cipher
   * referenced with the cipher handle is returned.
   *
   * Return: digest size of cipher
   */
7b5a080b3   Herbert Xu   crypto: hash - Ad...
708
709
710
711
  static inline unsigned int crypto_shash_digestsize(struct crypto_shash *tfm)
  {
  	return crypto_shash_alg(tfm)->digestsize;
  }
99d27e1c5   Herbert Xu   crypto: shash - E...
712
713
714
715
  static inline unsigned int crypto_shash_statesize(struct crypto_shash *tfm)
  {
  	return crypto_shash_alg(tfm)->statesize;
  }
7b5a080b3   Herbert Xu   crypto: hash - Ad...
716
717
718
719
720
721
722
723
724
725
726
727
728
729
  static inline u32 crypto_shash_get_flags(struct crypto_shash *tfm)
  {
  	return crypto_tfm_get_flags(crypto_shash_tfm(tfm));
  }
  
  static inline void crypto_shash_set_flags(struct crypto_shash *tfm, u32 flags)
  {
  	crypto_tfm_set_flags(crypto_shash_tfm(tfm), flags);
  }
  
  static inline void crypto_shash_clear_flags(struct crypto_shash *tfm, u32 flags)
  {
  	crypto_tfm_clear_flags(crypto_shash_tfm(tfm), flags);
  }
968ab2910   Stephan Mueller   crypto: doc - SHA...
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
  /**
   * crypto_shash_descsize() - obtain the operational state size
   * @tfm: cipher handle
   *
   * The size of the operational state the cipher needs during operation is
   * returned for the hash referenced with the cipher handle. This size is
   * required to calculate the memory requirements to allow the caller allocating
   * sufficient memory for operational state.
   *
   * The operational state is defined with struct shash_desc where the size of
   * that data structure is to be calculated as
   * sizeof(struct shash_desc) + crypto_shash_descsize(alg)
   *
   * Return: size of the operational state
   */
7b5a080b3   Herbert Xu   crypto: hash - Ad...
745
746
  static inline unsigned int crypto_shash_descsize(struct crypto_shash *tfm)
  {
113adefc7   Herbert Xu   crypto: shash - M...
747
  	return tfm->descsize;
7b5a080b3   Herbert Xu   crypto: hash - Ad...
748
749
750
751
752
753
  }
  
  static inline void *shash_desc_ctx(struct shash_desc *desc)
  {
  	return desc->__ctx;
  }
968ab2910   Stephan Mueller   crypto: doc - SHA...
754
755
756
757
758
759
760
761
762
763
764
765
  /**
   * crypto_shash_setkey() - set key for message digest
   * @tfm: cipher handle
   * @key: buffer holding the key
   * @keylen: length of the key in bytes
   *
   * The caller provided key is set for the keyed message digest cipher. The
   * cipher handle must point to a keyed message digest cipher in order for this
   * function to succeed.
   *
   * Return: 0 if the setting of the key was successful; < 0 if an error occurred
   */
7b5a080b3   Herbert Xu   crypto: hash - Ad...
766
767
  int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key,
  			unsigned int keylen);
968ab2910   Stephan Mueller   crypto: doc - SHA...
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
  
  /**
   * crypto_shash_digest() - calculate message digest for buffer
   * @desc: see crypto_shash_final()
   * @data: see crypto_shash_update()
   * @len: see crypto_shash_update()
   * @out: see crypto_shash_final()
   *
   * This function is a "short-hand" for the function calls of crypto_shash_init,
   * crypto_shash_update and crypto_shash_final. The parameters have the same
   * meaning as discussed for those separate three functions.
   *
   * Return: 0 if the message digest creation was successful; < 0 if an error
   *	   occurred
   */
7b5a080b3   Herbert Xu   crypto: hash - Ad...
783
784
  int crypto_shash_digest(struct shash_desc *desc, const u8 *data,
  			unsigned int len, u8 *out);
968ab2910   Stephan Mueller   crypto: doc - SHA...
785
786
787
788
789
790
791
792
793
794
795
  /**
   * crypto_shash_export() - extract operational state for message digest
   * @desc: reference to the operational state handle whose state is exported
   * @out: output buffer of sufficient size that can hold the hash state
   *
   * This function exports the hash state of the operational state handle into the
   * caller-allocated output buffer out which must have sufficient size (e.g. by
   * calling crypto_shash_descsize).
   *
   * Return: 0 if the export creation was successful; < 0 if an error occurred
   */
99d27e1c5   Herbert Xu   crypto: shash - E...
796
  static inline int crypto_shash_export(struct shash_desc *desc, void *out)
dec8b7860   Herbert Xu   crypto: hash - Ad...
797
  {
99d27e1c5   Herbert Xu   crypto: shash - E...
798
  	return crypto_shash_alg(desc->tfm)->export(desc, out);
dec8b7860   Herbert Xu   crypto: hash - Ad...
799
  }
968ab2910   Stephan Mueller   crypto: doc - SHA...
800
801
802
803
804
805
806
807
808
809
810
  /**
   * crypto_shash_import() - import operational state
   * @desc: reference to the operational state handle the state imported into
   * @in: buffer holding the state
   *
   * This function imports the hash state into the operational state handle from
   * the input buffer. That buffer should have been generated with the
   * crypto_ahash_export function.
   *
   * Return: 0 if the import was successful; < 0 if an error occurred
   */
99d27e1c5   Herbert Xu   crypto: shash - E...
811
812
  static inline int crypto_shash_import(struct shash_desc *desc, const void *in)
  {
9fa68f620   Eric Biggers   crypto: hash - pr...
813
814
815
816
817
818
  	struct crypto_shash *tfm = desc->tfm;
  
  	if (crypto_shash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
  		return -ENOKEY;
  
  	return crypto_shash_alg(tfm)->import(desc, in);
99d27e1c5   Herbert Xu   crypto: shash - E...
819
  }
dec8b7860   Herbert Xu   crypto: hash - Ad...
820

968ab2910   Stephan Mueller   crypto: doc - SHA...
821
822
823
824
825
826
827
828
829
830
831
  /**
   * crypto_shash_init() - (re)initialize message digest
   * @desc: operational state handle that is already filled
   *
   * The call (re-)initializes the message digest referenced by the
   * operational state handle. Any potentially existing state created by
   * previous operations is discarded.
   *
   * Return: 0 if the message digest initialization was successful; < 0 if an
   *	   error occurred
   */
7b5a080b3   Herbert Xu   crypto: hash - Ad...
832
833
  static inline int crypto_shash_init(struct shash_desc *desc)
  {
9fa68f620   Eric Biggers   crypto: hash - pr...
834
835
836
837
838
839
  	struct crypto_shash *tfm = desc->tfm;
  
  	if (crypto_shash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
  		return -ENOKEY;
  
  	return crypto_shash_alg(tfm)->init(desc);
7b5a080b3   Herbert Xu   crypto: hash - Ad...
840
  }
968ab2910   Stephan Mueller   crypto: doc - SHA...
841
842
843
844
845
846
847
848
849
850
851
  /**
   * crypto_shash_update() - add data to message digest for processing
   * @desc: operational state handle that is already initialized
   * @data: input data to be added to the message digest
   * @len: length of the input data
   *
   * Updates the message digest state of the operational state handle.
   *
   * Return: 0 if the message digest update was successful; < 0 if an error
   *	   occurred
   */
7b5a080b3   Herbert Xu   crypto: hash - Ad...
852
853
  int crypto_shash_update(struct shash_desc *desc, const u8 *data,
  			unsigned int len);
968ab2910   Stephan Mueller   crypto: doc - SHA...
854
855
856
857
858
859
860
861
862
863
864
865
866
867
  
  /**
   * crypto_shash_final() - calculate message digest
   * @desc: operational state handle that is already filled with data
   * @out: output buffer filled with the message digest
   *
   * Finalize the message digest operation and create the message digest
   * based on all data added to the cipher handle. The message digest is placed
   * into the output buffer. The caller must ensure that the output buffer is
   * large enough by using crypto_shash_digestsize.
   *
   * Return: 0 if the message digest creation was successful; < 0 if an error
   *	   occurred
   */
7b5a080b3   Herbert Xu   crypto: hash - Ad...
868
  int crypto_shash_final(struct shash_desc *desc, u8 *out);
968ab2910   Stephan Mueller   crypto: doc - SHA...
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
  
  /**
   * crypto_shash_finup() - calculate message digest of buffer
   * @desc: see crypto_shash_final()
   * @data: see crypto_shash_update()
   * @len: see crypto_shash_update()
   * @out: see crypto_shash_final()
   *
   * This function is a "short-hand" for the function calls of
   * crypto_shash_update and crypto_shash_final. The parameters have the same
   * meaning as discussed for those separate functions.
   *
   * Return: 0 if the message digest creation was successful; < 0 if an error
   *	   occurred
   */
7b5a080b3   Herbert Xu   crypto: hash - Ad...
884
885
  int crypto_shash_finup(struct shash_desc *desc, const u8 *data,
  		       unsigned int len, u8 *out);
e67ffe0af   Herbert Xu   crypto: hash - Ad...
886
887
888
889
890
  static inline void shash_desc_zero(struct shash_desc *desc)
  {
  	memzero_explicit(desc,
  			 sizeof(*desc) + crypto_shash_descsize(desc->tfm));
  }
18e33e6d5   Herbert Xu   crypto: hash - Mo...
891
  #endif	/* _CRYPTO_HASH_H */