0b1e59e979f7a14c001b842369b6c87780e54872
[strongswan.git] / src / libstrongswan / plugins / curve25519 / curve25519_plugin.c
1 /*
2 * Copyright (C) 2014 Martin Willi
3 * Copyright (C) 2014 revosec AG
4 *
5 * Copyright (C) 2016 Andreas Steffen
6 * HSR Hochschule fuer Technik Rapperswil
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
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 */
18
19 #include "curve25519_plugin.h"
20 #include "curve25519_dh.h"
21 #include "curve25519_private_key.h"
22 #include "curve25519_public_key.h"
23
24 #include <library.h>
25
26 typedef struct private_curve25519_plugin_t private_curve25519_plugin_t;
27
28 /**
29 * private data of curve25519_plugin
30 */
31 struct private_curve25519_plugin_t {
32
33 /**
34 * public functions
35 */
36 curve25519_plugin_t public;
37 };
38
39 METHOD(plugin_t, get_name, char*,
40 private_curve25519_plugin_t *this)
41 {
42 return "curve25519";
43 }
44
45 METHOD(plugin_t, get_features, int,
46 private_curve25519_plugin_t *this, plugin_feature_t *features[])
47 {
48 static plugin_feature_t f[] = {
49 /* X25519 DH group */
50 PLUGIN_REGISTER(DH, curve25519_dh_create),
51 PLUGIN_PROVIDE(DH, CURVE_25519),
52 PLUGIN_DEPENDS(RNG, RNG_STRONG),
53 /* Ed25519 private/public keys */
54 PLUGIN_REGISTER(PRIVKEY, curve25519_private_key_load, TRUE),
55 PLUGIN_PROVIDE(PRIVKEY, KEY_ED25519),
56 PLUGIN_REGISTER(PRIVKEY_GEN, curve25519_private_key_gen, FALSE),
57 PLUGIN_PROVIDE(PRIVKEY_GEN, KEY_ED25519),
58 PLUGIN_DEPENDS(RNG, RNG_TRUE),
59 PLUGIN_DEPENDS(HASHER, HASH_SHA512),
60 PLUGIN_REGISTER(PUBKEY, curve25519_public_key_load, TRUE),
61 PLUGIN_PROVIDE(PUBKEY, KEY_ED25519),
62 /* Ed25519 signature scheme, private */
63 PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ED25519),
64 PLUGIN_DEPENDS(HASHER, HASH_SHA512),
65 /* Ed25519 signature verification scheme, public */
66 PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ED25519),
67 PLUGIN_DEPENDS(HASHER, HASH_SHA512),
68 };
69 *features = f;
70 return countof(f);
71 }
72
73 METHOD(plugin_t, destroy, void,
74 private_curve25519_plugin_t *this)
75 {
76 free(this);
77 }
78
79 /*
80 * see header file
81 */
82 plugin_t *curve25519_plugin_create()
83 {
84 private_curve25519_plugin_t *this;
85
86 INIT(this,
87 .public = {
88 .plugin = {
89 .get_name = _get_name,
90 .get_features = _get_features,
91 .destroy = _destroy,
92 },
93 },
94 );
95
96 return &this->public.plugin;
97 }