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