18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef _SHA_H_ 78c2ecf20Sopenharmony_ci#define _SHA_H_ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <crypto/scatterwalk.h> 108c2ecf20Sopenharmony_ci#include <crypto/sha.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include "common.h" 138c2ecf20Sopenharmony_ci#include "core.h" 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define QCE_SHA_MAX_BLOCKSIZE SHA256_BLOCK_SIZE 168c2ecf20Sopenharmony_ci#define QCE_SHA_MAX_DIGESTSIZE SHA256_DIGEST_SIZE 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistruct qce_sha_ctx { 198c2ecf20Sopenharmony_ci u8 authkey[QCE_SHA_MAX_BLOCKSIZE]; 208c2ecf20Sopenharmony_ci}; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/** 238c2ecf20Sopenharmony_ci * struct qce_sha_reqctx - holds private ahash objects per request 248c2ecf20Sopenharmony_ci * @buf: used during update, import and export 258c2ecf20Sopenharmony_ci * @tmpbuf: buffer for internal use 268c2ecf20Sopenharmony_ci * @digest: calculated digest buffer 278c2ecf20Sopenharmony_ci * @buflen: length of the buffer 288c2ecf20Sopenharmony_ci * @flags: operation flags 298c2ecf20Sopenharmony_ci * @src_orig: original request sg list 308c2ecf20Sopenharmony_ci * @nbytes_orig: original request number of bytes 318c2ecf20Sopenharmony_ci * @src_nents: source number of entries 328c2ecf20Sopenharmony_ci * @byte_count: byte count 338c2ecf20Sopenharmony_ci * @count: save count in states during update, import and export 348c2ecf20Sopenharmony_ci * @first_blk: is it the first block 358c2ecf20Sopenharmony_ci * @last_blk: is it the last block 368c2ecf20Sopenharmony_ci * @sg: used to chain sg lists 378c2ecf20Sopenharmony_ci * @authkey: pointer to auth key in sha ctx 388c2ecf20Sopenharmony_ci * @authklen: auth key length 398c2ecf20Sopenharmony_ci * @result_sg: scatterlist used for result buffer 408c2ecf20Sopenharmony_ci */ 418c2ecf20Sopenharmony_cistruct qce_sha_reqctx { 428c2ecf20Sopenharmony_ci u8 buf[QCE_SHA_MAX_BLOCKSIZE]; 438c2ecf20Sopenharmony_ci u8 tmpbuf[QCE_SHA_MAX_BLOCKSIZE]; 448c2ecf20Sopenharmony_ci u8 digest[QCE_SHA_MAX_DIGESTSIZE]; 458c2ecf20Sopenharmony_ci unsigned int buflen; 468c2ecf20Sopenharmony_ci unsigned long flags; 478c2ecf20Sopenharmony_ci struct scatterlist *src_orig; 488c2ecf20Sopenharmony_ci unsigned int nbytes_orig; 498c2ecf20Sopenharmony_ci int src_nents; 508c2ecf20Sopenharmony_ci __be32 byte_count[2]; 518c2ecf20Sopenharmony_ci u64 count; 528c2ecf20Sopenharmony_ci bool first_blk; 538c2ecf20Sopenharmony_ci bool last_blk; 548c2ecf20Sopenharmony_ci struct scatterlist sg[2]; 558c2ecf20Sopenharmony_ci u8 *authkey; 568c2ecf20Sopenharmony_ci unsigned int authklen; 578c2ecf20Sopenharmony_ci struct scatterlist result_sg; 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic inline struct qce_alg_template *to_ahash_tmpl(struct crypto_tfm *tfm) 618c2ecf20Sopenharmony_ci{ 628c2ecf20Sopenharmony_ci struct crypto_ahash *ahash = __crypto_ahash_cast(tfm); 638c2ecf20Sopenharmony_ci struct ahash_alg *alg = container_of(crypto_hash_alg_common(ahash), 648c2ecf20Sopenharmony_ci struct ahash_alg, halg); 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci return container_of(alg, struct qce_alg_template, alg.ahash); 678c2ecf20Sopenharmony_ci} 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ciextern const struct qce_algo_ops ahash_ops; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#endif /* _SHA_H_ */ 72