Thomas Gleixner | 97fb5e8 | 2019-05-29 07:17:58 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stanimir Varbanov | ec8f5d8 | 2014-06-25 19:28:57 +0300 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved. |
Stanimir Varbanov | ec8f5d8 | 2014-06-25 19:28:57 +0300 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _SHA_H_ |
| 7 | #define _SHA_H_ |
| 8 | |
| 9 | #include <crypto/scatterwalk.h> |
| 10 | #include <crypto/sha.h> |
| 11 | |
| 12 | #include "common.h" |
| 13 | #include "core.h" |
| 14 | |
| 15 | #define QCE_SHA_MAX_BLOCKSIZE SHA256_BLOCK_SIZE |
| 16 | #define QCE_SHA_MAX_DIGESTSIZE SHA256_DIGEST_SIZE |
| 17 | |
| 18 | struct qce_sha_ctx { |
| 19 | u8 authkey[QCE_SHA_MAX_BLOCKSIZE]; |
| 20 | }; |
| 21 | |
| 22 | /** |
| 23 | * struct qce_sha_reqctx - holds private ahash objects per request |
| 24 | * @buf: used during update, import and export |
| 25 | * @tmpbuf: buffer for internal use |
| 26 | * @digest: calculated digest buffer |
| 27 | * @buflen: length of the buffer |
| 28 | * @flags: operation flags |
| 29 | * @src_orig: original request sg list |
| 30 | * @nbytes_orig: original request number of bytes |
Stanimir Varbanov | ec8f5d8 | 2014-06-25 19:28:57 +0300 | [diff] [blame] | 31 | * @src_nents: source number of entries |
| 32 | * @byte_count: byte count |
| 33 | * @count: save count in states during update, import and export |
| 34 | * @first_blk: is it the first block |
| 35 | * @last_blk: is it the last block |
| 36 | * @sg: used to chain sg lists |
| 37 | * @authkey: pointer to auth key in sha ctx |
| 38 | * @authklen: auth key length |
| 39 | * @result_sg: scatterlist used for result buffer |
| 40 | */ |
| 41 | struct qce_sha_reqctx { |
| 42 | u8 buf[QCE_SHA_MAX_BLOCKSIZE]; |
| 43 | u8 tmpbuf[QCE_SHA_MAX_BLOCKSIZE]; |
| 44 | u8 digest[QCE_SHA_MAX_DIGESTSIZE]; |
| 45 | unsigned int buflen; |
| 46 | unsigned long flags; |
| 47 | struct scatterlist *src_orig; |
| 48 | unsigned int nbytes_orig; |
Stanimir Varbanov | ec8f5d8 | 2014-06-25 19:28:57 +0300 | [diff] [blame] | 49 | int src_nents; |
| 50 | __be32 byte_count[2]; |
| 51 | u64 count; |
| 52 | bool first_blk; |
| 53 | bool last_blk; |
| 54 | struct scatterlist sg[2]; |
| 55 | u8 *authkey; |
| 56 | unsigned int authklen; |
| 57 | struct scatterlist result_sg; |
| 58 | }; |
| 59 | |
| 60 | static inline struct qce_alg_template *to_ahash_tmpl(struct crypto_tfm *tfm) |
| 61 | { |
| 62 | struct crypto_ahash *ahash = __crypto_ahash_cast(tfm); |
| 63 | struct ahash_alg *alg = container_of(crypto_hash_alg_common(ahash), |
| 64 | struct ahash_alg, halg); |
| 65 | |
| 66 | return container_of(alg, struct qce_alg_template, alg.ahash); |
| 67 | } |
| 68 | |
| 69 | extern const struct qce_algo_ops ahash_ops; |
| 70 | |
| 71 | #endif /* _SHA_H_ */ |