]> asedeno.scripts.mit.edu Git - linux.git/blob - arch/x86/crypto/morus1280-avx2-glue.c
Merge tag 'spi-fix-v5.3-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
[linux.git] / arch / x86 / crypto / morus1280-avx2-glue.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * The MORUS-1280 Authenticated-Encryption Algorithm
4  *   Glue for AVX2 implementation
5  *
6  * Copyright (c) 2016-2018 Ondrej Mosnacek <omosnacek@gmail.com>
7  * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved.
8  */
9
10 #include <crypto/internal/aead.h>
11 #include <crypto/internal/simd.h>
12 #include <crypto/morus1280_glue.h>
13 #include <linux/module.h>
14 #include <asm/fpu/api.h>
15 #include <asm/cpu_device_id.h>
16
17 asmlinkage void crypto_morus1280_avx2_init(void *state, const void *key,
18                                            const void *iv);
19 asmlinkage void crypto_morus1280_avx2_ad(void *state, const void *data,
20                                          unsigned int length);
21
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
27 asmlinkage void crypto_morus1280_avx2_enc_tail(void *state, const void *src,
28                                                void *dst, unsigned int length);
29 asmlinkage void crypto_morus1280_avx2_dec_tail(void *state, const void *src,
30                                                void *dst, unsigned int length);
31
32 asmlinkage void crypto_morus1280_avx2_final(void *state, void *tag_xor,
33                                             u64 assoclen, u64 cryptlen);
34
35 MORUS1280_DECLARE_ALG(avx2, "morus1280-avx2", 400);
36
37 static struct simd_aead_alg *simd_alg;
38
39 static int __init crypto_morus1280_avx2_module_init(void)
40 {
41         if (!boot_cpu_has(X86_FEATURE_AVX2) ||
42             !boot_cpu_has(X86_FEATURE_OSXSAVE) ||
43             !cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM, NULL))
44                 return -ENODEV;
45
46         return simd_register_aeads_compat(&crypto_morus1280_avx2_alg, 1,
47                                           &simd_alg);
48 }
49
50 static void __exit crypto_morus1280_avx2_module_exit(void)
51 {
52         simd_unregister_aeads(&crypto_morus1280_avx2_alg, 1, &simd_alg);
53 }
54
55 module_init(crypto_morus1280_avx2_module_init);
56 module_exit(crypto_morus1280_avx2_module_exit);
57
58 MODULE_LICENSE("GPL");
59 MODULE_AUTHOR("Ondrej Mosnacek <omosnacek@gmail.com>");
60 MODULE_DESCRIPTION("MORUS-1280 AEAD algorithm -- AVX2 implementation");
61 MODULE_ALIAS_CRYPTO("morus1280");
62 MODULE_ALIAS_CRYPTO("morus1280-avx2");