morus1280-avx2-glue.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * The MORUS-1280 Authenticated-Encryption Algorithm
  3. * Glue for AVX2 implementation
  4. *
  5. * Copyright (c) 2016-2018 Ondrej Mosnacek <omosnacek@gmail.com>
  6. * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the Free
  10. * Software Foundation; either version 2 of the License, or (at your option)
  11. * any later version.
  12. */
  13. #include <crypto/internal/aead.h>
  14. #include <crypto/morus1280_glue.h>
  15. #include <linux/module.h>
  16. #include <asm/fpu/api.h>
  17. #include <asm/cpu_device_id.h>
  18. asmlinkage void crypto_morus1280_avx2_init(void *state, const void *key,
  19. const void *iv);
  20. asmlinkage void crypto_morus1280_avx2_ad(void *state, const void *data,
  21. unsigned int length);
  22. asmlinkage void crypto_morus1280_avx2_enc(void *state, const void *src,
  23. void *dst, unsigned int length);
  24. asmlinkage void crypto_morus1280_avx2_dec(void *state, const void *src,
  25. void *dst, unsigned int length);
  26. asmlinkage void crypto_morus1280_avx2_enc_tail(void *state, const void *src,
  27. void *dst, unsigned int length);
  28. asmlinkage void crypto_morus1280_avx2_dec_tail(void *state, const void *src,
  29. void *dst, unsigned int length);
  30. asmlinkage void crypto_morus1280_avx2_final(void *state, void *tag_xor,
  31. u64 assoclen, u64 cryptlen);
  32. MORUS1280_DECLARE_ALGS(avx2, "morus1280-avx2", 400);
  33. static int __init crypto_morus1280_avx2_module_init(void)
  34. {
  35. if (!boot_cpu_has(X86_FEATURE_AVX2) ||
  36. !boot_cpu_has(X86_FEATURE_OSXSAVE) ||
  37. !cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM, NULL))
  38. return -ENODEV;
  39. return crypto_register_aeads(crypto_morus1280_avx2_algs,
  40. ARRAY_SIZE(crypto_morus1280_avx2_algs));
  41. }
  42. static void __exit crypto_morus1280_avx2_module_exit(void)
  43. {
  44. crypto_unregister_aeads(crypto_morus1280_avx2_algs,
  45. ARRAY_SIZE(crypto_morus1280_avx2_algs));
  46. }
  47. module_init(crypto_morus1280_avx2_module_init);
  48. module_exit(crypto_morus1280_avx2_module_exit);
  49. MODULE_LICENSE("GPL");
  50. MODULE_AUTHOR("Ondrej Mosnacek <omosnacek@gmail.com>");
  51. MODULE_DESCRIPTION("MORUS-1280 AEAD algorithm -- AVX2 implementation");
  52. MODULE_ALIAS_CRYPTO("morus1280");
  53. MODULE_ALIAS_CRYPTO("morus1280-avx2");