2
0

cipher_aria_ccm_hw.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. * Generic support for ARIA CCM.
  11. */
  12. #include "cipher_aria_ccm.h"
  13. static int ccm_aria_initkey(PROV_CCM_CTX *ctx,
  14. const unsigned char *key, size_t keylen)
  15. {
  16. PROV_ARIA_CCM_CTX *actx = (PROV_ARIA_CCM_CTX *)ctx;
  17. ossl_aria_set_encrypt_key(key, keylen * 8, &actx->ks.ks);
  18. CRYPTO_ccm128_init(&ctx->ccm_ctx, ctx->m, ctx->l, &actx->ks.ks,
  19. (block128_f)ossl_aria_encrypt);
  20. ctx->str = NULL;
  21. ctx->key_set = 1;
  22. return 1;
  23. }
  24. static const PROV_CCM_HW ccm_aria = {
  25. ccm_aria_initkey,
  26. ossl_ccm_generic_setiv,
  27. ossl_ccm_generic_setaad,
  28. ossl_ccm_generic_auth_encrypt,
  29. ossl_ccm_generic_auth_decrypt,
  30. ossl_ccm_generic_gettag
  31. };
  32. const PROV_CCM_HW *ossl_prov_aria_hw_ccm(size_t keybits)
  33. {
  34. return &ccm_aria;
  35. }