sha.h 1.9 KB

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