Annotation of embedaddon/strongswan/src/libstrongswan/plugins/curve25519/curve25519_plugin.c, revision 1.1.1.1

1.1       misho       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: #include "curve25519_identity_hasher.h"
                     24: 
                     25: #include <library.h>
                     26: 
                     27: typedef struct private_curve25519_plugin_t private_curve25519_plugin_t;
                     28: 
                     29: /**
                     30:  * private data of curve25519_plugin
                     31:  */
                     32: struct private_curve25519_plugin_t {
                     33: 
                     34:        /**
                     35:         * public functions
                     36:         */
                     37:        curve25519_plugin_t public;
                     38: };
                     39: 
                     40: METHOD(plugin_t, get_name, char*,
                     41:        private_curve25519_plugin_t *this)
                     42: {
                     43:        return "curve25519";
                     44: }
                     45: 
                     46: METHOD(plugin_t, get_features, int,
                     47:        private_curve25519_plugin_t *this, plugin_feature_t *features[])
                     48: {
                     49:        static plugin_feature_t f[] = {
                     50:                /* X25519 DH group */
                     51:                PLUGIN_REGISTER(DH, curve25519_dh_create),
                     52:                        PLUGIN_PROVIDE(DH, CURVE_25519),
                     53:                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
                     54:                /* Ed25519 private/public keys */
                     55:                PLUGIN_REGISTER(PRIVKEY, curve25519_private_key_load, TRUE),
                     56:                        PLUGIN_PROVIDE(PRIVKEY, KEY_ED25519),
                     57:                PLUGIN_REGISTER(PRIVKEY_GEN, curve25519_private_key_gen, FALSE),
                     58:                        PLUGIN_PROVIDE(PRIVKEY_GEN, KEY_ED25519),
                     59:                                PLUGIN_DEPENDS(RNG, RNG_TRUE),
                     60:                                PLUGIN_DEPENDS(HASHER, HASH_SHA512),
                     61:                PLUGIN_REGISTER(PUBKEY, curve25519_public_key_load, TRUE),
                     62:                        PLUGIN_PROVIDE(PUBKEY, KEY_ED25519),
                     63:                /* Ed25519 signature scheme, private */
                     64:                PLUGIN_PROVIDE(PRIVKEY_SIGN, SIGN_ED25519),
                     65:                        PLUGIN_DEPENDS(HASHER, HASH_SHA512),
                     66:                /* Ed25519 signature verification scheme, public */
                     67:                PLUGIN_PROVIDE(PUBKEY_VERIFY, SIGN_ED25519),
                     68:                        PLUGIN_DEPENDS(HASHER, HASH_SHA512),
                     69:                /* register a pro forma identity hasher */
                     70:                PLUGIN_REGISTER(HASHER, curve25519_identity_hasher_create),
                     71:                        PLUGIN_PROVIDE(HASHER, HASH_IDENTITY),
                     72:        };
                     73:        *features = f;
                     74:        return countof(f);
                     75: }
                     76: 
                     77: METHOD(plugin_t, destroy, void,
                     78:        private_curve25519_plugin_t *this)
                     79: {
                     80:        free(this);
                     81: }
                     82: 
                     83: /*
                     84:  * see header file
                     85:  */
                     86: plugin_t *curve25519_plugin_create()
                     87: {
                     88:        private_curve25519_plugin_t *this;
                     89: 
                     90:        INIT(this,
                     91:                .public = {
                     92:                        .plugin = {
                     93:                                .get_name = _get_name,
                     94:                                .get_features = _get_features,
                     95:                                .destroy = _destroy,
                     96:                        },
                     97:                },
                     98:        );
                     99: 
                    100:        return &this->public.plugin;
                    101: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>