cipher_aes_ocb.h 1.3 KB

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