2 * Copyright (C) 2015 Martin Willi
3 * Copyright (C) 2015 revosec AG
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>.
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
16 #include "aesni_plugin.h"
17 #include "aesni_cbc.h"
18 #include "aesni_ctr.h"
19 #include "aesni_ccm.h"
20 #include "aesni_xcbc.h"
21 #include "aesni_cmac.h"
26 #include <utils/debug.h>
27 #include <utils/cpu_feature.h>
29 typedef struct private_aesni_plugin_t private_aesni_plugin_t
;
30 typedef enum cpuid_feature_t cpuid_feature_t
;
33 * private data of aesni_plugin
35 struct private_aesni_plugin_t
{
40 aesni_plugin_t
public;
43 METHOD(plugin_t
, get_name
, char*,
44 private_aesni_plugin_t
*this)
49 METHOD(plugin_t
, get_features
, int,
50 private_aesni_plugin_t
*this, plugin_feature_t
*features
[])
52 static plugin_feature_t f
[] = {
53 PLUGIN_REGISTER(CRYPTER
, aesni_cbc_create
),
54 PLUGIN_PROVIDE(CRYPTER
, ENCR_AES_CBC
, 16),
55 PLUGIN_PROVIDE(CRYPTER
, ENCR_AES_CBC
, 24),
56 PLUGIN_PROVIDE(CRYPTER
, ENCR_AES_CBC
, 32),
57 PLUGIN_REGISTER(CRYPTER
, aesni_ctr_create
),
58 PLUGIN_PROVIDE(CRYPTER
, ENCR_AES_CTR
, 16),
59 PLUGIN_PROVIDE(CRYPTER
, ENCR_AES_CTR
, 24),
60 PLUGIN_PROVIDE(CRYPTER
, ENCR_AES_CTR
, 32),
61 PLUGIN_REGISTER(AEAD
, aesni_ccm_create
),
62 PLUGIN_PROVIDE(AEAD
, ENCR_AES_CCM_ICV8
, 16),
63 PLUGIN_PROVIDE(AEAD
, ENCR_AES_CCM_ICV12
, 16),
64 PLUGIN_PROVIDE(AEAD
, ENCR_AES_CCM_ICV16
, 16),
65 PLUGIN_PROVIDE(AEAD
, ENCR_AES_CCM_ICV8
, 24),
66 PLUGIN_PROVIDE(AEAD
, ENCR_AES_CCM_ICV12
, 24),
67 PLUGIN_PROVIDE(AEAD
, ENCR_AES_CCM_ICV16
, 24),
68 PLUGIN_PROVIDE(AEAD
, ENCR_AES_CCM_ICV8
, 32),
69 PLUGIN_PROVIDE(AEAD
, ENCR_AES_CCM_ICV12
, 32),
70 PLUGIN_PROVIDE(AEAD
, ENCR_AES_CCM_ICV16
, 32),
71 PLUGIN_REGISTER(PRF
, aesni_xcbc_prf_create
),
72 PLUGIN_PROVIDE(PRF
, PRF_AES128_XCBC
),
73 PLUGIN_REGISTER(SIGNER
, aesni_xcbc_signer_create
),
74 PLUGIN_PROVIDE(SIGNER
, AUTH_AES_XCBC_96
),
75 PLUGIN_REGISTER(PRF
, aesni_cmac_prf_create
),
76 PLUGIN_PROVIDE(PRF
, PRF_AES128_CMAC
),
77 PLUGIN_REGISTER(SIGNER
, aesni_cmac_signer_create
),
78 PLUGIN_PROVIDE(SIGNER
, AUTH_AES_CMAC_96
),
82 if (cpu_feature_available(CPU_FEATURE_AESNI
))
89 METHOD(plugin_t
, destroy
, void,
90 private_aesni_plugin_t
*this)
98 plugin_t
*aesni_plugin_create()
100 private_aesni_plugin_t
*this;
105 .get_name
= _get_name
,
106 .get_features
= _get_features
,
107 .reload
= (void*)return_false
,
113 return &this->public.plugin
;