aegis128-neon.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (C) 2019 Linaro Ltd <ard.biesheuvel@linaro.org>
  4. */
  5. #include <asm/cpufeature.h>
  6. #include <asm/simd.h>
  7. #include "aegis.h"
  8. #include "aegis-neon.h"
  9. int aegis128_have_aes_insn __ro_after_init;
  10. bool crypto_aegis128_have_simd(void)
  11. {
  12. if (cpu_have_feature(cpu_feature(AES))) {
  13. aegis128_have_aes_insn = 1;
  14. return true;
  15. }
  16. return IS_ENABLED(CONFIG_ARM64);
  17. }
  18. void crypto_aegis128_init_simd(struct aegis_state *state,
  19. const union aegis_block *key,
  20. const u8 *iv)
  21. {
  22. scoped_ksimd()
  23. crypto_aegis128_init_neon(state, key, iv);
  24. }
  25. void crypto_aegis128_update_simd(struct aegis_state *state, const void *msg)
  26. {
  27. scoped_ksimd()
  28. crypto_aegis128_update_neon(state, msg);
  29. }
  30. void crypto_aegis128_encrypt_chunk_simd(struct aegis_state *state, u8 *dst,
  31. const u8 *src, unsigned int size)
  32. {
  33. scoped_ksimd()
  34. crypto_aegis128_encrypt_chunk_neon(state, dst, src, size);
  35. }
  36. void crypto_aegis128_decrypt_chunk_simd(struct aegis_state *state, u8 *dst,
  37. const u8 *src, unsigned int size)
  38. {
  39. scoped_ksimd()
  40. crypto_aegis128_decrypt_chunk_neon(state, dst, src, size);
  41. }
  42. int crypto_aegis128_final_simd(struct aegis_state *state,
  43. union aegis_block *tag_xor,
  44. unsigned int assoclen,
  45. unsigned int cryptlen,
  46. unsigned int authsize)
  47. {
  48. scoped_ksimd()
  49. return crypto_aegis128_final_neon(state, tag_xor, assoclen,
  50. cryptlen, authsize);
  51. }