cipher_aes_gcm_hw_t4.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright 2001-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. * Fujitsu SPARC64 X support for AES GCM.
  11. * This file is included by cipher_aes_gcm_hw.c
  12. */
  13. static int t4_aes_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key,
  14. size_t keylen)
  15. {
  16. ctr128_f ctr;
  17. PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx;
  18. AES_KEY *ks = &actx->ks.ks;
  19. switch (keylen) {
  20. case 16:
  21. ctr = (ctr128_f)aes128_t4_ctr32_encrypt;
  22. break;
  23. case 24:
  24. ctr = (ctr128_f)aes192_t4_ctr32_encrypt;
  25. break;
  26. case 32:
  27. ctr = (ctr128_f)aes256_t4_ctr32_encrypt;
  28. break;
  29. default:
  30. return 0;
  31. }
  32. GCM_HW_SET_KEY_CTR_FN(ks, aes_t4_set_encrypt_key, aes_t4_encrypt, ctr);
  33. return 1;
  34. }
  35. static const PROV_GCM_HW t4_aes_gcm = {
  36. t4_aes_gcm_initkey,
  37. ossl_gcm_setiv,
  38. ossl_gcm_aad_update,
  39. generic_aes_gcm_cipher_update,
  40. ossl_gcm_cipher_final,
  41. ossl_gcm_one_shot
  42. };
  43. const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits)
  44. {
  45. return SPARC_AES_CAPABLE ? &t4_aes_gcm : &aes_gcm;
  46. }