Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
0004  */
0005 
0006 #ifndef _SHA_H_
0007 #define _SHA_H_
0008 
0009 #include <crypto/scatterwalk.h>
0010 #include <crypto/sha1.h>
0011 #include <crypto/sha2.h>
0012 
0013 #include "common.h"
0014 #include "core.h"
0015 
0016 #define QCE_SHA_MAX_BLOCKSIZE       SHA256_BLOCK_SIZE
0017 #define QCE_SHA_MAX_DIGESTSIZE      SHA256_DIGEST_SIZE
0018 
0019 struct qce_sha_ctx {
0020     u8 authkey[QCE_SHA_MAX_BLOCKSIZE];
0021 };
0022 
0023 /**
0024  * struct qce_sha_reqctx - holds private ahash objects per request
0025  * @buf: used during update, import and export
0026  * @tmpbuf: buffer for internal use
0027  * @digest: calculated digest buffer
0028  * @buflen: length of the buffer
0029  * @flags: operation flags
0030  * @src_orig: original request sg list
0031  * @nbytes_orig: original request number of bytes
0032  * @src_nents: source number of entries
0033  * @byte_count: byte count
0034  * @count: save count in states during update, import and export
0035  * @first_blk: is it the first block
0036  * @last_blk: is it the last block
0037  * @sg: used to chain sg lists
0038  * @authkey: pointer to auth key in sha ctx
0039  * @authklen: auth key length
0040  * @result_sg: scatterlist used for result buffer
0041  */
0042 struct qce_sha_reqctx {
0043     u8 buf[QCE_SHA_MAX_BLOCKSIZE];
0044     u8 tmpbuf[QCE_SHA_MAX_BLOCKSIZE];
0045     u8 digest[QCE_SHA_MAX_DIGESTSIZE];
0046     unsigned int buflen;
0047     unsigned long flags;
0048     struct scatterlist *src_orig;
0049     unsigned int nbytes_orig;
0050     int src_nents;
0051     __be32 byte_count[2];
0052     u64 count;
0053     bool first_blk;
0054     bool last_blk;
0055     struct scatterlist sg[2];
0056     u8 *authkey;
0057     unsigned int authklen;
0058     struct scatterlist result_sg;
0059 };
0060 
0061 static inline struct qce_alg_template *to_ahash_tmpl(struct crypto_tfm *tfm)
0062 {
0063     struct crypto_ahash *ahash = __crypto_ahash_cast(tfm);
0064     struct ahash_alg *alg = container_of(crypto_hash_alg_common(ahash),
0065                          struct ahash_alg, halg);
0066 
0067     return container_of(alg, struct qce_alg_template, alg.ahash);
0068 }
0069 
0070 extern const struct qce_algo_ops ahash_ops;
0071 
0072 #endif /* _SHA_H_ */