cipher_aes_ccm.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright 2019-2021 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. /*
  10. * AES low level APIs are deprecated for public use, but still ok for internal
  11. * use where we're using them to implement the higher level EVP interface, as is
  12. * the case here.
  13. */
  14. #include "internal/deprecated.h"
  15. /* Dispatch functions for AES CCM mode */
  16. #include "cipher_aes_ccm.h"
  17. #include "prov/implementations.h"
  18. #include "prov/providercommon.h"
  19. static void *aes_ccm_newctx(void *provctx, size_t keybits)
  20. {
  21. PROV_AES_CCM_CTX *ctx;
  22. if (!ossl_prov_is_running())
  23. return NULL;
  24. ctx = OPENSSL_zalloc(sizeof(*ctx));
  25. if (ctx != NULL)
  26. ossl_ccm_initctx(&ctx->base, keybits, ossl_prov_aes_hw_ccm(keybits));
  27. return ctx;
  28. }
  29. static OSSL_FUNC_cipher_freectx_fn aes_ccm_freectx;
  30. static void aes_ccm_freectx(void *vctx)
  31. {
  32. PROV_AES_CCM_CTX *ctx = (PROV_AES_CCM_CTX *)vctx;
  33. OPENSSL_clear_free(ctx, sizeof(*ctx));
  34. }
  35. /* ossl_aes128ccm_functions */
  36. IMPLEMENT_aead_cipher(aes, ccm, CCM, AEAD_FLAGS, 128, 8, 96);
  37. /* ossl_aes192ccm_functions */
  38. IMPLEMENT_aead_cipher(aes, ccm, CCM, AEAD_FLAGS, 192, 8, 96);
  39. /* ossl_aes256ccm_functions */
  40. IMPLEMENT_aead_cipher(aes, ccm, CCM, AEAD_FLAGS, 256, 8, 96);