2
0

cipher_aes_ocb.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 <openssl/aes.h>
  10. #include "prov/ciphercommon.h"
  11. #include "crypto/aes_platform.h"
  12. #define OCB_MAX_TAG_LEN AES_BLOCK_SIZE
  13. #define OCB_MAX_DATA_LEN AES_BLOCK_SIZE
  14. #define OCB_MAX_AAD_LEN AES_BLOCK_SIZE
  15. typedef struct prov_aes_ocb_ctx_st {
  16. PROV_CIPHER_CTX base; /* Must be first */
  17. union {
  18. OSSL_UNION_ALIGN;
  19. AES_KEY ks;
  20. } ksenc; /* AES key schedule to use for encryption/aad */
  21. union {
  22. OSSL_UNION_ALIGN;
  23. AES_KEY ks;
  24. } ksdec; /* AES key schedule to use for decryption */
  25. OCB128_CONTEXT ocb;
  26. unsigned int iv_state; /* set to one of IV_STATE_XXX */
  27. unsigned int key_set : 1;
  28. size_t taglen;
  29. size_t data_buf_len;
  30. size_t aad_buf_len;
  31. unsigned char tag[OCB_MAX_TAG_LEN];
  32. unsigned char data_buf[OCB_MAX_DATA_LEN]; /* Store partial data blocks */
  33. unsigned char aad_buf[OCB_MAX_AAD_LEN]; /* Store partial AAD blocks */
  34. } PROV_AES_OCB_CTX;
  35. const PROV_CIPHER_HW *ossl_prov_cipher_hw_aes_ocb(size_t keybits);