vici: With start_action=start, terminate IKE_SA without children on unload
[strongswan.git] / src / libstrongswan / plugins / aesni / aesni_plugin.c
1 /*
2 * Copyright (C) 2015 Martin Willi
3 * Copyright (C) 2015 revosec AG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include "aesni_plugin.h"
17 #include "aesni_cbc.h"
18 #include "aesni_ecb.h"
19 #include "aesni_ctr.h"
20 #include "aesni_ccm.h"
21 #include "aesni_gcm.h"
22 #include "aesni_xcbc.h"
23 #include "aesni_cmac.h"
24
25 #include <stdio.h>
26
27 #include <library.h>
28 #include <utils/debug.h>
29 #include <utils/cpu_feature.h>
30
31 typedef struct private_aesni_plugin_t private_aesni_plugin_t;
32 typedef enum cpuid_feature_t cpuid_feature_t;
33
34 /**
35 * private data of aesni_plugin
36 */
37 struct private_aesni_plugin_t {
38
39 /**
40 * public functions
41 */
42 aesni_plugin_t public;
43 };
44
45 METHOD(plugin_t, get_name, char*,
46 private_aesni_plugin_t *this)
47 {
48 return "aesni";
49 }
50
51 METHOD(plugin_t, get_features, int,
52 private_aesni_plugin_t *this, plugin_feature_t *features[])
53 {
54 static plugin_feature_t f[] = {
55 PLUGIN_REGISTER(CRYPTER, aesni_cbc_create),
56 PLUGIN_PROVIDE(CRYPTER, ENCR_AES_CBC, 16),
57 PLUGIN_PROVIDE(CRYPTER, ENCR_AES_CBC, 24),
58 PLUGIN_PROVIDE(CRYPTER, ENCR_AES_CBC, 32),
59 PLUGIN_REGISTER(CRYPTER, aesni_ecb_create),
60 PLUGIN_PROVIDE(CRYPTER, ENCR_AES_ECB, 16),
61 PLUGIN_PROVIDE(CRYPTER, ENCR_AES_ECB, 24),
62 PLUGIN_PROVIDE(CRYPTER, ENCR_AES_ECB, 32),
63 PLUGIN_REGISTER(CRYPTER, aesni_ctr_create),
64 PLUGIN_PROVIDE(CRYPTER, ENCR_AES_CTR, 16),
65 PLUGIN_PROVIDE(CRYPTER, ENCR_AES_CTR, 24),
66 PLUGIN_PROVIDE(CRYPTER, ENCR_AES_CTR, 32),
67 PLUGIN_REGISTER(AEAD, aesni_ccm_create),
68 PLUGIN_PROVIDE(AEAD, ENCR_AES_CCM_ICV8, 16),
69 PLUGIN_PROVIDE(AEAD, ENCR_AES_CCM_ICV12, 16),
70 PLUGIN_PROVIDE(AEAD, ENCR_AES_CCM_ICV16, 16),
71 PLUGIN_PROVIDE(AEAD, ENCR_AES_CCM_ICV8, 24),
72 PLUGIN_PROVIDE(AEAD, ENCR_AES_CCM_ICV12, 24),
73 PLUGIN_PROVIDE(AEAD, ENCR_AES_CCM_ICV16, 24),
74 PLUGIN_PROVIDE(AEAD, ENCR_AES_CCM_ICV8, 32),
75 PLUGIN_PROVIDE(AEAD, ENCR_AES_CCM_ICV12, 32),
76 PLUGIN_PROVIDE(AEAD, ENCR_AES_CCM_ICV16, 32),
77 PLUGIN_REGISTER(AEAD, aesni_gcm_create),
78 PLUGIN_PROVIDE(AEAD, ENCR_AES_GCM_ICV8, 16),
79 PLUGIN_PROVIDE(AEAD, ENCR_AES_GCM_ICV12, 16),
80 PLUGIN_PROVIDE(AEAD, ENCR_AES_GCM_ICV16, 16),
81 PLUGIN_PROVIDE(AEAD, ENCR_AES_GCM_ICV8, 24),
82 PLUGIN_PROVIDE(AEAD, ENCR_AES_GCM_ICV12, 24),
83 PLUGIN_PROVIDE(AEAD, ENCR_AES_GCM_ICV16, 24),
84 PLUGIN_PROVIDE(AEAD, ENCR_AES_GCM_ICV8, 32),
85 PLUGIN_PROVIDE(AEAD, ENCR_AES_GCM_ICV12, 32),
86 PLUGIN_PROVIDE(AEAD, ENCR_AES_GCM_ICV16, 32),
87 PLUGIN_REGISTER(PRF, aesni_xcbc_prf_create),
88 PLUGIN_PROVIDE(PRF, PRF_AES128_XCBC),
89 PLUGIN_REGISTER(SIGNER, aesni_xcbc_signer_create),
90 PLUGIN_PROVIDE(SIGNER, AUTH_AES_XCBC_96),
91 PLUGIN_REGISTER(PRF, aesni_cmac_prf_create),
92 PLUGIN_PROVIDE(PRF, PRF_AES128_CMAC),
93 PLUGIN_REGISTER(SIGNER, aesni_cmac_signer_create),
94 PLUGIN_PROVIDE(SIGNER, AUTH_AES_CMAC_96),
95 };
96
97 *features = f;
98 if (cpu_feature_available(CPU_FEATURE_AESNI | CPU_FEATURE_PCLMULQDQ))
99 {
100 return countof(f);
101 }
102 return 0;
103 }
104
105 METHOD(plugin_t, destroy, void,
106 private_aesni_plugin_t *this)
107 {
108 free(this);
109 }
110
111 /*
112 * see header file
113 */
114 plugin_t *aesni_plugin_create()
115 {
116 private_aesni_plugin_t *this;
117
118 INIT(this,
119 .public = {
120 .plugin = {
121 .get_name = _get_name,
122 .get_features = _get_features,
123 .reload = (void*)return_false,
124 .destroy = _destroy,
125 },
126 },
127 );
128
129 return &this->public.plugin;
130 }