cipher_aes_ccm.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 "prov/ciphercommon_ccm.h"
  12. #include "crypto/aes_platform.h"
  13. typedef struct prov_aes_ccm_ctx_st {
  14. PROV_CCM_CTX base; /* Must be first */
  15. union {
  16. OSSL_UNION_ALIGN;
  17. /*-
  18. * Padding is chosen so that s390x.kmac.k overlaps with ks.ks and
  19. * fc with ks.ks.rounds. Remember that on s390x, an AES_KEY's
  20. * rounds field is used to store the function code and that the key
  21. * schedule is not stored (if aes hardware support is detected).
  22. */
  23. struct {
  24. unsigned char pad[16];
  25. AES_KEY ks;
  26. } ks;
  27. #if defined(OPENSSL_CPUID_OBJ) && defined(__s390__)
  28. struct {
  29. S390X_KMAC_PARAMS kmac;
  30. unsigned long long blocks;
  31. union {
  32. unsigned long long g[2];
  33. unsigned char b[AES_BLOCK_SIZE];
  34. } nonce;
  35. union {
  36. unsigned long long g[2];
  37. unsigned char b[AES_BLOCK_SIZE];
  38. } buf;
  39. unsigned char dummy_pad[168];
  40. unsigned int fc; /* fc has same offset as ks.ks.rounds */
  41. } s390x;
  42. #endif /* defined(OPENSSL_CPUID_OBJ) && defined(__s390__) */
  43. } ccm;
  44. } PROV_AES_CCM_CTX;
  45. const PROV_CCM_HW *ossl_prov_aes_hw_ccm(size_t keylen);