aesni: Provide a plugin stub for AES-NI instruction based crypto primitives
[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
18 #include <stdio.h>
19
20 #include <library.h>
21 #include <utils/debug.h>
22 #include <utils/cpu_feature.h>
23
24 typedef struct private_aesni_plugin_t private_aesni_plugin_t;
25 typedef enum cpuid_feature_t cpuid_feature_t;
26
27 /**
28 * private data of aesni_plugin
29 */
30 struct private_aesni_plugin_t {
31
32 /**
33 * public functions
34 */
35 aesni_plugin_t public;
36 };
37
38 METHOD(plugin_t, get_name, char*,
39 private_aesni_plugin_t *this)
40 {
41 return "aesni";
42 }
43
44 METHOD(plugin_t, get_features, int,
45 private_aesni_plugin_t *this, plugin_feature_t *features[])
46 {
47 static plugin_feature_t f[] = {
48 };
49
50 *features = f;
51 if (cpu_feature_available(CPU_FEATURE_AESNI))
52 {
53 return countof(f);
54 }
55 return 0;
56 }
57
58 METHOD(plugin_t, destroy, void,
59 private_aesni_plugin_t *this)
60 {
61 free(this);
62 }
63
64 /*
65 * see header file
66 */
67 plugin_t *aesni_plugin_create()
68 {
69 private_aesni_plugin_t *this;
70
71 INIT(this,
72 .public = {
73 .plugin = {
74 .get_name = _get_name,
75 .get_features = _get_features,
76 .reload = (void*)return_false,
77 .destroy = _destroy,
78 },
79 },
80 );
81
82 return &this->public.plugin;
83 }