cipher_aes_cbc_hmac_sha.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include "prov/ciphercommon.h"
  10. #include "crypto/aes_platform.h"
  11. int ossl_cipher_capable_aes_cbc_hmac_sha1(void);
  12. int ossl_cipher_capable_aes_cbc_hmac_sha256(void);
  13. typedef struct prov_cipher_hw_aes_hmac_sha_ctx_st {
  14. PROV_CIPHER_HW base; /* must be first */
  15. void (*init_mac_key)(void *ctx, const unsigned char *inkey, size_t inlen);
  16. int (*set_tls1_aad)(void *ctx, unsigned char *aad_rec, int aad_len);
  17. # if !defined(OPENSSL_NO_MULTIBLOCK)
  18. int (*tls1_multiblock_max_bufsize)(void *ctx);
  19. int (*tls1_multiblock_aad)(
  20. void *vctx, EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *param);
  21. int (*tls1_multiblock_encrypt)(
  22. void *ctx, EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *param);
  23. # endif /* OPENSSL_NO_MULTIBLOCK) */
  24. } PROV_CIPHER_HW_AES_HMAC_SHA;
  25. const PROV_CIPHER_HW_AES_HMAC_SHA *ossl_prov_cipher_hw_aes_cbc_hmac_sha1(void);
  26. const PROV_CIPHER_HW_AES_HMAC_SHA *ossl_prov_cipher_hw_aes_cbc_hmac_sha256(void);
  27. #ifdef AES_CBC_HMAC_SHA_CAPABLE
  28. # include <openssl/aes.h>
  29. # include <openssl/sha.h>
  30. typedef struct prov_aes_hmac_sha_ctx_st {
  31. PROV_CIPHER_CTX base;
  32. AES_KEY ks;
  33. size_t payload_length; /* AAD length in decrypt case */
  34. union {
  35. unsigned int tls_ver;
  36. unsigned char tls_aad[16]; /* 13 used */
  37. } aux;
  38. const PROV_CIPHER_HW_AES_HMAC_SHA *hw;
  39. /* some value that are setup by set methods - that can be retrieved */
  40. unsigned int multiblock_interleave;
  41. unsigned int multiblock_aad_packlen;
  42. size_t multiblock_max_send_fragment;
  43. size_t multiblock_encrypt_len;
  44. size_t tls_aad_pad;
  45. } PROV_AES_HMAC_SHA_CTX;
  46. typedef struct prov_aes_hmac_sha1_ctx_st {
  47. PROV_AES_HMAC_SHA_CTX base_ctx;
  48. SHA_CTX head, tail, md;
  49. } PROV_AES_HMAC_SHA1_CTX;
  50. typedef struct prov_aes_hmac_sha256_ctx_st {
  51. PROV_AES_HMAC_SHA_CTX base_ctx;
  52. SHA256_CTX head, tail, md;
  53. } PROV_AES_HMAC_SHA256_CTX;
  54. # define NO_PAYLOAD_LENGTH ((size_t)-1)
  55. #endif /* AES_CBC_HMAC_SHA_CAPABLE */