1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
9 #include <crypto/scatterwalk.h>
10 #include <crypto/sha1.h>
11 #include <crypto/sha2.h>
16 #define QCE_SHA_MAX_BLOCKSIZE SHA256_BLOCK_SIZE
17 #define QCE_SHA_MAX_DIGESTSIZE SHA256_DIGEST_SIZE
20 u8 authkey
[QCE_SHA_MAX_BLOCKSIZE
];
24 * struct qce_sha_reqctx - holds private ahash objects per request
25 * @buf: used during update, import and export
26 * @tmpbuf: buffer for internal use
27 * @digest: calculated digest buffer
28 * @buflen: length of the buffer
29 * @flags: operation flags
30 * @src_orig: original request sg list
31 * @nbytes_orig: original request number of bytes
32 * @src_nents: source number of entries
33 * @byte_count: byte count
34 * @count: save count in states during update, import and export
35 * @first_blk: is it the first block
36 * @last_blk: is it the last block
37 * @sg: used to chain sg lists
38 * @authkey: pointer to auth key in sha ctx
39 * @authklen: auth key length
40 * @result_sg: scatterlist used for result buffer
42 struct qce_sha_reqctx
{
43 u8 buf
[QCE_SHA_MAX_BLOCKSIZE
];
44 u8 tmpbuf
[QCE_SHA_MAX_BLOCKSIZE
];
45 u8 digest
[QCE_SHA_MAX_DIGESTSIZE
];
48 struct scatterlist
*src_orig
;
49 unsigned int nbytes_orig
;
55 struct scatterlist sg
[2];
57 unsigned int authklen
;
58 struct scatterlist result_sg
;
61 static inline struct qce_alg_template
*to_ahash_tmpl(struct crypto_tfm
*tfm
)
63 struct crypto_ahash
*ahash
= __crypto_ahash_cast(tfm
);
64 struct ahash_alg
*alg
= container_of(crypto_hash_alg_common(ahash
),
65 struct ahash_alg
, halg
);
67 return container_of(alg
, struct qce_alg_template
, alg
.ahash
);
70 extern const struct qce_algo_ops ahash_ops
;