]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Rename diffie_hellman_t to key_exchange_t and change the interface etc.
authorTobias Brunner <tobias@strongswan.org>
Thu, 24 Oct 2019 07:49:14 +0000 (09:49 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Sun, 29 Mar 2020 11:44:22 +0000 (13:44 +0200)
This makes it more generic so we can use it for QSKE methods.

125 files changed:
scripts/dh_speed.c
src/charon-tkm/src/tkm/tkm_diffie_hellman.c
src/charon-tkm/src/tkm/tkm_diffie_hellman.h
src/charon-tkm/src/tkm/tkm_keymat.c
src/conftest/hooks/log_ke.c
src/conftest/hooks/set_proposal_number.c
src/libcharon/bus/bus.c
src/libcharon/bus/bus.h
src/libcharon/bus/listeners/listener.h
src/libcharon/config/child_cfg.c
src/libcharon/config/child_cfg.h
src/libcharon/config/ike_cfg.c
src/libcharon/config/ike_cfg.h
src/libcharon/encoding/payloads/ke_payload.c
src/libcharon/encoding/payloads/ke_payload.h
src/libcharon/encoding/payloads/proposal_substructure.c
src/libcharon/encoding/payloads/transform_substructure.h
src/libcharon/plugins/ha/ha_child.c
src/libcharon/plugins/ha/ha_dispatcher.c
src/libcharon/plugins/ha/ha_ike.c
src/libcharon/plugins/load_tester/load_tester_diffie_hellman.c
src/libcharon/plugins/load_tester/load_tester_diffie_hellman.h
src/libcharon/plugins/load_tester/load_tester_plugin.c
src/libcharon/plugins/stroke/stroke_list.c
src/libcharon/plugins/vici/vici_query.c
src/libcharon/sa/authenticator.c
src/libcharon/sa/authenticator.h
src/libcharon/sa/ikev1/authenticators/hybrid_authenticator.c
src/libcharon/sa/ikev1/authenticators/hybrid_authenticator.h
src/libcharon/sa/ikev1/authenticators/psk_v1_authenticator.c
src/libcharon/sa/ikev1/authenticators/psk_v1_authenticator.h
src/libcharon/sa/ikev1/authenticators/pubkey_v1_authenticator.c
src/libcharon/sa/ikev1/authenticators/pubkey_v1_authenticator.h
src/libcharon/sa/ikev1/keymat_v1.c
src/libcharon/sa/ikev1/keymat_v1.h
src/libcharon/sa/ikev1/phase1.c
src/libcharon/sa/ikev1/phase1.h
src/libcharon/sa/ikev1/tasks/aggressive_mode.c
src/libcharon/sa/ikev1/tasks/main_mode.c
src/libcharon/sa/ikev1/tasks/quick_mode.c
src/libcharon/sa/ikev2/keymat_v2.c
src/libcharon/sa/ikev2/keymat_v2.h
src/libcharon/sa/ikev2/tasks/child_create.c
src/libcharon/sa/ikev2/tasks/child_create.h
src/libcharon/sa/ikev2/tasks/child_rekey.c
src/libcharon/sa/ikev2/tasks/ike_init.c
src/libcharon/sa/keymat.h
src/libcharon/tests/suites/test_message_chapoly.c
src/libcharon/tests/utils/exchange_test_helper.c
src/libcharon/tests/utils/mock_dh.c
src/libcharon/tests/utils/mock_dh.h
src/libimcv/pts/pts.c
src/libimcv/pts/pts_dh_group.c
src/libimcv/pts/pts_dh_group.h
src/libstrongswan/Makefile.am
src/libstrongswan/crypto/crypto_factory.c
src/libstrongswan/crypto/crypto_factory.h
src/libstrongswan/crypto/crypto_tester.c
src/libstrongswan/crypto/crypto_tester.h
src/libstrongswan/crypto/key_exchange.c [moved from src/libstrongswan/crypto/diffie_hellman.c with 95% similarity]
src/libstrongswan/crypto/key_exchange.h [moved from src/libstrongswan/crypto/diffie_hellman.h with 56% similarity]
src/libstrongswan/crypto/proposal/proposal.c
src/libstrongswan/crypto/proposal/proposal.h
src/libstrongswan/crypto/proposal/proposal_keywords_static.txt
src/libstrongswan/crypto/transform.c
src/libstrongswan/crypto/transform.h
src/libstrongswan/plugins/botan/botan_diffie_hellman.c
src/libstrongswan/plugins/botan/botan_diffie_hellman.h
src/libstrongswan/plugins/botan/botan_ec_diffie_hellman.c
src/libstrongswan/plugins/botan/botan_ec_diffie_hellman.h
src/libstrongswan/plugins/botan/botan_plugin.c
src/libstrongswan/plugins/botan/botan_x25519.c
src/libstrongswan/plugins/botan/botan_x25519.h
src/libstrongswan/plugins/curve25519/curve25519_dh.c
src/libstrongswan/plugins/curve25519/curve25519_dh.h
src/libstrongswan/plugins/curve25519/curve25519_plugin.c
src/libstrongswan/plugins/gcrypt/gcrypt_dh.c
src/libstrongswan/plugins/gcrypt/gcrypt_dh.h
src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c
src/libstrongswan/plugins/gmp/gmp_diffie_hellman.c
src/libstrongswan/plugins/gmp/gmp_diffie_hellman.h
src/libstrongswan/plugins/gmp/gmp_plugin.c
src/libstrongswan/plugins/newhope/newhope_ke.c
src/libstrongswan/plugins/newhope/newhope_ke.h
src/libstrongswan/plugins/newhope/newhope_plugin.c
src/libstrongswan/plugins/newhope/tests/suites/test_newhope_ke.c
src/libstrongswan/plugins/ntru/ntru_ke.c
src/libstrongswan/plugins/ntru/ntru_ke.h
src/libstrongswan/plugins/ntru/ntru_plugin.c
src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c
src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h
src/libstrongswan/plugins/openssl/openssl_ec_diffie_hellman.c
src/libstrongswan/plugins/openssl/openssl_ec_diffie_hellman.h
src/libstrongswan/plugins/openssl/openssl_plugin.c
src/libstrongswan/plugins/openssl/openssl_x_diffie_hellman.c
src/libstrongswan/plugins/openssl/openssl_x_diffie_hellman.h
src/libstrongswan/plugins/pkcs11/pkcs11_dh.c
src/libstrongswan/plugins/pkcs11/pkcs11_dh.h
src/libstrongswan/plugins/pkcs11/pkcs11_plugin.c
src/libstrongswan/plugins/plugin_feature.c
src/libstrongswan/plugins/plugin_feature.h
src/libstrongswan/plugins/test_vectors/test_vectors.h
src/libstrongswan/plugins/test_vectors/test_vectors/curve25519.c
src/libstrongswan/plugins/test_vectors/test_vectors/curve448.c
src/libstrongswan/plugins/test_vectors/test_vectors/ecp.c
src/libstrongswan/plugins/test_vectors/test_vectors/ecpbp.c
src/libstrongswan/plugins/test_vectors/test_vectors/modp.c
src/libstrongswan/plugins/test_vectors/test_vectors/modpsub.c
src/libstrongswan/plugins/test_vectors/test_vectors_plugin.c
src/libstrongswan/plugins/wolfssl/wolfssl_diffie_hellman.c
src/libstrongswan/plugins/wolfssl/wolfssl_diffie_hellman.h
src/libstrongswan/plugins/wolfssl/wolfssl_ec_diffie_hellman.c
src/libstrongswan/plugins/wolfssl/wolfssl_ec_diffie_hellman.h
src/libstrongswan/plugins/wolfssl/wolfssl_plugin.c
src/libstrongswan/plugins/wolfssl/wolfssl_x_diffie_hellman.c
src/libstrongswan/plugins/wolfssl/wolfssl_x_diffie_hellman.h
src/libstrongswan/tests/suites/test_crypto_factory.c
src/libstrongswan/tests/suites/test_ntru.c
src/libstrongswan/tests/suites/test_proposal.c
src/libstrongswan/tests/suites/test_vectors.c
src/libstrongswan/tests/tests.h
src/libtls/tls_crypto.c
src/libtls/tls_crypto.h
src/libtls/tls_peer.c
src/libtls/tls_server.c

index 235772fafa3aabd30180ae297c40a3a2520b875b..8cff98997aa8e2635f611c484b802067350e9b30 100644 (file)
@@ -18,7 +18,7 @@
 #include <assert.h>
 #include <library.h>
 #include <utils/debug.h>
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 
 static void usage()
 {
@@ -28,7 +28,7 @@ static void usage()
 
 struct {
        char *name;
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 } groups[] = {
        {"modp768",                     MODP_768_BIT},
        {"modp1024",            MODP_1024_BIT},
@@ -64,43 +64,43 @@ static double end_timing(struct timespec *start)
                        (end.tv_sec - start->tv_sec) * 1.0;
 }
 
-static void run_test(diffie_hellman_group_t group, int rounds)
+static void run_test(key_exchange_method_t group, int rounds)
 {
-       diffie_hellman_t *l[rounds], *r;
+       key_exchange_t *l[rounds], *r;
        chunk_t chunk, chunks[rounds], lsecrets[rounds], rsecrets[rounds];
        struct timespec timing;
        int round;
 
-       r = lib->crypto->create_dh(lib->crypto, group);
+       r = lib->crypto->create_ke(lib->crypto, group);
        if (!r)
        {
-               printf("skipping %N, not supported\n",
-                               diffie_hellman_group_names, group);
+               printf("skipping %N, not supported\n", key_exchange_method_names,
+                          group);
                return;
        }
 
-       printf("%N:\t", diffie_hellman_group_names, group);
+       printf("%N:\t", key_exchange_method_names, group);
 
        start_timing(&timing);
        for (round = 0; round < rounds; round++)
        {
-               l[round] = lib->crypto->create_dh(lib->crypto, group);
-               assert(l[round]->get_my_public_value(l[round], &chunks[round]));
+               l[round] = lib->crypto->create_ke(lib->crypto, group);
+               assert(l[round]->get_public_key(l[round], &chunks[round]));
        }
        printf("A = g^a/s: %8.1f", rounds / end_timing(&timing));
 
        for (round = 0; round < rounds; round++)
        {
-               assert(r->set_other_public_value(r, chunks[round]));
+               assert(r->set_public_key(r, chunks[round]));
                assert(r->get_shared_secret(r, &rsecrets[round]));
                chunk_free(&chunks[round]);
        }
 
-       assert(r->get_my_public_value(r, &chunk));
+       assert(r->get_public_key(r, &chunk));
        start_timing(&timing);
        for (round = 0; round < rounds; round++)
        {
-               assert(l[round]->set_other_public_value(l[round], chunk));
+               assert(l[round]->set_public_key(l[round], chunk));
                assert(l[round]->get_shared_secret(l[round], &lsecrets[round]));
        }
        printf(" | S = B^a/s: %8.1f\n", rounds / end_timing(&timing));
index 41b557edc2138d44934f250545e717eff463ec8e..f1e91cc2e463947f82c0165848fb9aeee6552ab2 100644 (file)
@@ -39,12 +39,12 @@ struct private_tkm_diffie_hellman_t {
        tkm_diffie_hellman_t public;
 
        /**
-        * Diffie Hellman group number.
+        * Diffie-Hellman group number.
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        /**
-        * Diffie Hellman public value.
+        * Diffie-Hellman public value.
         */
        dh_pubvalue_type pubvalue;
 
@@ -55,14 +55,14 @@ struct private_tkm_diffie_hellman_t {
 
 };
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_tkm_diffie_hellman_t *this, chunk_t *value)
 {
        sequence_to_chunk(this->pubvalue.data, this->pubvalue.size, value);
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_tkm_diffie_hellman_t *this, chunk_t *secret)
 {
        *secret = chunk_empty;
@@ -70,7 +70,7 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
 }
 
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_tkm_diffie_hellman_t *this, chunk_t value)
 {
        dh_pubvalue_type othervalue;
@@ -80,13 +80,13 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return ike_dh_generate_key(this->context_id, othervalue) == TKM_OK;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_tkm_diffie_hellman_t *this)
 {
        return this->group;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_tkm_diffie_hellman_t *this)
 {
        if (ike_dh_reset(this->context_id) != TKM_OK)
@@ -106,13 +106,13 @@ METHOD(tkm_diffie_hellman_t, get_id, dh_id_type,
 
 static u_int hash(void *key)
 {
-       diffie_hellman_group_t k = *(diffie_hellman_group_t*)key;
+       key_exchange_method_t k = *(key_exchange_method_t*)key;
        return chunk_hash(chunk_from_thing(k));
 }
 
 static bool equals(void *key, void *other_key)
 {
-       return *(diffie_hellman_group_t*)key == *(diffie_hellman_group_t*)other_key;
+       return *(key_exchange_method_t*)key == *(key_exchange_method_t*)other_key;
 }
 
 /*
@@ -122,7 +122,7 @@ int register_dh_mapping()
 {
        int count, i;
        char *iana_id_str, *tkm_id_str;
-       diffie_hellman_group_t *iana_id;
+       key_exchange_method_t *iana_id;
        uint64_t *tkm_id;
        hashtable_t *map;
        enumerator_t *enumerator;
@@ -136,7 +136,7 @@ int register_dh_mapping()
 
        while (enumerator->enumerate(enumerator, &iana_id_str, &tkm_id_str))
        {
-               iana_id = malloc_thing(diffie_hellman_group_t);
+               iana_id = malloc_thing(key_exchange_method_t);
                *iana_id = settings_value_as_int(iana_id_str, 0);
                tkm_id = malloc_thing(uint64_t);
                *tkm_id = settings_value_as_int(tkm_id_str, 0);
@@ -147,13 +147,13 @@ int register_dh_mapping()
 
        count = map->get_count(map);
        plugin_feature_t f[count + 1];
-       f[0] = PLUGIN_REGISTER(DH, tkm_diffie_hellman_create);
+       f[0] = PLUGIN_REGISTER(KE, tkm_diffie_hellman_create);
 
        i = 1;
        enumerator = map->create_enumerator(map);
        while (enumerator->enumerate(enumerator, &iana_id, &tkm_id))
        {
-               f[i] = PLUGIN_PROVIDE(DH, *iana_id);
+               f[i] = PLUGIN_PROVIDE(KE, *iana_id);
                i++;
        }
        enumerator->destroy(enumerator);
@@ -197,7 +197,7 @@ void destroy_dh_mapping()
 /*
  * Described in header.
  */
-tkm_diffie_hellman_t *tkm_diffie_hellman_create(diffie_hellman_group_t group)
+tkm_diffie_hellman_t *tkm_diffie_hellman_create(key_exchange_method_t group)
 {
        private_tkm_diffie_hellman_t *this;
 
@@ -208,11 +208,11 @@ tkm_diffie_hellman_t *tkm_diffie_hellman_create(diffie_hellman_group_t group)
 
        INIT(this,
                .public = {
-                       .dh = {
+                       .ke = {
                                .get_shared_secret = _get_shared_secret,
-                               .set_other_public_value = _set_other_public_value,
-                               .get_my_public_value = _get_my_public_value,
-                               .get_dh_group = _get_dh_group,
+                               .set_public_key = _set_public_key,
+                               .get_public_key = _get_public_key,
+                               .get_method = _get_method,
                                .destroy = _destroy,
                        },
                        .get_id = _get_id,
index 19de7c874e1190b0c91a74a1529a50dbd54c134e..27df4b2fe94c3fbadfd4995a75db602121bf58bf 100644 (file)
@@ -28,14 +28,14 @@ typedef struct tkm_diffie_hellman_t tkm_diffie_hellman_t;
 #include <tkm/types.h>
 
 /**
- * diffie_hellman_t implementation using the trusted key manager.
+ * key_exchange_t implementation using the trusted key manager.
  */
 struct tkm_diffie_hellman_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 
        /**
         * Get Diffie-Hellman context id.
@@ -65,6 +65,6 @@ void destroy_dh_mapping();
  * @param group                        Diffie Hellman group number to use
  * @return                             tkm_diffie_hellman_t object, NULL if not supported
  */
-tkm_diffie_hellman_t *tkm_diffie_hellman_create(diffie_hellman_group_t group);
+tkm_diffie_hellman_t *tkm_diffie_hellman_create(key_exchange_method_t group);
 
 #endif /** TKM_DIFFIE_HELLMAN_H_ @}*/
index 1107c2219ddd13da790e044ccfe5297326cc8dd5..1fb94f50bf0b4e204a7eb813a5a17dce1ad87ecc 100644 (file)
@@ -170,10 +170,10 @@ METHOD(keymat_t, get_version, ike_version_t,
        return IKEV2;
 }
 
-METHOD(keymat_t, create_dh, diffie_hellman_t*,
-       private_tkm_keymat_t *this, diffie_hellman_group_t group)
+METHOD(keymat_t, create_ke, key_exchange_t*,
+       private_tkm_keymat_t *this, key_exchange_method_t ke)
 {
-       return lib->crypto->create_dh(lib->crypto, group);
+       return lib->crypto->create_ke(lib->crypto, ke);
 }
 
 METHOD(keymat_t, create_nonce_gen, nonce_gen_t*,
@@ -183,7 +183,7 @@ METHOD(keymat_t, create_nonce_gen, nonce_gen_t*,
 }
 
 METHOD(keymat_v2_t, derive_ike_keys, bool,
-       private_tkm_keymat_t *this, proposal_t *proposal, diffie_hellman_t *dh,
+       private_tkm_keymat_t *this, proposal_t *proposal, key_exchange_t *ke,
        chunk_t nonce_i, chunk_t nonce_r, ike_sa_id_t *id,
        pseudo_random_function_t rekey_function, chunk_t rekey_skd)
 {
@@ -238,7 +238,7 @@ METHOD(keymat_v2_t, derive_ike_keys, bool,
        }
 
        /* Get DH context id */
-       tkm_dh = (tkm_diffie_hellman_t *)dh;
+       tkm_dh = (tkm_diffie_hellman_t *)ke;
        dh_id = tkm_dh->get_id(tkm_dh);
 
        if (this->initiator)
@@ -335,16 +335,16 @@ METHOD(keymat_v2_t, derive_ike_keys, bool,
 }
 
 METHOD(keymat_v2_t, derive_child_keys, bool,
-       private_tkm_keymat_t *this, proposal_t *proposal, diffie_hellman_t *dh,
+       private_tkm_keymat_t *this, proposal_t *proposal, key_exchange_t *ke,
        chunk_t nonce_i, chunk_t nonce_r, chunk_t *encr_i, chunk_t *integ_i,
        chunk_t *encr_r, chunk_t *integ_r)
 {
        esa_info_t *esa_info_i, *esa_info_r;
        dh_id_type dh_id = 0;
 
-       if (dh)
+       if (ke)
        {
-               dh_id = ((tkm_diffie_hellman_t *)dh)->get_id((tkm_diffie_hellman_t *)dh);
+               dh_id = ((tkm_diffie_hellman_t *)ke)->get_id((tkm_diffie_hellman_t *)ke);
        }
 
        INIT(esa_info_i,
@@ -517,7 +517,7 @@ tkm_keymat_t *tkm_keymat_create(bool initiator)
                        .keymat_v2 = {
                                .keymat = {
                                        .get_version = _get_version,
-                                       .create_dh = _create_dh,
+                                       .create_ke = _create_ke,
                                        .create_nonce_gen = _create_nonce_gen,
                                        .get_aead = _get_aead,
                                        .destroy = _destroy,
index 66aa4a65e69963c44300c86bf625eb2d10815e12..b28b64cc9d9a9c532ca8861ee6ebd7433a033efb 100644 (file)
@@ -47,7 +47,7 @@ METHOD(listener_t, message, bool,
                        {
                                ke = (ke_payload_t*)payload;
                                DBG1(DBG_CFG, "received DH group %N",
-                                        diffie_hellman_group_names, ke->get_dh_group_number(ke));
+                                        key_exchange_method_names, ke->get_key_exchange_method(ke));
                        }
                }
                enumerator->destroy(enumerator);
index 3fa53680cd7ba34fc74e90163739b9ce5b95e691..49b437c43b700555ba78180d96c1c05d154af1b1 100644 (file)
@@ -109,7 +109,7 @@ METHOD(listener_t, message, bool,
                                        copy_proposal_algs(proposal, new, ENCRYPTION_ALGORITHM);
                                        copy_proposal_algs(proposal, new, INTEGRITY_ALGORITHM);
                                        copy_proposal_algs(proposal, new, PSEUDO_RANDOM_FUNCTION);
-                                       copy_proposal_algs(proposal, new, DIFFIE_HELLMAN_GROUP);
+                                       copy_proposal_algs(proposal, new, KEY_EXCHANGE_METHOD);
                                        copy_proposal_algs(proposal, new, EXTENDED_SEQUENCE_NUMBERS);
                                        updated->insert_last(updated, new);
                                }
index b7348f0f93e399c41015ef5a6e5463f3746a9458..3f72b8163a9ecd7e3de04dc2439591ab20cf343e 100644 (file)
@@ -573,7 +573,7 @@ METHOD(bus_t, message, void,
 }
 
 METHOD(bus_t, ike_keys, void,
-       private_bus_t *this, ike_sa_t *ike_sa, diffie_hellman_t *dh,
+       private_bus_t *this, ike_sa_t *ike_sa, key_exchange_t *dh,
        chunk_t dh_other, chunk_t nonce_i, chunk_t nonce_r,
        ike_sa_t *rekey, shared_key_t *shared, auth_method_t method)
 {
@@ -637,7 +637,7 @@ METHOD(bus_t, ike_derived_keys, void,
 
 METHOD(bus_t, child_keys, void,
        private_bus_t *this, child_sa_t *child_sa, bool initiator,
-       diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r)
+       key_exchange_t *dh, chunk_t nonce_i, chunk_t nonce_r)
 {
        enumerator_t *enumerator;
        ike_sa_t *ike_sa;
index abf95a4c9a49da44028ce2970b1805e5d2c9f4cb..177e8250fa6fe4817cd487725be7b5b0099055e8 100644 (file)
@@ -355,7 +355,7 @@ struct bus_t {
         * @param shared        shared key used for key derivation (IKEv1-PSK only)
         * @param method        auth method for key derivation (IKEv1-non-PSK only)
         */
-       void (*ike_keys)(bus_t *this, ike_sa_t *ike_sa, diffie_hellman_t *dh,
+       void (*ike_keys)(bus_t *this, ike_sa_t *ike_sa, key_exchange_t *dh,
                                         chunk_t dh_other, chunk_t nonce_i, chunk_t nonce_r,
                                         ike_sa_t *rekey, shared_key_t *shared,
                                         auth_method_t method);
@@ -381,7 +381,7 @@ struct bus_t {
         * @param nonce_r       responder's nonce
         */
        void (*child_keys)(bus_t *this, child_sa_t *child_sa, bool initiator,
-                                          diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r);
+                                          key_exchange_t *dh, chunk_t nonce_i, chunk_t nonce_r);
 
        /**
         * CHILD_SA derived keys hook.
index 0f3b8578a850ee37acf4a89a64b55224d0465b69..c5ee537e2e1f5ae1a9ec3e90e5374b85937880ae 100644 (file)
@@ -91,7 +91,7 @@ struct listener_t {
         * @param method        auth method for key derivation (IKEv1-non-PSK only)
         * @return                      TRUE to stay registered, FALSE to unregister
         */
-       bool (*ike_keys)(listener_t *this, ike_sa_t *ike_sa, diffie_hellman_t *dh,
+       bool (*ike_keys)(listener_t *this, ike_sa_t *ike_sa, key_exchange_t *dh,
                                         chunk_t dh_other, chunk_t nonce_i, chunk_t nonce_r,
                                         ike_sa_t *rekey, shared_key_t *shared,
                                         auth_method_t method);
@@ -120,7 +120,7 @@ struct listener_t {
         * @return                      TRUE to stay registered, FALSE to unregister
         */
        bool (*child_keys)(listener_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa,
-                                          bool initiator, diffie_hellman_t *dh,
+                                          bool initiator, key_exchange_t *dh,
                                           chunk_t nonce_i, chunk_t nonce_r);
 
        /**
index d4fb37cdcac0c580f2ce11ff28c0699f3afa8775..dc6e668bd1aa0c8fbe68b1eebb42d8614246da46 100644 (file)
@@ -205,16 +205,16 @@ CALLBACK(match_proposal, bool,
 }
 
 METHOD(child_cfg_t, get_proposals, linked_list_t*,
-       private_child_cfg_t *this, bool strip_dh)
+       private_child_cfg_t *this, bool strip_ke)
 {
        enumerator_t *enumerator;
        proposal_t *current;
        proposal_selection_flag_t flags = 0;
        linked_list_t *proposals = linked_list_create();
 
-       if (strip_dh)
+       if (strip_ke)
        {
-               flags |= PROPOSAL_SKIP_DH;
+               flags |= PROPOSAL_SKIP_KE;
        }
 
        enumerator = this->proposals->create_enumerator(this->proposals);
@@ -473,23 +473,24 @@ METHOD(child_cfg_t, get_close_action, action_t,
        return this->close_action;
 }
 
-METHOD(child_cfg_t, get_dh_group, diffie_hellman_group_t,
+METHOD(child_cfg_t, get_ke_method, key_exchange_method_t,
        private_child_cfg_t *this)
 {
        enumerator_t *enumerator;
        proposal_t *proposal;
-       uint16_t dh_group = MODP_NONE;
+       uint16_t method = MODP_NONE;
 
        enumerator = this->proposals->create_enumerator(this->proposals);
        while (enumerator->enumerate(enumerator, &proposal))
        {
-               if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP, &dh_group, NULL))
+               if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD, &method,
+                                                                       NULL))
                {
                        break;
                }
        }
        enumerator->destroy(enumerator);
-       return dh_group;
+       return method;
 }
 
 METHOD(child_cfg_t, get_inactivity, uint32_t,
@@ -653,7 +654,7 @@ child_cfg_t *child_cfg_create(char *name, child_cfg_create_t *data)
                        .get_dpd_action = _get_dpd_action,
                        .get_close_action = _get_close_action,
                        .get_lifetime = _get_lifetime,
-                       .get_dh_group = _get_dh_group,
+                       .get_ke_method = _get_ke_method,
                        .get_inactivity = _get_inactivity,
                        .get_reqid = _get_reqid,
                        .get_if_id = _get_if_id,
index b176d67bd920300b964992ce905e286c10faeafe..b7ff6a4574d433620660c582d2538ff7f1dbefde 100644 (file)
@@ -88,10 +88,10 @@ struct child_cfg_t {
         *
         * Resulting list and all of its proposals must be freed after use.
         *
-        * @param strip_dh              TRUE strip out diffie hellman groups
+        * @param strip_ke              TRUE strip out key exchange methods
         * @return                              list of proposals
         */
-       linked_list_t* (*get_proposals)(child_cfg_t *this, bool strip_dh);
+       linked_list_t* (*get_proposals)(child_cfg_t *this, bool strip_ke);
 
        /**
         * Select a proposal from a supplied list.
@@ -203,11 +203,11 @@ struct child_cfg_t {
        action_t (*get_close_action) (child_cfg_t *this);
 
        /**
-        * Get the DH group to use for CHILD_SA setup.
+        * Get the key exchange method to use for CHILD_SA setup.
         *
-        * @return                              dh group to use
+        * @return                              key exchange method to use
         */
-       diffie_hellman_group_t (*get_dh_group)(child_cfg_t *this);
+       key_exchange_method_t (*get_ke_method)(child_cfg_t *this);
 
        /**
         * Get the inactivity timeout value.
index 79a344e450727d32b1d0664ad41189b1f43abc10..589b41905c1e35c7f1f6ed1b1cc524686191c934 100644 (file)
@@ -347,23 +347,24 @@ METHOD(ike_cfg_t, select_proposal, proposal_t*,
        return proposal_select(this->proposals, proposals, flags);
 }
 
-METHOD(ike_cfg_t, get_dh_group, diffie_hellman_group_t,
+METHOD(ike_cfg_t, get_ke_method, key_exchange_method_t,
        private_ike_cfg_t *this)
 {
        enumerator_t *enumerator;
        proposal_t *proposal;
-       uint16_t dh_group = MODP_NONE;
+       uint16_t method = MODP_NONE;
 
        enumerator = this->proposals->create_enumerator(this->proposals);
        while (enumerator->enumerate(enumerator, &proposal))
        {
-               if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP, &dh_group, NULL))
+               if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD, &method,
+                                                                       NULL))
                {
                        break;
                }
        }
        enumerator->destroy(enumerator);
-       return dh_group;
+       return method;
 }
 
 METHOD(ike_cfg_t, equals, bool,
@@ -602,7 +603,7 @@ ike_cfg_t *ike_cfg_create(ike_cfg_create_t *data)
                        .get_proposals = _get_proposals,
                        .select_proposal = _select_proposal,
                        .has_proposal = _has_proposal,
-                       .get_dh_group = _get_dh_group,
+                       .get_ke_method = _get_ke_method,
                        .equals = _equals,
                        .get_ref = _get_ref,
                        .destroy = _destroy,
index 1e11a1e569b7f4a0f92432a44bb89e3cb47dcca9..ce32e756d66d75eb6aedd40c62eaa355a7ad5e49 100644 (file)
@@ -34,7 +34,7 @@ typedef struct ike_cfg_create_t ike_cfg_create_t;
 #include <collections/linked_list.h>
 #include <utils/identification.h>
 #include <crypto/proposal/proposal.h>
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 
 /**
  * IKE version.
@@ -230,11 +230,11 @@ struct ike_cfg_t {
        childless_t (*childless)(ike_cfg_t *this);
 
        /**
-        * Get the DH group to use for IKE_SA setup.
+        * Get the key exchange method to use for IKE_SA setup.
         *
-        * @return                              dh group to use for initialization
+        * @return                              key exchange method to use for initialization
         */
-       diffie_hellman_group_t (*get_dh_group)(ike_cfg_t *this);
+       key_exchange_method_t (*get_ke_method)(ike_cfg_t *this);
 
        /**
         * Check if two IKE configs are equal.
index 59e8930c1cb3fc9ce747054a1d8bf02faec85e33..278f10d93c825320a1cfdc9646c82d64d92a0aaa 100644 (file)
@@ -59,9 +59,9 @@ struct private_ke_payload_t {
        uint16_t payload_length;
 
        /**
-        * DH Group Number.
+        * Key exchange method number.
         */
-       uint16_t dh_group_number;
+       uint16_t ke_method;
 
        /**
         * Key Exchange Data of this KE payload.
@@ -92,8 +92,8 @@ static encoding_rule_t encodings_v2[] = {
        { RESERVED_BIT,                 offsetof(private_ke_payload_t, reserved_bit[6]) },
        /* Length of the whole payload*/
        { PAYLOAD_LENGTH,               offsetof(private_ke_payload_t, payload_length)  },
-       /* DH Group number as 16 bit field*/
-       { U_INT_16,                             offsetof(private_ke_payload_t, dh_group_number) },
+       /* Key exchange method number as 16 bit field*/
+       { U_INT_16,                             offsetof(private_ke_payload_t, ke_method)               },
        /* 2 reserved bytes */
        { RESERVED_BYTE,                offsetof(private_ke_payload_t, reserved_byte[0])},
        { RESERVED_BYTE,                offsetof(private_ke_payload_t, reserved_byte[1])},
@@ -107,7 +107,7 @@ static encoding_rule_t encodings_v2[] = {
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       ! Next Payload  !C!  RESERVED   !         Payload Length        !
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-      !          DH Group #           !           RESERVED            !
+      !          KE method #          !           RESERVED            !
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       !                                                               !
       ~                       Key Exchange Data                       ~
@@ -197,10 +197,10 @@ METHOD(ke_payload_t, get_key_exchange_data, chunk_t,
        return this->key_exchange_data;
 }
 
-METHOD(ke_payload_t, get_dh_group_number, diffie_hellman_group_t,
+METHOD(ke_payload_t, get_key_exchange_method, key_exchange_method_t,
        private_ke_payload_t *this)
 {
-       return this->dh_group_number;
+       return this->ke_method;
 }
 
 METHOD2(payload_t, ke_payload_t, destroy, void,
@@ -230,11 +230,11 @@ ke_payload_t *ke_payload_create(payload_type_t type)
                                .destroy = _destroy,
                        },
                        .get_key_exchange_data = _get_key_exchange_data,
-                       .get_dh_group_number = _get_dh_group_number,
+                       .get_key_exchange_method = _get_key_exchange_method,
                        .destroy = _destroy,
                },
                .next_payload = PL_NONE,
-               .dh_group_number = MODP_NONE,
+               .ke_method = MODP_NONE,
                .type = type,
        );
        this->payload_length = get_header_length(this);
@@ -244,19 +244,19 @@ ke_payload_t *ke_payload_create(payload_type_t type)
 /*
  * Described in header
  */
-ke_payload_t *ke_payload_create_from_diffie_hellman(payload_type_t type,
-                                                                                                       diffie_hellman_t *dh)
+ke_payload_t *ke_payload_create_from_key_exchange(payload_type_t type,
+                                                                                                 key_exchange_t *ke)
 {
        private_ke_payload_t *this;
        chunk_t value;
 
-       if (!dh->get_my_public_value(dh, &value))
+       if (!ke->get_public_key(ke, &value))
        {
                return NULL;
        }
        this = (private_ke_payload_t*)ke_payload_create(type);
        this->key_exchange_data = value;
-       this->dh_group_number = dh->get_dh_group(dh);
+       this->ke_method = ke->get_method(ke);
        this->payload_length += this->key_exchange_data.len;
 
        return &this->public;
index 71fffc7442b36696fb49536f9bac715fc5076c6a..25b0274964297f324ea32f906b671a2fcd68b751 100644 (file)
@@ -28,7 +28,7 @@ typedef struct ke_payload_t ke_payload_t;
 #include <encoding/payloads/payload.h>
 #include <encoding/payloads/transform_substructure.h>
 #include <collections/linked_list.h>
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 
 /**
  * Class representing an IKEv1 or IKEv2 key exchange payload.
@@ -48,11 +48,11 @@ struct ke_payload_t {
        chunk_t (*get_key_exchange_data) (ke_payload_t *this);
 
        /**
-        * Gets the Diffie-Hellman Group Number of this KE payload (IKEv2 only).
+        * Gets the key exchange method of this KE payload (IKEv2 only).
         *
-        * @return                                      DH Group Number of this payload
+        * @return              key exchange method of this payload
         */
-       diffie_hellman_group_t (*get_dh_group_number) (ke_payload_t *this);
+       key_exchange_method_t (*get_key_exchange_method)(ke_payload_t *this);
 
        /**
         * Destroys a ke_payload_t object.
@@ -69,13 +69,13 @@ struct ke_payload_t {
 ke_payload_t *ke_payload_create(payload_type_t type);
 
 /**
- * Creates a ke_payload_t from a diffie_hellman_t.
+ * Creates a ke_payload_t from a key_exchange_t.
  *
  * @param type         PLV2_KEY_EXCHANGE or PLV1_KEY_EXCHANGE
- * @param dh           diffie hellman object containing group and key
+ * @param ke           key exchange object containing method and public key
  * @return                     ke_payload_t object, NULL on error
  */
-ke_payload_t *ke_payload_create_from_diffie_hellman(payload_type_t type,
-                                                                                                       diffie_hellman_t *dh);
+ke_payload_t *ke_payload_create_from_key_exchange(payload_type_t type,
+                                                                                                 key_exchange_t *ke);
 
 #endif /** KE_PAYLOAD_H_ @}*/
index 127689eeccac84701d2bbe04e65bee77c00461f5..3f248b9f375296ec1c48e86cc4e108ecd5b86d45 100644 (file)
@@ -903,7 +903,7 @@ static void add_to_proposal_v1_ike(proposal_t *proposal,
                                                get_alg_from_ikev1(PSEUDO_RANDOM_FUNCTION, value), 0);
                                break;
                        case TATTR_PH1_GROUP:
-                               proposal->add_algorithm(proposal, DIFFIE_HELLMAN_GROUP,
+                               proposal->add_algorithm(proposal, KEY_EXCHANGE_METHOD,
                                                value, 0);
                                break;
                        default:
@@ -950,7 +950,7 @@ static void add_to_proposal_v1(proposal_t *proposal,
                                                                                get_alg_from_ikev1_auth(value), 0);
                                break;
                        case TATTR_PH2_GROUP:
-                               proposal->add_algorithm(proposal, DIFFIE_HELLMAN_GROUP,
+                               proposal->add_algorithm(proposal, KEY_EXCHANGE_METHOD,
                                                value, 0);
                                break;
                        case TATTR_PH2_EXT_SEQ_NUMBER:
@@ -1317,7 +1317,7 @@ static void set_from_proposal_v1_ike(private_proposal_substructure_t *this,
        }
        enumerator->destroy(enumerator);
 
-       enumerator = proposal->create_enumerator(proposal, DIFFIE_HELLMAN_GROUP);
+       enumerator = proposal->create_enumerator(proposal, KEY_EXCHANGE_METHOD);
        if (enumerator->enumerate(enumerator, &alg, &key_size))
        {
                transform->add_transform_attribute(transform,
@@ -1395,7 +1395,7 @@ static void set_from_proposal_v1(private_proposal_substructure_t *this,
                return;
        }
 
-       enumerator = proposal->create_enumerator(proposal, DIFFIE_HELLMAN_GROUP);
+       enumerator = proposal->create_enumerator(proposal, KEY_EXCHANGE_METHOD);
        if (enumerator->enumerate(enumerator, &alg, &key_size))
        {
                transform->add_transform_attribute(transform,
@@ -1488,11 +1488,11 @@ static void set_from_proposal_v2(private_proposal_substructure_t *this,
        enumerator->destroy(enumerator);
 
        /* dh groups */
-       enumerator = proposal->create_enumerator(proposal, DIFFIE_HELLMAN_GROUP);
+       enumerator = proposal->create_enumerator(proposal, KEY_EXCHANGE_METHOD);
        while (enumerator->enumerate(enumerator, &alg, NULL))
        {
                transform = transform_substructure_create_type(PLV2_TRANSFORM_SUBSTRUCTURE,
-                                                                                               DIFFIE_HELLMAN_GROUP, alg);
+                                                                                               KEY_EXCHANGE_METHOD, alg);
                add_transform_substructure(this, transform);
        }
        enumerator->destroy(enumerator);
index 5bbc80a81ce9fe26b9b716d04ef5f4121dc9f4f6..35bbd30ca64bca3fc9fa60a2e79ca26816f86598 100644 (file)
@@ -28,7 +28,7 @@ typedef struct transform_substructure_t transform_substructure_t;
 #include <encoding/payloads/payload.h>
 #include <encoding/payloads/transform_attribute.h>
 #include <collections/linked_list.h>
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 #include <crypto/signers/signer.h>
 #include <crypto/prfs/prf.h>
 #include <crypto/crypters/crypter.h>
index 47a26592a5c19256c04da32fe5159e655b3bf581..bbd77bb56d7a6a2b484306ecd6cd3b2f2c4b351c 100644 (file)
@@ -50,7 +50,7 @@ struct private_ha_child_t {
 
 METHOD(listener_t, child_keys, bool,
        private_ha_child_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa,
-       bool initiator, diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r)
+       bool initiator, key_exchange_t *dh, chunk_t nonce_i, chunk_t nonce_r)
 {
        ha_message_t *m;
        chunk_t secret;
@@ -91,7 +91,7 @@ METHOD(listener_t, child_keys, bool,
        {
                m->add_attribute(m, HA_ALG_INTEG, alg);
        }
-       if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP, &alg, NULL))
+       if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD, &alg, NULL))
        {
                m->add_attribute(m, HA_ALG_DH, alg);
        }
index ff75cb5c1acd27e83752a2943786a248f8f4bbaa..d4689f4cbdbe537e1cf54d79658bf5dea25d8846 100644 (file)
@@ -66,9 +66,9 @@ struct private_ha_dispatcher_t {
 struct ha_diffie_hellman_t {
 
        /**
-        * Implements diffie_hellman_t
+        * Implements key_exchange_t
         */
-       diffie_hellman_t dh;
+       key_exchange_t dh;
 
        /**
         * Shared secret
@@ -81,21 +81,21 @@ struct ha_diffie_hellman_t {
        chunk_t pub;
 };
 
-METHOD(diffie_hellman_t, dh_get_shared_secret, bool,
+METHOD(key_exchange_t, dh_get_shared_secret, bool,
        ha_diffie_hellman_t *this, chunk_t *secret)
 {
        *secret = chunk_clone(this->secret);
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, dh_get_my_public_value, bool,
+METHOD(key_exchange_t, dh_get_public_key, bool,
        ha_diffie_hellman_t *this, chunk_t *value)
 {
        *value = chunk_clone(this->pub);
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, dh_destroy, void,
+METHOD(key_exchange_t, dh_destroy, void,
        ha_diffie_hellman_t *this)
 {
        free(this);
@@ -104,14 +104,14 @@ METHOD(diffie_hellman_t, dh_destroy, void,
 /**
  * Create a HA synced DH implementation
  */
-static diffie_hellman_t *ha_diffie_hellman_create(chunk_t secret, chunk_t pub)
+static key_exchange_t *ha_diffie_hellman_create(chunk_t secret, chunk_t pub)
 {
        ha_diffie_hellman_t *this;
 
        INIT(this,
                .dh = {
                        .get_shared_secret = _dh_get_shared_secret,
-                       .get_my_public_value = _dh_get_my_public_value,
+                       .get_public_key = _dh_get_public_key,
                        .destroy = _dh_destroy,
                },
                .secret = secret,
@@ -209,7 +209,7 @@ static void process_ike_add(private_ha_dispatcher_t *this, ha_message_t *message
        if (ike_sa)
        {
                proposal_t *proposal;
-               diffie_hellman_t *dh;
+               key_exchange_t *dh;
 
                proposal = proposal_create(PROTO_IKE, 0);
                if (integ)
@@ -226,7 +226,7 @@ static void process_ike_add(private_ha_dispatcher_t *this, ha_message_t *message
                }
                if (dh_grp)
                {
-                       proposal->add_algorithm(proposal, DIFFIE_HELLMAN_GROUP, dh_grp, 0);
+                       proposal->add_algorithm(proposal, KEY_EXCHANGE_METHOD, dh_grp, 0);
                }
                charon->bus->set_sa(charon->bus, ike_sa);
                dh = ha_diffie_hellman_create(secret, dh_local);
@@ -663,7 +663,7 @@ static void process_child_add(private_ha_dispatcher_t *this,
        chunk_t nonce_i = chunk_empty, nonce_r = chunk_empty, secret = chunk_empty;
        chunk_t encr_i, integ_i, encr_r, integ_r;
        linked_list_t *local_ts, *remote_ts;
-       diffie_hellman_t *dh = NULL;
+       key_exchange_t *dh = NULL;
 
        enumerator = message->create_attribute_enumerator(message);
        while (enumerator->enumerate(enumerator, &attribute, &value))
@@ -763,7 +763,7 @@ static void process_child_add(private_ha_dispatcher_t *this,
        }
        if (dh_grp)
        {
-               proposal->add_algorithm(proposal, DIFFIE_HELLMAN_GROUP, dh_grp, 0);
+               proposal->add_algorithm(proposal, KEY_EXCHANGE_METHOD, dh_grp, 0);
        }
        proposal->add_algorithm(proposal, EXTENDED_SEQUENCE_NUMBERS, esn, 0);
        if (secret.len)
index aae402d5054bb2ea1d7f7acf386c8e3a1b148339..2fa4e27fed39bd4d5a2447ae0ae9c57ae2104f4c 100644 (file)
@@ -71,7 +71,7 @@ static ike_extension_t copy_extension(ike_sa_t *ike_sa, ike_extension_t ext)
 }
 
 METHOD(listener_t, ike_keys, bool,
-       private_ha_ike_t *this, ike_sa_t *ike_sa, diffie_hellman_t *dh,
+       private_ha_ike_t *this, ike_sa_t *ike_sa, key_exchange_t *dh,
        chunk_t dh_other, chunk_t nonce_i, chunk_t nonce_r, ike_sa_t *rekey,
        shared_key_t *shared, auth_method_t method)
 {
@@ -121,7 +121,7 @@ METHOD(listener_t, ike_keys, bool,
        {
                m->add_attribute(m, HA_ALG_PRF, alg);
        }
-       if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP, &alg, NULL))
+       if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD, &alg, NULL))
        {
                m->add_attribute(m, HA_ALG_DH, alg);
        }
@@ -131,7 +131,7 @@ METHOD(listener_t, ike_keys, bool,
        chunk_clear(&secret);
        if (ike_sa->get_version(ike_sa) == IKEV1)
        {
-               if (dh->get_my_public_value(dh, &secret))
+               if (dh->get_public_key(dh, &secret))
                {
                        m->add_attribute(m, HA_LOCAL_DH, secret);
                        chunk_free(&secret);
index 65378993cd87318090cc6040bd3f3be3024a3e98..fa2cd09650ef6fd4931a6bec43ac6acbdd155bc1 100644 (file)
 
 #include "load_tester_diffie_hellman.h"
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        load_tester_diffie_hellman_t *this, chunk_t *value)
 {
        *value = chunk_empty;
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        load_tester_diffie_hellman_t *this, chunk_t value)
 {
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        load_tester_diffie_hellman_t *this, chunk_t *secret)
 {
        *secret = chunk_empty;
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        load_tester_diffie_hellman_t *this)
 {
        return MODP_NULL;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        load_tester_diffie_hellman_t *this)
 {
        free(this);
@@ -51,7 +51,7 @@ METHOD(diffie_hellman_t, destroy, void,
  * See header
  */
 load_tester_diffie_hellman_t *load_tester_diffie_hellman_create(
-                                                                                               diffie_hellman_group_t group)
+                                                                                               key_exchange_method_t group)
 {
        load_tester_diffie_hellman_t *this;
 
@@ -61,11 +61,11 @@ load_tester_diffie_hellman_t *load_tester_diffie_hellman_create(
        }
 
        INIT(this,
-               .dh = {
+               .ke = {
                        .get_shared_secret = _get_shared_secret,
-                       .set_other_public_value = _set_other_public_value,
-                       .get_my_public_value = _get_my_public_value,
-                       .get_dh_group = _get_dh_group,
+                       .set_public_key = _set_public_key,
+                       .get_public_key = _get_public_key,
+                       .get_method = _get_method,
                        .destroy = _destroy,
                }
        );
index 3be43694401d5e8a9936aa04bfdbf08cf6675461..079d66bccf0d270c021558b358acd4e085e39c10 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef LOAD_TESTER_DIFFIE_HELLMAN_H_
 #define LOAD_TESTER_DIFFIE_HELLMAN_H_
 
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 
 typedef struct load_tester_diffie_hellman_t load_tester_diffie_hellman_t;
 
@@ -31,18 +31,18 @@ typedef struct load_tester_diffie_hellman_t load_tester_diffie_hellman_t;
 struct load_tester_diffie_hellman_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 };
 
 /**
- * Creates a new gmp_diffie_hellman_t object.
+ * Creates a new load_tester_diffie_hellman_t object.
  *
  * @param group                        Diffie Hellman group, supports MODP_NULL only
- * @return                             gmp_diffie_hellman_t object
+ * @return                             load_tester_diffie_hellman_t object
  */
 load_tester_diffie_hellman_t *load_tester_diffie_hellman_create(
-                                                                                               diffie_hellman_group_t group);
+                                                                                               key_exchange_method_t group);
 
 #endif /** LOAD_TESTER_DIFFIE_HELLMAN_H_ @}*/
index 961c10406b1c7f47baeb1dca3fc50516d5517895..36bdea78962bb3c9612d194e7f4794fc55df3d9f 100644 (file)
@@ -230,8 +230,8 @@ METHOD(plugin_t, get_features, int,
        private_load_tester_plugin_t *this, plugin_feature_t *features[])
 {
        static plugin_feature_t f[] = {
-               PLUGIN_REGISTER(DH, load_tester_diffie_hellman_create),
-                       PLUGIN_PROVIDE(DH, MODP_NULL),
+               PLUGIN_REGISTER(KE, load_tester_diffie_hellman_create),
+                       PLUGIN_PROVIDE(KE, MODP_NULL),
                                PLUGIN_DEPENDS(CUSTOM, "load-tester"),
                PLUGIN_CALLBACK((plugin_feature_callback_t)register_load_tester, NULL),
                        PLUGIN_PROVIDE(CUSTOM, "load-tester"),
index 92b18a8a67ede7fd2f6fbbd43595900b58c2c553..51fda825ae853494de1f4b1fe419bc9b5e0bd0da 100644 (file)
@@ -267,10 +267,10 @@ static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
                                                fprintf(out, "_%u", ks);
                                        }
                                }
-                               if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP,
+                               if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD,
                                                                                        &alg, NULL))
                                {
-                                       fprintf(out, "/%N", diffie_hellman_group_names, alg);
+                                       fprintf(out, "/%N", key_exchange_method_names, alg);
                                }
                                if (proposal->get_algorithm(proposal, EXTENDED_SEQUENCE_NUMBERS,
                                                                                        &alg, NULL) && alg == EXT_SEQ_NUMBERS)
@@ -850,7 +850,7 @@ static void list_algs(FILE *out)
        pseudo_random_function_t prf;
        ext_out_function_t xof;
        drbg_type_t drbg;
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
        rng_quality_t quality;
        const char *plugin_name;
        int len;
@@ -915,10 +915,10 @@ static void list_algs(FILE *out)
        enumerator->destroy(enumerator);
        fprintf(out, "\n  dh-group:  ");
        len = 13;
-       enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
+       enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
        while (enumerator->enumerate(enumerator, &group, &plugin_name))
        {
-               print_alg(out, &len, diffie_hellman_group_names, group, plugin_name);
+               print_alg(out, &len, key_exchange_method_names, group, plugin_name);
        }
        enumerator->destroy(enumerator);
        fprintf(out, "\n  random-gen:");
index ad07ff12d04748c7b207a67fff685bc2bf731c3c..9de43708191d05017be84c5e38ff7afbc1b4b334 100644 (file)
@@ -208,10 +208,10 @@ static void list_child_ipsec(vici_builder_t *b, child_sa_t *child)
                                b->add_kv(b, "integ-keysize", "%u", ks);
                        }
                }
-               if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP,
+               if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD,
                                                                        &alg, NULL))
                {
-                       b->add_kv(b, "dh-group", "%N", diffie_hellman_group_names, alg);
+                       b->add_kv(b, "dh-group", "%N", key_exchange_method_names, alg);
                }
                if (proposal->get_algorithm(proposal, EXTENDED_SEQUENCE_NUMBERS,
                                                                        &alg, NULL) && alg == EXT_SEQ_NUMBERS)
@@ -466,9 +466,9 @@ static void list_ike(private_vici_query_t *this, vici_builder_t *b,
                {
                        b->add_kv(b, "prf-alg", "%N", pseudo_random_function_names, alg);
                }
-               if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP, &alg, NULL))
+               if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD, &alg, NULL))
                {
-                       b->add_kv(b, "dh-group", "%N", diffie_hellman_group_names, alg);
+                       b->add_kv(b, "dh-group", "%N", key_exchange_method_names, alg);
                }
        }
        add_condition(b, ike_sa, "ppk", COND_PPK);
@@ -1266,7 +1266,7 @@ CALLBACK(get_algorithms, vici_message_t*,
        pseudo_random_function_t prf;
        ext_out_function_t xof;
        drbg_type_t drbg;
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
        rng_quality_t quality;
        const char *plugin_name;
 
@@ -1336,10 +1336,10 @@ CALLBACK(get_algorithms, vici_message_t*,
        b->end_section(b);
 
        b->begin_section(b, "dh");
-       enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
+       enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
        while (enumerator->enumerate(enumerator, &group, &plugin_name))
        {
-               add_algorithm(b, diffie_hellman_group_names, group, plugin_name);
+               add_algorithm(b, key_exchange_method_names, group, plugin_name);
        }
        enumerator->destroy(enumerator);
        b->end_section(b);
index b77c19d00a62018a7efeafa820d97900d39f09bf..439e8c9bbef582fa94b354596c82cf9c6bead965 100644 (file)
@@ -120,7 +120,7 @@ authenticator_t *authenticator_create_verifier(
  * Described in header.
  */
 authenticator_t *authenticator_create_v1(ike_sa_t *ike_sa, bool initiator,
-                                                               auth_method_t auth_method, diffie_hellman_t *dh,
+                                                               auth_method_t auth_method, key_exchange_t *dh,
                                                                chunk_t dh_value, chunk_t sa_payload,
                                                                chunk_t id_payload)
 {
index 58a8ca04fa9fbf4ede096d03e8c0fb008c73128b..15b08cce1caf168a47731e2eccbb220b6c25d37d 100644 (file)
@@ -237,7 +237,7 @@ authenticator_t *authenticator_create_verifier(
  * @return                                     authenticator, NULL if not supported
  */
 authenticator_t *authenticator_create_v1(ike_sa_t *ike_sa, bool initiator,
-                                                               auth_method_t auth_method, diffie_hellman_t *dh,
+                                                               auth_method_t auth_method, key_exchange_t *dh,
                                                                chunk_t dh_value, chunk_t sa_payload,
                                                                chunk_t id_payload);
 
index 689f5f376b96f9170740e61b821f6c59487ee4c0..321ac3b8c60499349f8a50ddf280f1ffc9df41d3 100644 (file)
@@ -77,7 +77,7 @@ METHOD(authenticator_t, destroy, void,
  * Described in header.
  */
 hybrid_authenticator_t *hybrid_authenticator_create(ike_sa_t *ike_sa,
-                                                                               bool initiator, diffie_hellman_t *dh,
+                                                                               bool initiator, key_exchange_t *dh,
                                                                                chunk_t dh_value, chunk_t sa_payload,
                                                                                chunk_t id_payload)
 {
index 69e5969593459370f595ca325bb5d7b85a84273a..a2fa7ea70ca3c9d12f08194ec3ab749ba6ef86a9 100644 (file)
@@ -49,7 +49,7 @@ struct hybrid_authenticator_t {
  * @return                                     hybrid authenticator
  */
 hybrid_authenticator_t *hybrid_authenticator_create(ike_sa_t *ike_sa,
-                                                                               bool initiator, diffie_hellman_t *dh,
+                                                                               bool initiator, key_exchange_t *dh,
                                                                                chunk_t dh_value, chunk_t sa_payload,
                                                                                chunk_t id_payload);
 
index ddb8c650b10484697bf76c34349af77d5381c857..8056d0dcc9ef4b728b96fbeea621c56f7719e24a 100644 (file)
@@ -44,7 +44,7 @@ struct private_psk_v1_authenticator_t {
        /**
         * DH key exchange
         */
-       diffie_hellman_t *dh;
+       key_exchange_t *dh;
 
        /**
         * Others DH public value
@@ -74,7 +74,7 @@ METHOD(authenticator_t, build, status_t,
        keymat_v1_t *keymat;
        chunk_t hash, dh;
 
-       if (!this->dh->get_my_public_value(this->dh, &dh))
+       if (!this->dh->get_public_key(this->dh, &dh))
        {
                return FAILED;
        }
@@ -111,7 +111,7 @@ METHOD(authenticator_t, process, status_t,
                return FAILED;
        }
 
-       if (!this->dh->get_my_public_value(this->dh, &dh))
+       if (!this->dh->get_public_key(this->dh, &dh))
        {
                return FAILED;
        }
@@ -150,7 +150,7 @@ METHOD(authenticator_t, destroy, void,
  * Described in header.
  */
 psk_v1_authenticator_t *psk_v1_authenticator_create(ike_sa_t *ike_sa,
-                                                                               bool initiator, diffie_hellman_t *dh,
+                                                                               bool initiator, key_exchange_t *dh,
                                                                                chunk_t dh_value, chunk_t sa_payload,
                                                                                chunk_t id_payload, bool hybrid)
 {
index cc9e18ba128a0ac89c4cc0aee68851993e081ac0..2d30e3aa464763ca515a21bd9b2b3504b6ef9a83 100644 (file)
@@ -50,7 +50,7 @@ struct psk_v1_authenticator_t {
  * @return                                     PSK authenticator
  */
 psk_v1_authenticator_t *psk_v1_authenticator_create(ike_sa_t *ike_sa,
-                                                                               bool initiator, diffie_hellman_t *dh,
+                                                                               bool initiator, key_exchange_t *dh,
                                                                                chunk_t dh_value, chunk_t sa_payload,
                                                                                chunk_t id_payload, bool hybrid);
 
index 9e5833efc2312448c9dd59e1c710607325ede2a6..6c335d11e06604dd3ef462f36c2b173188ef92ba 100644 (file)
@@ -45,7 +45,7 @@ struct private_pubkey_v1_authenticator_t {
        /**
         * DH key exchange
         */
-       diffie_hellman_t *dh;
+       key_exchange_t *dh;
 
        /**
         * Others DH public value
@@ -95,7 +95,7 @@ METHOD(authenticator_t, build, status_t,
                return NOT_FOUND;
        }
 
-       if (!this->dh->get_my_public_value(this->dh, &dh))
+       if (!this->dh->get_public_key(this->dh, &dh))
        {
                private->destroy(private);
                return FAILED;
@@ -180,7 +180,7 @@ METHOD(authenticator_t, process, status_t,
        }
 
        id = this->ike_sa->get_other_id(this->ike_sa);
-       if (!this->dh->get_my_public_value(this->dh, &dh))
+       if (!this->dh->get_public_key(this->dh, &dh))
        {
                return FAILED;
        }
@@ -237,7 +237,7 @@ METHOD(authenticator_t, destroy, void,
  * Described in header.
  */
 pubkey_v1_authenticator_t *pubkey_v1_authenticator_create(ike_sa_t *ike_sa,
-                                                                               bool initiator, diffie_hellman_t *dh,
+                                                                               bool initiator, key_exchange_t *dh,
                                                                                chunk_t dh_value, chunk_t sa_payload,
                                                                                chunk_t id_payload, key_type_t type)
 {
index 385664cf3703c66b3610a20ea8429e9b1a4c9115..80532c17f8836b1697c8213720ad2175e05edb75 100644 (file)
@@ -50,7 +50,7 @@ struct pubkey_v1_authenticator_t {
  * @return                                     pubkey authenticator
  */
 pubkey_v1_authenticator_t *pubkey_v1_authenticator_create(ike_sa_t *ike_sa,
-                                                                               bool initiator, diffie_hellman_t *dh,
+                                                                               bool initiator, key_exchange_t *dh,
                                                                                chunk_t dh_value, chunk_t sa_payload,
                                                                                chunk_t id_payload, key_type_t type);
 
index 34bae4391c317c4ec7458a0088ed8ee3a4597974..9e1c22b6f5941040778d5d5e235331774d35c446 100644 (file)
@@ -313,7 +313,7 @@ static void adjust_keylen(uint16_t alg, chunk_t *key)
 }
 
 METHOD(keymat_v1_t, derive_ike_keys, bool,
-       private_keymat_v1_t *this, proposal_t *proposal, diffie_hellman_t *dh,
+       private_keymat_v1_t *this, proposal_t *proposal, key_exchange_t *dh,
        chunk_t dh_other, chunk_t nonce_i, chunk_t nonce_r, ike_sa_id_t *id,
        auth_method_t auth, shared_key_t *shared_key)
 {
@@ -492,7 +492,7 @@ METHOD(keymat_v1_t, derive_ike_keys, bool,
                return FALSE;
        }
 
-       if (!dh->get_my_public_value(dh, &dh_me))
+       if (!dh->get_public_key(dh, &dh_me))
        {
                return FALSE;
        }
@@ -507,7 +507,7 @@ METHOD(keymat_v1_t, derive_ike_keys, bool,
 }
 
 METHOD(keymat_v1_t, derive_child_keys, bool,
-       private_keymat_v1_t *this, proposal_t *proposal, diffie_hellman_t *dh,
+       private_keymat_v1_t *this, proposal_t *proposal, key_exchange_t *dh,
        uint32_t spi_i, uint32_t spi_r, chunk_t nonce_i, chunk_t nonce_r,
        chunk_t *encr_i, chunk_t *integ_i, chunk_t *encr_r, chunk_t *integ_r)
 {
@@ -891,10 +891,10 @@ METHOD(keymat_t, get_version, ike_version_t,
        return IKEV1;
 }
 
-METHOD(keymat_t, create_dh, diffie_hellman_t*,
-       private_keymat_v1_t *this, diffie_hellman_group_t group)
+METHOD(keymat_t, create_ke, key_exchange_t*,
+       private_keymat_v1_t *this, key_exchange_method_t method)
 {
-       return lib->crypto->create_dh(lib->crypto, group);
+       return lib->crypto->create_ke(lib->crypto, method);
 }
 
 METHOD(keymat_t, create_nonce_gen, nonce_gen_t*,
@@ -933,7 +933,7 @@ keymat_v1_t *keymat_v1_create(bool initiator)
                .public = {
                        .keymat = {
                                .get_version = _get_version,
-                               .create_dh = _create_dh,
+                               .create_ke = _create_ke,
                                .create_nonce_gen = _create_nonce_gen,
                                .get_aead = _get_aead,
                                .destroy = _destroy,
index 4c89f6d760c4096a2df48c795573ddaad317d152..e515465363a71be7b5e1ab00f7487d8f93e9b972 100644 (file)
@@ -43,7 +43,7 @@ struct keymat_v1_t {
         * crypters and authentication functions.
         *
         * @param proposal              selected algorithms
-        * @param dh                    diffie hellman key allocated by create_dh()
+        * @param dh                    diffie hellman key allocated by create_ke()
         * @param dh_other              public DH value from other peer
         * @param nonce_i               initiators nonce value
         * @param nonce_r               responders nonce value
@@ -53,7 +53,7 @@ struct keymat_v1_t {
         * @return                              TRUE on success
         */
        bool (*derive_ike_keys)(keymat_v1_t *this, proposal_t *proposal,
-                                                       diffie_hellman_t *dh, chunk_t dh_other,
+                                                       key_exchange_t *dh, chunk_t dh_other,
                                                        chunk_t nonce_i, chunk_t nonce_r, ike_sa_id_t *id,
                                                        auth_method_t auth, shared_key_t *shared_key);
 
@@ -72,7 +72,7 @@ struct keymat_v1_t {
         * @param integ_r               allocated responders integrity key
         */
        bool (*derive_child_keys)(keymat_v1_t *this, proposal_t *proposal,
-                                               diffie_hellman_t *dh, uint32_t spi_i, uint32_t spi_r,
+                                               key_exchange_t *dh, uint32_t spi_i, uint32_t spi_r,
                                                chunk_t nonce_i, chunk_t nonce_r,
                                                chunk_t *encr_i, chunk_t *integ_i,
                                                chunk_t *encr_r, chunk_t *integ_r);
index f3c053d3636a745d8ec26af442acd119382718a3..5177b36cce40e34f37ff04b533755fc15c1d0373 100644 (file)
@@ -64,7 +64,7 @@ struct private_phase1_t {
        /**
         * DH exchange
         */
-       diffie_hellman_t *dh;
+       key_exchange_t *dh;
 
        /**
         * Keymat derivation (from SA)
@@ -215,9 +215,9 @@ METHOD(phase1_t, create_hasher, bool,
 }
 
 METHOD(phase1_t, create_dh, bool,
-       private_phase1_t *this, diffie_hellman_group_t group)
+       private_phase1_t *this, key_exchange_method_t group)
 {
-       this->dh = this->keymat->keymat.create_dh(&this->keymat->keymat, group);
+       this->dh = this->keymat->keymat.create_ke(&this->keymat->keymat, group);
        return this->dh != NULL;
 }
 
@@ -709,8 +709,8 @@ METHOD(phase1_t, add_nonce_ke, bool,
        nonce_gen_t *nonceg;
        chunk_t nonce;
 
-       ke_payload = ke_payload_create_from_diffie_hellman(PLV1_KEY_EXCHANGE,
-                                                                                                          this->dh);
+       ke_payload = ke_payload_create_from_key_exchange(PLV1_KEY_EXCHANGE,
+                                                                                                        this->dh);
        if (!ke_payload)
        {
                DBG1(DBG_IKE, "creating KE payload failed");
@@ -760,7 +760,7 @@ METHOD(phase1_t, get_nonce_ke, bool,
                return FALSE;
        }
        this->dh_value = chunk_clone(ke_payload->get_key_exchange_data(ke_payload));
-       if (!this->dh->set_other_public_value(this->dh, this->dh_value))
+       if (!this->dh->set_public_key(this->dh, this->dh_value))
        {
                DBG1(DBG_IKE, "unable to apply received KE value");
                return FALSE;
index eaf8908e76416de8cf4db3cc57adeda7887d8de9..157178bc35fbc8cee6177e41388ab23764286a0f 100644 (file)
@@ -24,7 +24,7 @@
 typedef struct phase1_t phase1_t;
 
 #include <sa/ike_sa.h>
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 
 /**
  * Common phase 1 helper for main and aggressive mode.
@@ -44,7 +44,7 @@ struct phase1_t {
         * @param group                 negotiated DH group
         * @return                              TRUE if group supported
         */
-       bool (*create_dh)(phase1_t *this, diffie_hellman_group_t group);
+       bool (*create_dh)(phase1_t *this, key_exchange_method_t group);
 
        /**
         * Derive key material.
index 7314f8872e53be85b6dda549c6abcb5c01356a27..f303305f58b3c61a29496ac2a7d77f263d3cea21 100644 (file)
@@ -253,7 +253,7 @@ METHOD(task_t, build_i, status_t,
 
                        message->add_payload(message, &sa_payload->payload_interface);
 
-                       group = this->ike_cfg->get_dh_group(this->ike_cfg);
+                       group = this->ike_cfg->get_ke_method(this->ike_cfg);
                        if (group == MODP_NONE)
                        {
                                DBG1(DBG_IKE, "DH group selection failed");
@@ -262,7 +262,7 @@ METHOD(task_t, build_i, status_t,
                        if (!this->ph1->create_dh(this->ph1, group))
                        {
                                DBG1(DBG_IKE, "DH group %N not supported",
-                                        diffie_hellman_group_names, group);
+                                        key_exchange_method_names, group);
                                return FAILED;
                        }
                        if (!this->ph1->add_nonce_ke(this->ph1, message))
@@ -438,7 +438,7 @@ METHOD(task_t, process_r, status_t,
                        }
 
                        if (!this->proposal->get_algorithm(this->proposal,
-                                                                               DIFFIE_HELLMAN_GROUP, &group, NULL))
+                                                                               KEY_EXCHANGE_METHOD, &group, NULL))
                        {
                                DBG1(DBG_IKE, "DH group selection failed");
                                return send_notify(this, INVALID_KEY_INFORMATION);
index 24b2f24d17e5da200018e5fa7564b6f02f2a1276..1eaf2d89ad61a1ac5f34b70b893b1a1aa963e04d 100644 (file)
@@ -309,7 +309,7 @@ METHOD(task_t, build_i, status_t,
                                return send_notify(this, NO_PROPOSAL_CHOSEN);
                        }
                        if (!this->proposal->get_algorithm(this->proposal,
-                                                                               DIFFIE_HELLMAN_GROUP, &group, NULL))
+                                                                               KEY_EXCHANGE_METHOD, &group, NULL))
                        {
                                DBG1(DBG_IKE, "DH group selection failed");
                                return send_notify(this, NO_PROPOSAL_CHOSEN);
@@ -423,7 +423,7 @@ METHOD(task_t, process_r, status_t,
                                return send_notify(this, INVALID_KEY_INFORMATION);
                        }
                        if (!this->proposal->get_algorithm(this->proposal,
-                                                                               DIFFIE_HELLMAN_GROUP, &group, NULL))
+                                                                               KEY_EXCHANGE_METHOD, &group, NULL))
                        {
                                DBG1(DBG_IKE, "DH group selection failed");
                                return send_notify(this, INVALID_KEY_INFORMATION);
index 50c280fe5804b5ac2fb044beec20a356c62ab3f1..8954b27553cc7a78b53c9f277792d344250a49ef 100644 (file)
@@ -138,7 +138,7 @@ struct private_quick_mode_t {
        /**
         * DH exchange, when PFS is in use
         */
-       diffie_hellman_t *dh;
+       key_exchange_t *dh;
 
        /**
         * Negotiated lifetime of new SA
@@ -485,8 +485,8 @@ static bool add_ke(private_quick_mode_t *this, message_t *message)
 {
        ke_payload_t *ke_payload;
 
-       ke_payload = ke_payload_create_from_diffie_hellman(PLV1_KEY_EXCHANGE,
-                                                                                                          this->dh);
+       ke_payload = ke_payload_create_from_key_exchange(PLV1_KEY_EXCHANGE,
+                                                                                                        this->dh);
        if (!ke_payload)
        {
                DBG1(DBG_IKE, "creating KE payload failed");
@@ -509,7 +509,7 @@ static bool get_ke(private_quick_mode_t *this, message_t *message)
                DBG1(DBG_IKE, "KE payload missing");
                return FALSE;
        }
-       if (!this->dh->set_other_public_value(this->dh,
+       if (!this->dh->set_public_key(this->dh,
                                                                ke_payload->get_key_exchange_data(ke_payload)))
        {
                DBG1(DBG_IKE, "unable to apply received KE value");
@@ -784,7 +784,7 @@ static status_t send_notify(private_quick_mode_t *this, notify_type_t type)
  * DH group, unless it is set to MODP_NONE.
  */
 static linked_list_t *get_proposals(private_quick_mode_t *this,
-                                                                       diffie_hellman_group_t group)
+                                                                       key_exchange_method_t group)
 {
        linked_list_t *list;
        proposal_t *proposal;
@@ -796,13 +796,13 @@ static linked_list_t *get_proposals(private_quick_mode_t *this,
        {
                if (group != MODP_NONE)
                {
-                       if (!proposal->has_dh_group(proposal, group))
+                       if (!proposal->has_ke_method(proposal, group))
                        {
                                list->remove_at(list, enumerator);
                                proposal->destroy(proposal);
                                continue;
                        }
-                       proposal->promote_dh_group(proposal, group);
+                       proposal->promote_ke_method(proposal, group);
                }
                proposal->set_spi(proposal, this->spi_i);
        }
@@ -821,7 +821,7 @@ METHOD(task_t, build_i, status_t,
                        sa_payload_t *sa_payload;
                        linked_list_t *list, *tsi, *tsr;
                        proposal_t *proposal;
-                       diffie_hellman_group_t group;
+                       key_exchange_method_t group;
                        encap_t encap;
 
                        this->mode = this->config->get_mode(this->config);
@@ -865,14 +865,14 @@ METHOD(task_t, build_i, status_t,
                                return FAILED;
                        }
 
-                       group = this->config->get_dh_group(this->config);
+                       group = this->config->get_ke_method(this->config);
                        if (group != MODP_NONE)
                        {
                                proposal_t *proposal;
                                uint16_t preferred_group;
 
                                proposal = this->ike_sa->get_proposal(this->ike_sa);
-                               proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP,
+                               proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD,
                                                                                &preferred_group, NULL);
                                /* try the negotiated DH group from IKE_SA */
                                list = get_proposals(this, preferred_group);
@@ -887,12 +887,12 @@ METHOD(task_t, build_i, status_t,
                                        list = get_proposals(this, group);
                                }
 
-                               this->dh = this->keymat->keymat.create_dh(&this->keymat->keymat,
+                               this->dh = this->keymat->keymat.create_ke(&this->keymat->keymat,
                                                                                                                  group);
                                if (!this->dh)
                                {
                                        DBG1(DBG_IKE, "configured DH group %N not supported",
-                                                diffie_hellman_group_names, group);
+                                                key_exchange_method_names, group);
                                        list->destroy_offset(list, offsetof(proposal_t, destroy));
                                        return FAILED;
                                }
@@ -1164,14 +1164,14 @@ METHOD(task_t, process_r, status_t,
                        }
 
                        if (this->proposal->get_algorithm(this->proposal,
-                                                                               DIFFIE_HELLMAN_GROUP, &group, NULL))
+                                                                               KEY_EXCHANGE_METHOD, &group, NULL))
                        {
-                               this->dh = this->keymat->keymat.create_dh(&this->keymat->keymat,
+                               this->dh = this->keymat->keymat.create_ke(&this->keymat->keymat,
                                                                                                                  group);
                                if (!this->dh)
                                {
                                        DBG1(DBG_IKE, "negotiated DH group %N not supported",
-                                                diffie_hellman_group_names, group);
+                                                key_exchange_method_names, group);
                                        return send_notify(this, INVALID_KEY_INFORMATION);
                                }
                                if (!get_ke(this, message))
index 98cba066da91b265c0bebf6c85f98590dd911a1e..50a4e3ac86ee267a0089bfea65cac5945567493e 100644 (file)
@@ -84,10 +84,10 @@ METHOD(keymat_t, get_version, ike_version_t,
        return IKEV2;
 }
 
-METHOD(keymat_t, create_dh, diffie_hellman_t*,
-       private_keymat_v2_t *this, diffie_hellman_group_t group)
+METHOD(keymat_t, create_ke, key_exchange_t*,
+       private_keymat_v2_t *this, key_exchange_method_t method)
 {
-       return lib->crypto->create_dh(lib->crypto, group);
+       return lib->crypto->create_ke(lib->crypto, method);
 }
 
 METHOD(keymat_t, create_nonce_gen, nonce_gen_t*,
@@ -299,7 +299,7 @@ failure:
 }
 
 METHOD(keymat_v2_t, derive_ike_keys, bool,
-       private_keymat_v2_t *this, proposal_t *proposal, diffie_hellman_t *dh,
+       private_keymat_v2_t *this, proposal_t *proposal, key_exchange_t *dh,
        chunk_t nonce_i, chunk_t nonce_r, ike_sa_id_t *id,
        pseudo_random_function_t rekey_function, chunk_t rekey_skd)
 {
@@ -579,7 +579,7 @@ METHOD(keymat_v2_t, derive_ike_keys_ppk, bool,
 }
 
 METHOD(keymat_v2_t, derive_child_keys, bool,
-       private_keymat_v2_t *this, proposal_t *proposal, diffie_hellman_t *dh,
+       private_keymat_v2_t *this, proposal_t *proposal, key_exchange_t *dh,
        chunk_t nonce_i, chunk_t nonce_r, chunk_t *encr_i, chunk_t *integ_i,
        chunk_t *encr_r, chunk_t *integ_r)
 {
@@ -857,7 +857,7 @@ keymat_v2_t *keymat_v2_create(bool initiator)
                .public = {
                        .keymat = {
                                .get_version = _get_version,
-                               .create_dh = _create_dh,
+                               .create_ke = _create_ke,
                                .create_nonce_gen = _create_nonce_gen,
                                .get_aead = _get_aead,
                                .destroy = _destroy,
index 3cc071aeb4f0734117a1efa986d4f22ebc40797d..d9d0967f437b736ca04e01d62b745e0f4d42c956 100644 (file)
@@ -43,7 +43,7 @@ struct keymat_v2_t {
         * crypters and authentication functions.
         *
         * @param proposal      selected algorithms
-        * @param dh            diffie hellman key allocated by create_dh()
+        * @param dh            diffie hellman key allocated by create_ke()
         * @param nonce_i       initiators nonce value
         * @param nonce_r       responders nonce value
         * @param id            IKE_SA identifier
@@ -52,7 +52,7 @@ struct keymat_v2_t {
         * @return                      TRUE on success
         */
        bool (*derive_ike_keys)(keymat_v2_t *this, proposal_t *proposal,
-                                                       diffie_hellman_t *dh, chunk_t nonce_i,
+                                                       key_exchange_t *dh, chunk_t nonce_i,
                                                        chunk_t nonce_r, ike_sa_id_t *id,
                                                        pseudo_random_function_t rekey_function,
                                                        chunk_t rekey_skd);
@@ -76,7 +76,7 @@ struct keymat_v2_t {
         * If no PFS is used for the CHILD_SA, dh can be NULL.
         *
         * @param proposal      selected algorithms
-        * @param dh            diffie hellman key allocated by create_dh(), or NULL
+        * @param dh            diffie hellman key allocated by create_ke(), or NULL
         * @param nonce_i       initiators nonce value
         * @param nonce_r       responders nonce value
         * @param encr_i        chunk to write initiators encryption key to
@@ -86,7 +86,7 @@ struct keymat_v2_t {
         * @return                      TRUE on success
         */
        bool (*derive_child_keys)(keymat_v2_t *this,
-                                                         proposal_t *proposal, diffie_hellman_t *dh,
+                                                         proposal_t *proposal, key_exchange_t *dh,
                                                          chunk_t nonce_i, chunk_t nonce_r,
                                                          chunk_t *encr_i, chunk_t *integ_i,
                                                          chunk_t *encr_r, chunk_t *integ_r);
index a642a76861b044efcbc8816d362f5689c471628e..64e8d41c536137d567998e4661db551e14d2e710 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <daemon.h>
 #include <sa/ikev2/keymat_v2.h>
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 #include <credentials/certificates/x509.h>
 #include <encoding/payloads/sa_payload.h>
 #include <encoding/payloads/ke_payload.h>
@@ -106,7 +106,7 @@ struct private_child_create_t {
        /**
         * optional diffie hellman exchange
         */
-       diffie_hellman_t *dh;
+       key_exchange_t *dh;
 
        /**
         * Applying DH public value failed?
@@ -116,7 +116,7 @@ struct private_child_create_t {
        /**
         * group used for DH exchange
         */
-       diffie_hellman_group_t dh_group;
+       key_exchange_method_t dh_group;
 
        /**
         * IKE_SAs keymat
@@ -316,7 +316,7 @@ static bool update_and_check_proposals(private_child_create_t *this)
                if (this->dh_group != MODP_NONE)
                {       /* proposals that don't contain the selected group are
                         * moved to the back */
-                       if (!proposal->promote_dh_group(proposal, this->dh_group))
+                       if (!proposal->promote_ke_method(proposal, this->dh_group))
                        {
                                this->proposals->remove_at(this->proposals, enumerator);
                                other_dh_groups->insert_last(other_dh_groups, proposal);
@@ -562,7 +562,7 @@ static status_t select_and_install(private_child_create_t *this,
 
        if (no_dh)
        {
-               flags |= PROPOSAL_SKIP_DH;
+               flags |= PROPOSAL_SKIP_KE;
        }
        if (!this->ike_sa->supports_extension(this->ike_sa, EXT_STRONGSWAN) &&
                !lib->settings->get_bool(lib->settings, "%s.accept_private_algs",
@@ -598,16 +598,16 @@ static status_t select_and_install(private_child_create_t *this,
        }
        this->child_sa->set_proposal(this->child_sa, this->proposal);
 
-       if (!this->proposal->has_dh_group(this->proposal, this->dh_group))
+       if (!this->proposal->has_ke_method(this->proposal, this->dh_group))
        {
                uint16_t group;
 
-               if (this->proposal->get_algorithm(this->proposal, DIFFIE_HELLMAN_GROUP,
+               if (this->proposal->get_algorithm(this->proposal, KEY_EXCHANGE_METHOD,
                                                                                  &group, NULL))
                {
                        DBG1(DBG_IKE, "DH group %N unacceptable, requesting %N",
-                                diffie_hellman_group_names, this->dh_group,
-                                diffie_hellman_group_names, group);
+                                key_exchange_method_names, this->dh_group,
+                                key_exchange_method_names, group);
                        this->dh_group = group;
                        return INVALID_ARG;
                }
@@ -875,8 +875,8 @@ static bool build_payloads(private_child_create_t *this, message_t *message)
        /* diffie hellman exchange, if PFS enabled */
        if (this->dh)
        {
-               ke_payload = ke_payload_create_from_diffie_hellman(PLV2_KEY_EXCHANGE,
-                                                                                                                  this->dh);
+               ke_payload = ke_payload_create_from_key_exchange(PLV2_KEY_EXCHANGE,
+                                                                                                                this->dh);
                if (!ke_payload)
                {
                        DBG1(DBG_IKE, "creating KE payload failed");
@@ -1016,18 +1016,19 @@ static void process_payloads(private_child_create_t *this, message_t *message)
                                ke_payload = (ke_payload_t*)payload;
                                if (!this->initiator)
                                {
-                                       this->dh_group = ke_payload->get_dh_group_number(ke_payload);
-                                       this->dh = this->keymat->keymat.create_dh(
+                                       this->dh_group = ke_payload->get_key_exchange_method(
+                                                                                                                                       ke_payload);
+                                       this->dh = this->keymat->keymat.create_ke(
                                                                                &this->keymat->keymat, this->dh_group);
                                }
                                else if (this->dh)
                                {
-                                       this->dh_failed = this->dh->get_dh_group(this->dh) !=
-                                                                       ke_payload->get_dh_group_number(ke_payload);
+                                       this->dh_failed = this->dh->get_method(this->dh) !=
+                                                               ke_payload->get_key_exchange_method(ke_payload);
                                }
                                if (this->dh && !this->dh_failed)
                                {
-                                       this->dh_failed = !this->dh->set_other_public_value(this->dh,
+                                       this->dh_failed = !this->dh->set_public_key(this->dh,
                                                                ke_payload->get_key_exchange_data(ke_payload));
                                }
                                break;
@@ -1095,7 +1096,7 @@ METHOD(task_t, build_i, status_t,
                        }
                        if (!this->retry && this->dh_group == MODP_NONE)
                        {       /* during a rekeying the group might already be set */
-                               this->dh_group = this->config->get_dh_group(this->config);
+                               this->dh_group = this->config->get_ke_method(this->config);
                        }
                        break;
                case IKE_AUTH:
@@ -1199,13 +1200,13 @@ METHOD(task_t, build_i, status_t,
        {
                DBG1(DBG_IKE, "requested DH group %N not contained in any of our "
                         "proposals",
-                        diffie_hellman_group_names, this->dh_group);
+                        key_exchange_method_names, this->dh_group);
                return FAILED;
        }
 
        if (this->dh_group != MODP_NONE)
        {
-               this->dh = this->keymat->keymat.create_dh(&this->keymat->keymat,
+               this->dh = this->keymat->keymat.create_ke(&this->keymat->keymat,
                                                                                                  this->dh_group);
        }
 
@@ -1690,15 +1691,15 @@ METHOD(task_t, process_i, status_t,
                                        if (this->retry)
                                        {
                                                DBG1(DBG_IKE, "already retried with DH group %N, "
-                                                        "ignore requested %N", diffie_hellman_group_names,
-                                                        this->dh_group, diffie_hellman_group_names, group);
+                                                        "ignore requested %N", key_exchange_method_names,
+                                                        this->dh_group, key_exchange_method_names, group);
                                                handle_child_sa_failure(this, message);
                                                /* an error in CHILD_SA creation is not critical */
                                                return SUCCESS;
                                        }
                                        DBG1(DBG_IKE, "peer didn't accept DH group %N, "
-                                                "it requested %N", diffie_hellman_group_names,
-                                                this->dh_group, diffie_hellman_group_names, group);
+                                                "it requested %N", key_exchange_method_names,
+                                                this->dh_group, key_exchange_method_names, group);
                                        this->retry = TRUE;
                                        this->dh_group = group;
                                        this->child_sa->set_state(this->child_sa, CHILD_RETRYING);
@@ -1793,7 +1794,7 @@ METHOD(child_create_t, use_if_ids, void,
 }
 
 METHOD(child_create_t, use_dh_group, void,
-       private_child_create_t *this, diffie_hellman_group_t dh_group)
+       private_child_create_t *this, key_exchange_method_t dh_group)
 {
        this->dh_group = dh_group;
 }
index eae1f3532f548edcc56a693229812a752ab8f5e9..2febd59484091913f60de2c6b88fb5ca3078a7af 100644 (file)
@@ -75,7 +75,7 @@ struct child_create_t {
         *
         * @param dh_group      DH group to use
         */
-       void (*use_dh_group)(child_create_t *this, diffie_hellman_group_t dh_group);
+       void (*use_dh_group)(child_create_t *this, key_exchange_method_t dh_group);
 
        /**
         * Get the lower of the two nonces, used for rekey collisions.
index 6b0f4278563d2ee1418286c6c0ff43df00ea3fdd..cc30679a391344edc116862b5cb0cbdb068b083e 100644 (file)
@@ -196,7 +196,7 @@ METHOD(task_t, build_i, status_t,
                                                                        config->get_ref(config), TRUE, NULL, NULL);
 
                proposal = this->child_sa->get_proposal(this->child_sa);
-               if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP,
+               if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD,
                                                                        &dh_group, NULL))
                {       /* reuse the DH group negotiated previously */
                        this->child_create->use_dh_group(this->child_create, dh_group);
index 477d2caae5ac9560fe4211aa67aeb85db28d124e..1c33a805cc248f0335e259ca82a58d3546a5f484 100644 (file)
@@ -23,7 +23,7 @@
 #include <bio/bio_reader.h>
 #include <bio/bio_writer.h>
 #include <sa/ikev2/keymat_v2.h>
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 #include <crypto/hashers/hash_algorithm_set.h>
 #include <encoding/payloads/sa_payload.h>
 #include <encoding/payloads/ke_payload.h>
@@ -57,12 +57,12 @@ struct private_ike_init_t {
        /**
         * diffie hellman group to use
         */
-       diffie_hellman_group_t dh_group;
+       key_exchange_method_t dh_group;
 
        /**
         * diffie hellman key exchange
         */
-       diffie_hellman_t *dh;
+       key_exchange_t *dh;
 
        /**
         * Applying DH public value failed?
@@ -332,7 +332,7 @@ static bool build_payloads(private_ike_init_t *this, message_t *message)
                                proposal->set_spi(proposal, id->get_initiator_spi(id));
                        }
                        /* move the selected DH group to the front of the proposal */
-                       if (!proposal->promote_dh_group(proposal, this->dh_group))
+                       if (!proposal->promote_ke_method(proposal, this->dh_group))
                        {       /* the proposal does not include the group, move to the back */
                                proposal_list->remove_at(proposal_list, enumerator);
                                other_dh_groups->insert_last(other_dh_groups, proposal);
@@ -362,8 +362,8 @@ static bool build_payloads(private_ike_init_t *this, message_t *message)
        }
        message->add_payload(message, (payload_t*)sa_payload);
 
-       ke_payload = ke_payload_create_from_diffie_hellman(PLV2_KEY_EXCHANGE,
-                                                                                                          this->dh);
+       ke_payload = ke_payload_create_from_key_exchange(PLV2_KEY_EXCHANGE,
+                                                                                                        this->dh);
        if (!ke_payload)
        {
                DBG1(DBG_IKE, "creating KE payload failed");
@@ -534,7 +534,7 @@ static void process_payloads(private_ike_init_t *this, message_t *message)
                        {
                                ke_payload = (ke_payload_t*)payload;
 
-                               this->dh_group = ke_payload->get_dh_group_number(ke_payload);
+                               this->dh_group = ke_payload->get_key_exchange_method(ke_payload);
                                break;
                        }
                        case PLV2_NONCE:
@@ -616,20 +616,20 @@ static void process_payloads(private_ike_init_t *this, message_t *message)
        }
 
        if (ke_payload && this->proposal &&
-               this->proposal->has_dh_group(this->proposal, this->dh_group))
+               this->proposal->has_ke_method(this->proposal, this->dh_group))
        {
                if (!this->initiator)
                {
-                       this->dh = this->keymat->keymat.create_dh(
+                       this->dh = this->keymat->keymat.create_ke(
                                                                &this->keymat->keymat, this->dh_group);
                }
                else if (this->dh)
                {
-                       this->dh_failed = this->dh->get_dh_group(this->dh) != this->dh_group;
+                       this->dh_failed = this->dh->get_method(this->dh) != this->dh_group;
                }
                if (this->dh && !this->dh_failed)
                {
-                       this->dh_failed = !this->dh->set_other_public_value(this->dh,
+                       this->dh_failed = !this->dh->set_public_key(this->dh,
                                                                ke_payload->get_key_exchange_data(ke_payload));
                }
        }
@@ -664,38 +664,38 @@ METHOD(task_t, build_i, status_t,
                        uint16_t dh_group;
 
                        proposal = this->old_sa->get_proposal(this->old_sa);
-                       if (proposal->get_algorithm(proposal, DIFFIE_HELLMAN_GROUP,
+                       if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD,
                                                                                &dh_group, NULL))
                        {
                                this->dh_group = dh_group;
                        }
                        else
                        {       /* this shouldn't happen, but let's be safe */
-                               this->dh_group = ike_cfg->get_dh_group(ike_cfg);
+                               this->dh_group = ike_cfg->get_ke_method(ike_cfg);
                        }
                }
                else
                {
-                       this->dh_group = ike_cfg->get_dh_group(ike_cfg);
+                       this->dh_group = ike_cfg->get_ke_method(ike_cfg);
                }
-               this->dh = this->keymat->keymat.create_dh(&this->keymat->keymat,
+               this->dh = this->keymat->keymat.create_ke(&this->keymat->keymat,
                                                                                                  this->dh_group);
                if (!this->dh)
                {
                        DBG1(DBG_IKE, "configured DH group %N not supported",
-                               diffie_hellman_group_names, this->dh_group);
+                               key_exchange_method_names, this->dh_group);
                        return FAILED;
                }
        }
-       else if (this->dh->get_dh_group(this->dh) != this->dh_group)
+       else if (this->dh->get_method(this->dh) != this->dh_group)
        {       /* reset DH instance if group changed (INVALID_KE_PAYLOAD) */
                this->dh->destroy(this->dh);
-               this->dh = this->keymat->keymat.create_dh(&this->keymat->keymat,
+               this->dh = this->keymat->keymat.create_ke(&this->keymat->keymat,
                                                                                                  this->dh_group);
                if (!this->dh)
                {
                        DBG1(DBG_IKE, "requested DH group %N not supported",
-                                diffie_hellman_group_names, this->dh_group);
+                                key_exchange_method_names, this->dh_group);
                        return FAILED;
                }
        }
@@ -828,16 +828,16 @@ METHOD(task_t, build_r, status_t,
        }
 
        if (this->dh == NULL ||
-               !this->proposal->has_dh_group(this->proposal, this->dh_group))
+               !this->proposal->has_ke_method(this->proposal, this->dh_group))
        {
                uint16_t group;
 
-               if (this->proposal->get_algorithm(this->proposal, DIFFIE_HELLMAN_GROUP,
+               if (this->proposal->get_algorithm(this->proposal, KEY_EXCHANGE_METHOD,
                                                                                  &group, NULL))
                {
                        DBG1(DBG_IKE, "DH group %N unacceptable, requesting %N",
-                                diffie_hellman_group_names, this->dh_group,
-                                diffie_hellman_group_names, group);
+                                key_exchange_method_names, this->dh_group,
+                                key_exchange_method_names, group);
                        this->dh_group = group;
                        group = htons(group);
                        message->add_notify(message, FALSE, INVALID_KE_PAYLOAD,
@@ -975,14 +975,14 @@ METHOD(task_t, process_i, status_t,
                                case INVALID_KE_PAYLOAD:
                                {
                                        chunk_t data;
-                                       diffie_hellman_group_t bad_group;
+                                       key_exchange_method_t bad_group;
 
                                        bad_group = this->dh_group;
                                        data = notify->get_notification_data(notify);
                                        this->dh_group = ntohs(*((uint16_t*)data.ptr));
                                        DBG1(DBG_IKE, "peer didn't accept DH group %N, "
-                                                "it requested %N", diffie_hellman_group_names,
-                                                bad_group, diffie_hellman_group_names, this->dh_group);
+                                                "it requested %N", key_exchange_method_names,
+                                                bad_group, key_exchange_method_names, this->dh_group);
 
                                        if (this->old_sa == NULL)
                                        {       /* reset the IKE_SA if we are not rekeying */
@@ -1063,7 +1063,7 @@ METHOD(task_t, process_i, status_t,
        }
 
        if (this->dh == NULL ||
-               !this->proposal->has_dh_group(this->proposal, this->dh_group))
+               !this->proposal->has_ke_method(this->proposal, this->dh_group))
        {
                DBG1(DBG_IKE, "peer DH group selection invalid");
                return FAILED;
index c05dcb35bea5c909330a5b8e57ef8563b676dcc2..68d4811f63f62f3bbb08a71a358e18f5a2daaed5 100644 (file)
@@ -52,22 +52,21 @@ struct keymat_t {
        ike_version_t (*get_version)(keymat_t *this);
 
        /**
-        * Create a diffie hellman object for key agreement.
+        * Create a key exchange object for key agreement.
         *
-        * The diffie hellman is either for IKE negotiation/rekeying or
-        * CHILD_SA rekeying (using PFS). The resulting DH object must be passed
-        * to derive_keys or to derive_child_keys and destroyed after use.
+        * The key exchange is either for IKE negotiation/rekeying or
+        * CHILD_SA rekeying (using PFS). The resulting object must be passed
+        * to derive_ike_keys() or to derive_child_keys() and destroyed after use.
         *
-        * Only DH objects allocated through this method are passed to other
-        * keymat_t methods, allowing private DH implementations. In some cases
-        * (such as retrying with a COOKIE), a DH object allocated from a different
+        * Only objects allocated through this method are passed to other
+        * keymat_t methods, allowing private KE implementations. In some cases
+        * (such as retrying with a COOKIE), a KE object allocated from a different
         * keymat_t instance may be passed to other methods.
         *
-        * @param group                 diffie hellman group
-        * @return                              DH object, NULL if group not supported
+        * @param method                key exchange method
+        * @return                              key exchange object, NULL if method not supported
         */
-       diffie_hellman_t* (*create_dh)(keymat_t *this,
-                                                                  diffie_hellman_group_t group);
+       key_exchange_t* (*create_ke)(keymat_t *this, key_exchange_method_t method);
 
        /**
         * Create a nonce generator object.
index f4a74abb4a4bb26db58f1026253e5a6995555453..ba7908e0344d2b110bd76f1818a89d3ca8bf0c6b 100644 (file)
@@ -73,7 +73,7 @@ START_TEST(test_chacha20poly1305)
        chunk_t chunk, exp;
        keymat_t keymat = {
                .get_version = _get_version,
-               .create_dh = (void*)return_null,
+               .create_ke = (void*)return_null,
                .create_nonce_gen = (void*)return_null,
                .get_aead = _get_aead,
        };
index 97fa6fecd83d651b0620ae1f44897e8788adc8b5..5faaf1dc6d82f48a733a7b0ac033762fc87287aa 100644 (file)
@@ -331,11 +331,11 @@ void exchange_test_helper_init(char *plugins)
        private_exchange_test_helper_t *this;
        private_backend_t *backend;
        plugin_feature_t features[] = {
-               PLUGIN_REGISTER(DH, mock_dh_create),
+               PLUGIN_REGISTER(KE, mock_dh_create),
                        /* we only need to support a limited number of DH groups */
-                       PLUGIN_PROVIDE(DH, MODP_2048_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_3072_BIT),
-                       PLUGIN_PROVIDE(DH, ECP_256_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_2048_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_3072_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_256_BIT),
                PLUGIN_REGISTER(NONCE_GEN, create_nonce_gen),
                        PLUGIN_PROVIDE(NONCE_GEN),
                                PLUGIN_DEPENDS(RNG, RNG_WEAK),
index 153bf1166455b2ccf14bbdbc3e391a8df2df95a6..2d93b3056f3a5c210f38f00f687581a10cd70d94 100644 (file)
@@ -26,41 +26,41 @@ struct private_diffie_hellman_t {
        /**
         * Public interface
         */
-       diffie_hellman_t public;
+       key_exchange_t public;
 
        /**
-        * Instantiated DH group
+        * Instantiated key exchagne method
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t method;
 };
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_diffie_hellman_t *this, chunk_t *value)
 {
        *value = chunk_empty;
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_diffie_hellman_t *this, chunk_t value)
 {
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_diffie_hellman_t *this, chunk_t *secret)
 {
        *secret = chunk_empty;
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_diffie_hellman_t *this)
 {
-       return this->group;
+       return this->method;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_diffie_hellman_t *this)
 {
        free(this);
@@ -69,19 +69,19 @@ METHOD(diffie_hellman_t, destroy, void,
 /**
  * See header
  */
-diffie_hellman_t *mock_dh_create(diffie_hellman_group_t group)
+key_exchange_t *mock_dh_create(key_exchange_method_t method)
 {
        private_diffie_hellman_t *this;
 
        INIT(this,
                .public = {
                        .get_shared_secret = _get_shared_secret,
-                       .set_other_public_value = _set_other_public_value,
-                       .get_my_public_value = _get_my_public_value,
-                       .get_dh_group = _get_dh_group,
+                       .set_public_key = _set_public_key,
+                       .get_public_key = _get_public_key,
+                       .get_method = _get_method,
                        .destroy = _destroy,
                },
-               .group = group,
+               .method = method,
        );
        return &this->public;
 }
index 332c65537b946755235422a3b300452587245c9c..91a5d164a8a3937df7055f2baa84c39c575bfbcf 100644 (file)
 #ifndef MOCK_DH_H_
 #define MOCK_DH_H_
 
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 
 /**
- * Creates a diffie_hellman_t object.
+ * Creates a key_exchange_t object.
  *
- * @param group                        Diffie Hellman group, supports MODP_NULL only
+ * @param method               key_exchange method, supports MODP_NULL only
  * @return                             created object
  */
-diffie_hellman_t *mock_dh_create(diffie_hellman_group_t group);
+key_exchange_t *mock_dh_create(key_exchange_method_t method);
 
 #endif /** MOCK_DH_H_ @}*/
index 7321d6708b985b4401632e67fd4c8b1ca3018e9d..963a11f28deb6a0ca98b2490297af8cce70609df 100644 (file)
@@ -68,7 +68,7 @@ struct private_pts_t {
        /**
         * PTS Diffie-Hellman Secret
         */
-       diffie_hellman_t *dh;
+       key_exchange_t *dh;
 
        /**
         * PTS Diffie-Hellman Initiator Nonce
@@ -188,15 +188,15 @@ METHOD(pts_t, set_dh_hash_algorithm, void,
 METHOD(pts_t, create_dh_nonce, bool,
        private_pts_t *this, pts_dh_group_t group, int nonce_len)
 {
-       diffie_hellman_group_t dh_group;
+       key_exchange_method_t dh_group;
        chunk_t *nonce;
        rng_t *rng;
 
        dh_group = pts_dh_group_to_ike(group);
        DBG2(DBG_PTS, "selected PTS DH group is %N",
-                                  diffie_hellman_group_names, dh_group);
+                                  key_exchange_method_names, dh_group);
        DESTROY_IF(this->dh);
-       this->dh = lib->crypto->create_dh(lib->crypto, dh_group);
+       this->dh = lib->crypto->create_ke(lib->crypto, dh_group);
 
        rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
        if (!rng)
@@ -220,7 +220,7 @@ METHOD(pts_t, create_dh_nonce, bool,
 METHOD(pts_t, get_my_public_value, bool,
        private_pts_t *this, chunk_t *value, chunk_t *nonce)
 {
-       if (!this->dh->get_my_public_value(this->dh, value))
+       if (!this->dh->get_public_key(this->dh, value))
        {
                return FALSE;
        }
@@ -231,7 +231,7 @@ METHOD(pts_t, get_my_public_value, bool,
 METHOD(pts_t, set_peer_public_value, bool,
        private_pts_t *this, chunk_t value, chunk_t nonce)
 {
-       if (!this->dh->set_other_public_value(this->dh, value))
+       if (!this->dh->set_public_key(this->dh, value))
        {
                return FALSE;
        }
index 305b4ec4fbf4b96e329e2c4635c30a4d348f8d49..02f772222b531023c0b4055897927feb618b7837 100644 (file)
 bool pts_dh_group_probe(pts_dh_group_t *dh_groups, bool mandatory_dh_groups)
 {
        enumerator_t *enumerator;
-       diffie_hellman_group_t dh_group;
+       key_exchange_method_t dh_group;
        const char *plugin_name;
        char format1[] = "  %s PTS DH group %N[%s] available";
        char format2[] = "  %s PTS DH group %N not available";
 
        *dh_groups = PTS_DH_GROUP_NONE;
 
-       enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
+       enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
        while (enumerator->enumerate(enumerator, &dh_group, &plugin_name))
        {
                if (dh_group == MODP_1024_BIT)
                {
                        *dh_groups |= PTS_DH_GROUP_IKE2;
-                       DBG2(DBG_PTS, format1, "optional ", diffie_hellman_group_names,
+                       DBG2(DBG_PTS, format1, "optional ", key_exchange_method_names,
                                                                        dh_group, plugin_name);
                }
                else if (dh_group == MODP_1536_BIT)
                {
                        *dh_groups |= PTS_DH_GROUP_IKE5;
-                       DBG2(DBG_PTS, format1, "optional ", diffie_hellman_group_names,
+                       DBG2(DBG_PTS, format1, "optional ", key_exchange_method_names,
                                                                        dh_group, plugin_name);
                }
                else if (dh_group == MODP_2048_BIT)
                {
                        *dh_groups |= PTS_DH_GROUP_IKE14;
-                       DBG2(DBG_PTS, format1, "optional ", diffie_hellman_group_names,
+                       DBG2(DBG_PTS, format1, "optional ", key_exchange_method_names,
                                                                        dh_group, plugin_name);
                }
                else if (dh_group == ECP_256_BIT)
                {
                        *dh_groups |= PTS_DH_GROUP_IKE19;
-                       DBG2(DBG_PTS, format1, "mandatory", diffie_hellman_group_names,
+                       DBG2(DBG_PTS, format1, "mandatory", key_exchange_method_names,
                                                                        dh_group, plugin_name);
                }
                else if (dh_group == ECP_384_BIT)
                {
                        *dh_groups |= PTS_DH_GROUP_IKE20;
-                       DBG2(DBG_PTS, format1, "optional ", diffie_hellman_group_names,
+                       DBG2(DBG_PTS, format1, "optional ", key_exchange_method_names,
                                                                        dh_group, plugin_name);
                }
        }
@@ -78,7 +78,7 @@ bool pts_dh_group_probe(pts_dh_group_t *dh_groups, bool mandatory_dh_groups)
        }
        if (mandatory_dh_groups)
        {
-               DBG1(DBG_PTS, format2, "mandatory", diffie_hellman_group_names,
+               DBG1(DBG_PTS, format2, "mandatory", key_exchange_method_names,
                                                                                        ECP_256_BIT);
                return FALSE;
        }
@@ -164,7 +164,7 @@ pts_dh_group_t pts_dh_group_select(pts_dh_group_t supported_dh_groups,
 /**
  * Described in header.
  */
-diffie_hellman_group_t pts_dh_group_to_ike(pts_dh_group_t dh_group)
+key_exchange_method_t pts_dh_group_to_ike(pts_dh_group_t dh_group)
 {
        switch (dh_group)
        {
index 6e8c989cc2ac11a87909d84b114b8898f2e9001b..2f482db5fe48acc01195d86cdc052773e6250c3a 100644 (file)
@@ -22,7 +22,7 @@
 #define PTS_DH_GROUP_H_
 
 #include <library.h>
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 
 typedef enum pts_dh_group_t pts_dh_group_t;
 
@@ -97,11 +97,11 @@ pts_dh_group_t pts_dh_group_select(pts_dh_group_t supported_groups,
                                                                   pts_dh_group_t offered_groups);
 
 /**
- * Convert pts_dh_group_t to diffie_hellman_group_t
+ * Convert pts_dh_group_t to key_exchange_method_t
  *
  * @param dh_group                     PTS DH group type
  * @return                                     IKE DH group type
  */
-diffie_hellman_group_t pts_dh_group_to_ike(pts_dh_group_t dh_group);
+key_exchange_method_t pts_dh_group_to_ike(pts_dh_group_t dh_group);
 
 #endif /** PTS_DH_GROUP_H_ @}*/
index fda7463edd00d4a170606f1fd5646fbf71011dbd..cd91f7b0ecb5d0df6ecba061797a079c61a2832a 100644 (file)
@@ -13,7 +13,7 @@ crypto/prfs/prf.c crypto/prfs/mac_prf.c crypto/pkcs5.c \
 crypto/rngs/rng.c crypto/rngs/rng_tester.c \
 crypto/prf_plus.c crypto/signers/signer.c \
 crypto/signers/mac_signer.c crypto/crypto_factory.c crypto/crypto_tester.c \
-crypto/diffie_hellman.c crypto/aead.c crypto/transform.c \
+crypto/key_exchange.c crypto/aead.c crypto/transform.c \
 crypto/iv/iv_gen.c crypto/iv/iv_gen_rand.c crypto/iv/iv_gen_seq.c \
 crypto/iv/iv_gen_null.c \
 crypto/xofs/xof.c crypto/xofs/xof_bitspender.c \
@@ -76,7 +76,7 @@ crypto/proposal/proposal_keywords.h crypto/proposal/proposal_keywords_static.h \
 crypto/rngs/rng.h crypto/rngs/rng_tester.h \
 crypto/prfs/prf.h crypto/prfs/mac_prf.h crypto/nonce_gen.h \
 crypto/prf_plus.h crypto/signers/signer.h crypto/signers/mac_signer.h \
-crypto/crypto_factory.h crypto/crypto_tester.h crypto/diffie_hellman.h \
+crypto/crypto_factory.h crypto/crypto_tester.h crypto/key_exchange.h \
 crypto/aead.h crypto/transform.h crypto/pkcs5.h crypto/iv/iv_gen.h \
 crypto/iv/iv_gen_rand.h crypto/iv/iv_gen_seq.h crypto/iv/iv_gen_null.h \
 crypto/xofs/xof.h crypto/xofs/xof_bitspender.h crypto/xofs/mgf1.h \
index 62b9806966fa56b1eb8e0106bc60c025df0fe64f..6d8f2fbff6bc7eb9090fe58b28fead4d4194b97a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2014 Tobias Brunner
+ * Copyright (C) 2013-2019 Tobias Brunner
  * Copyright (C) 2008 Martin Willi
  * Copyright (C) 2016-2019 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
@@ -56,7 +56,7 @@ struct entry_t {
                drbg_constructor_t create_drbg;
                rng_constructor_t create_rng;
                nonce_gen_constructor_t create_nonce_gen;
-               dh_constructor_t create_dh;
+               ke_constructor_t create_ke;
                void *create;
        };
 };
@@ -119,9 +119,9 @@ struct private_crypto_factory_t {
        linked_list_t *nonce_gens;
 
        /**
-        * registered diffie hellman, as entry_t
+        * registered key exchange methods, as entry_t
         */
-       linked_list_t *dhs;
+       linked_list_t *kes;
 
        /**
         * test manager to test crypto algorithms
@@ -437,37 +437,33 @@ METHOD(crypto_factory_t, create_nonce_gen, nonce_gen_t*,
        return nonce_gen;
 }
 
-METHOD(crypto_factory_t, create_dh, diffie_hellman_t*,
-       private_crypto_factory_t *this, diffie_hellman_group_t group, ...)
+METHOD(crypto_factory_t, create_ke, key_exchange_t*,
+       private_crypto_factory_t *this, key_exchange_method_t method, ...)
 {
        enumerator_t *enumerator;
        entry_t *entry;
-       va_list args;
        chunk_t g = chunk_empty, p = chunk_empty;
-       diffie_hellman_t *diffie_hellman = NULL;
+       key_exchange_t *ke = NULL;
 
-       if (group == MODP_CUSTOM)
+       if (method == MODP_CUSTOM)
        {
-               va_start(args, group);
-               g = va_arg(args, chunk_t);
-               p = va_arg(args, chunk_t);
-               va_end(args);
+               VA_ARGS_GET(method, g, p);
        }
 
        this->lock->read_lock(this->lock);
-       enumerator = this->dhs->create_enumerator(this->dhs);
+       enumerator = this->kes->create_enumerator(this->kes);
        while (enumerator->enumerate(enumerator, &entry))
        {
-               if (entry->algo == group)
+               if (entry->algo == method)
                {
-                       if (this->test_on_create && group != MODP_CUSTOM &&
-                               !this->tester->test_dh(this->tester, group,
-                                                               entry->create_dh, NULL, default_plugin_name))
+                       if (this->test_on_create && method != MODP_CUSTOM &&
+                               !this->tester->test_ke(this->tester, method,
+                                                               entry->create_ke, NULL, default_plugin_name))
                        {
                                continue;
                        }
-                       diffie_hellman = entry->create_dh(group, g, p);
-                       if (diffie_hellman)
+                       ke = entry->create_ke(method, g, p);
+                       if (ke)
                        {
                                break;
                        }
@@ -475,7 +471,7 @@ METHOD(crypto_factory_t, create_dh, diffie_hellman_t*,
        }
        enumerator->destroy(enumerator);
        this->lock->unlock(this->lock);
-       return diffie_hellman;
+       return ke;
 }
 
 /**
@@ -851,36 +847,36 @@ METHOD(crypto_factory_t, remove_nonce_gen, void,
        this->lock->unlock(this->lock);
 }
 
-METHOD(crypto_factory_t, add_dh, bool,
-       private_crypto_factory_t *this, diffie_hellman_group_t group,
-       const char *plugin_name, dh_constructor_t create)
+METHOD(crypto_factory_t, add_ke, bool,
+       private_crypto_factory_t *this, key_exchange_method_t group,
+       const char *plugin_name, ke_constructor_t create)
 {
        u_int speed = 0;
 
        if (!this->test_on_add ||
-               this->tester->test_dh(this->tester, group, create,
+               this->tester->test_ke(this->tester, group, create,
                                                          this->bench ? &speed : NULL, plugin_name))
        {
-               add_entry(this, this->dhs, group, plugin_name, 0, create);
+               add_entry(this, this->kes, group, plugin_name, 0, create);
                return TRUE;
        }
        this->test_failures++;
        return FALSE;
 }
 
-METHOD(crypto_factory_t, remove_dh, void,
-       private_crypto_factory_t *this, dh_constructor_t create)
+METHOD(crypto_factory_t, remove_ke, void,
+       private_crypto_factory_t *this, ke_constructor_t create)
 {
        entry_t *entry;
        enumerator_t *enumerator;
 
        this->lock->write_lock(this->lock);
-       enumerator = this->dhs->create_enumerator(this->dhs);
+       enumerator = this->kes->create_enumerator(this->kes);
        while (enumerator->enumerate(enumerator, &entry))
        {
-               if (entry->create_dh == create)
+               if (entry->create_ke == create)
                {
-                       this->dhs->remove_at(this->dhs, enumerator);
+                       this->kes->remove_at(this->kes, enumerator);
                        free(entry);
                }
        }
@@ -1082,11 +1078,11 @@ METHOD(crypto_factory_t, create_drbg_enumerator, enumerator_t*,
        return create_enumerator(this, this->drbgs, drbg_filter);
 }
 
-CALLBACK(dh_filter, bool,
+CALLBACK(ke_filter, bool,
        void *n, enumerator_t *orig, va_list args)
 {
        entry_t *entry;
-       diffie_hellman_group_t *algo;
+       key_exchange_method_t *algo;
        const char **plugin_name;
 
        VA_ARGS_VGET(args, algo, plugin_name);
@@ -1100,10 +1096,10 @@ CALLBACK(dh_filter, bool,
        return FALSE;
 }
 
-METHOD(crypto_factory_t, create_dh_enumerator, enumerator_t*,
+METHOD(crypto_factory_t, create_ke_enumerator, enumerator_t*,
        private_crypto_factory_t *this)
 {
-       return create_enumerator(this, this->dhs, dh_filter);
+       return create_enumerator(this, this->kes, ke_filter);
 }
 
 CALLBACK(rng_filter, bool,
@@ -1173,8 +1169,8 @@ METHOD(crypto_factory_t, add_test_vector, void,
                        return this->tester->add_drbg_vector(this->tester, vector);
                case RANDOM_NUMBER_GENERATOR:
                        return this->tester->add_rng_vector(this->tester, vector);
-               case DIFFIE_HELLMAN_GROUP:
-                       return this->tester->add_dh_vector(this->tester, vector);
+               case KEY_EXCHANGE_METHOD:
+                       return this->tester->add_ke_vector(this->tester, vector);
                default:
                        DBG1(DBG_LIB, "%N test vectors not supported, ignored",
                                 transform_type_names, type);
@@ -1240,9 +1236,9 @@ METHOD(enumerator_t, verify_enumerate, bool,
                        *valid = this->tester->test_rng(this->tester, entry->algo,
                                                        entry->create_rng, NULL, entry->plugin_name);
                        break;
-               case DIFFIE_HELLMAN_GROUP:
-                       *valid = this->tester->test_dh(this->tester, entry->algo,
-                                                       entry->create_dh, NULL, entry->plugin_name);
+               case KEY_EXCHANGE_METHOD:
+                       *valid = this->tester->test_ke(this->tester, entry->algo,
+                                                       entry->create_ke, NULL, entry->plugin_name);
                        break;
                default:
                        return FALSE;
@@ -1293,8 +1289,8 @@ METHOD(crypto_factory_t, create_verify_enumerator, enumerator_t*,
                case RANDOM_NUMBER_GENERATOR:
                        inner = this->rngs->create_enumerator(this->rngs);
                        break;
-               case DIFFIE_HELLMAN_GROUP:
-                       inner = this->dhs->create_enumerator(this->dhs);
+               case KEY_EXCHANGE_METHOD:
+                       inner = this->kes->create_enumerator(this->kes);
                        break;
                default:
                        this->lock->unlock(this->lock);
@@ -1326,7 +1322,7 @@ METHOD(crypto_factory_t, destroy, void,
        this->drbgs->destroy(this->drbgs);
        this->rngs->destroy(this->rngs);
        this->nonce_gens->destroy(this->nonce_gens);
-       this->dhs->destroy(this->dhs);
+       this->kes->destroy(this->kes);
        this->tester->destroy(this->tester);
        this->lock->destroy(this->lock);
        free(this);
@@ -1350,7 +1346,7 @@ crypto_factory_t *crypto_factory_create()
                        .create_drbg = _create_drbg,
                        .create_rng = _create_rng,
                        .create_nonce_gen = _create_nonce_gen,
-                       .create_dh = _create_dh,
+                       .create_ke = _create_ke,
                        .add_crypter = _add_crypter,
                        .remove_crypter = _remove_crypter,
                        .add_aead = _add_aead,
@@ -1369,8 +1365,8 @@ crypto_factory_t *crypto_factory_create()
                        .remove_rng = _remove_rng,
                        .add_nonce_gen = _add_nonce_gen,
                        .remove_nonce_gen = _remove_nonce_gen,
-                       .add_dh = _add_dh,
-                       .remove_dh = _remove_dh,
+                       .add_ke = _add_ke,
+                       .remove_ke = _remove_ke,
                        .create_crypter_enumerator = _create_crypter_enumerator,
                        .create_aead_enumerator = _create_aead_enumerator,
                        .create_signer_enumerator = _create_signer_enumerator,
@@ -1378,7 +1374,7 @@ crypto_factory_t *crypto_factory_create()
                        .create_prf_enumerator = _create_prf_enumerator,
                        .create_xof_enumerator = _create_xof_enumerator,
                        .create_drbg_enumerator = _create_drbg_enumerator,
-                       .create_dh_enumerator = _create_dh_enumerator,
+                       .create_ke_enumerator = _create_ke_enumerator,
                        .create_rng_enumerator = _create_rng_enumerator,
                        .create_nonce_gen_enumerator = _create_nonce_gen_enumerator,
                        .add_test_vector = _add_test_vector,
@@ -1394,7 +1390,7 @@ crypto_factory_t *crypto_factory_create()
                .drbgs = linked_list_create(),
                .rngs = linked_list_create(),
                .nonce_gens = linked_list_create(),
-               .dhs = linked_list_create(),
+               .kes = linked_list_create(),
                .lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
                .tester = crypto_tester_create(),
                .test_on_add = lib->settings->get_bool(lib->settings,
index 3901cce805440ab04fc04e11cda2022025861223..2003f6fa3fc03c68f977588b65100a46aff7935c 100644 (file)
@@ -35,7 +35,7 @@ typedef struct crypto_factory_t crypto_factory_t;
 #include <crypto/xofs/xof.h>
 #include <crypto/drbgs/drbg.h>
 #include <crypto/nonce_gen.h>
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 #include <crypto/transform.h>
 
 #define CRYPTO_MAX_ALG_LINE          120   /* characters */
@@ -87,12 +87,12 @@ typedef rng_t* (*rng_constructor_t)(rng_quality_t quality);
 typedef nonce_gen_t* (*nonce_gen_constructor_t)();
 
 /**
- * Constructor function for diffie hellman
+ * Constructor function for key exchange methods
  *
- * The DH constructor accepts additional arguments for:
+ * The key exchange method constructor accepts additional arguments for:
  * - MODP_CUSTOM: chunk_t generator, chunk_t prime
  */
-typedef diffie_hellman_t* (*dh_constructor_t)(diffie_hellman_group_t group, ...);
+typedef key_exchange_t* (*ke_constructor_t)(key_exchange_method_t method, ...);
 
 /**
  * Handles crypto modules and creates instances.
@@ -183,15 +183,15 @@ struct crypto_factory_t {
        nonce_gen_t* (*create_nonce_gen)(crypto_factory_t *this);
 
        /**
-        * Create a diffie hellman instance.
+        * Create a key exchange method instance.
         *
-        * Additional arguments are passed to the DH constructor.
+        * Additional arguments are passed to the key exchange method constructor.
         *
-        * @param group                 diffie hellman group
-        * @return                              diffie_hellman_t instance, NULL if not supported
+        * @param method                key exchange method
+        * @return                              key_exchange_t instance, NULL if not supported
         */
-       diffie_hellman_t* (*create_dh)(crypto_factory_t *this,
-                                                                  diffie_hellman_group_t group, ...);
+       key_exchange_t* (*create_ke)(crypto_factory_t *this,
+                                                                key_exchange_method_t method, ...);
 
        /**
         * Register a crypter constructor.
@@ -360,22 +360,22 @@ struct crypto_factory_t {
                                                         nonce_gen_constructor_t create);
 
        /**
-        * Register a diffie hellman constructor.
+        * Register a key exchange method constructor.
         *
-        * @param group                 dh group to constructor
+        * @param method                key exchange method to constructor
         * @param plugin_name   plugin that registered this algorithm
         * @param create                constructor function for that algorithm
         * @return                              TRUE if registered, FALSE if test vector failed
         */
-       bool (*add_dh)(crypto_factory_t *this, diffie_hellman_group_t group,
-                                  const char *plugin_name, dh_constructor_t create);
+       bool (*add_ke)(crypto_factory_t *this, key_exchange_method_t method,
+                                  const char *plugin_name, ke_constructor_t create);
 
        /**
-        * Unregister a diffie hellman constructor.
+        * Unregister a key exchange method constructor.
         *
         * @param create                constructor function to unregister
         */
-       void (*remove_dh)(crypto_factory_t *this, dh_constructor_t create);
+       void (*remove_ke)(crypto_factory_t *this, ke_constructor_t create);
 
        /**
         * Create an enumerator over all registered crypter algorithms.
@@ -427,11 +427,11 @@ struct crypto_factory_t {
        enumerator_t* (*create_drbg_enumerator)(crypto_factory_t *this);
 
        /**
-        * Create an enumerator over all registered diffie hellman groups.
+        * Create an enumerator over all registered key exchange method.
         *
-        * @return                              enumerator over diffie_hellman_group_t, plugin
+        * @return                              enumerator over key_exchange_method_t, plugin
         */
-       enumerator_t* (*create_dh_enumerator)(crypto_factory_t *this);
+       enumerator_t* (*create_ke_enumerator)(crypto_factory_t *this);
 
        /**
         * Create an enumerator over all registered random generators.
index 04ed2288c0d17f982bc721d74fbe3cd8cb575d4f..69361608be2ce5d40691e0563cbbb93f9bbfe6e6 100644 (file)
@@ -80,9 +80,9 @@ struct private_crypto_tester_t {
        linked_list_t *rng;
 
        /**
-        * List of Diffie-Hellman test vectors
+        * List of key exchange method test vectors
         */
-       linked_list_t *dh;
+       linked_list_t *ke;
 
        /**
         * Is a test vector required to pass a test?
@@ -1439,13 +1439,13 @@ failure:
 }
 
 /**
- * Benchmark a DH backend
+ * Benchmark a key exchange backend
  */
-static u_int bench_dh(private_crypto_tester_t *this,
-                                         diffie_hellman_group_t group, dh_constructor_t create)
+static u_int bench_ke(private_crypto_tester_t *this,
+                                         key_exchange_method_t method, ke_constructor_t create)
 {
        chunk_t pub = chunk_empty, shared = chunk_empty;
-       diffie_hellman_t *dh;
+       key_exchange_t *ke;
        struct timespec start;
        u_int runs;
 
@@ -1453,46 +1453,46 @@ static u_int bench_dh(private_crypto_tester_t *this,
        start_timing(&start);
        while (end_timing(&start) < this->bench_time)
        {
-               dh = create(group);
-               if (!dh)
+               ke = create(method);
+               if (!ke)
                {
                        return 0;
                }
-               if (dh->get_my_public_value(dh, &pub) &&
-                       dh->set_other_public_value(dh, pub) &&
-                       dh->get_shared_secret(dh, &shared))
+               if (ke->get_public_key(ke, &pub) &&
+                       ke->set_public_key(ke, pub) &&
+                       ke->get_shared_secret(ke, &shared))
                {
                        runs++;
                }
                chunk_free(&pub);
                chunk_free(&shared);
-               dh->destroy(dh);
+               ke->destroy(ke);
        }
        return runs;
 }
 
-METHOD(crypto_tester_t, test_dh, bool,
-       private_crypto_tester_t *this, diffie_hellman_group_t group,
-       dh_constructor_t create, u_int *speed, const char *plugin_name)
+METHOD(crypto_tester_t, test_ke, bool,
+       private_crypto_tester_t *this, key_exchange_method_t method,
+       ke_constructor_t create, u_int *speed, const char *plugin_name)
 {
        enumerator_t *enumerator;
-       dh_test_vector_t *v;
+       ke_test_vector_t *v;
        bool failed = FALSE;
        u_int tested = 0;
 
-       enumerator = this->dh->create_enumerator(this->dh);
+       enumerator = this->ke->create_enumerator(this->ke);
        while (enumerator->enumerate(enumerator, &v))
        {
-               diffie_hellman_t *a, *b;
+               key_exchange_t *a, *b;
                chunk_t apub, bpub, asec, bsec;
 
-               if (v->group != group)
+               if (v->method != method)
                {
                        continue;
                }
 
-               a = create(group);
-               b = create(group);
+               a = create(method);
+               b = create(method);
                if (!a || !b)
                {
                        DESTROY_IF(a);
@@ -1500,11 +1500,11 @@ METHOD(crypto_tester_t, test_dh, bool,
                        failed = TRUE;
                        tested++;
                        DBG1(DBG_LIB, "disabled %N[%s]: creating instance failed",
-                                diffie_hellman_group_names, group, plugin_name);
+                                key_exchange_method_names, method, plugin_name);
                        break;
                }
 
-               if (!a->set_private_value || !b->set_private_value)
+               if (!a->set_private_key || !b->set_private_key)
                {       /* does not support testing */
                        a->destroy(a);
                        b->destroy(b);
@@ -1515,23 +1515,23 @@ METHOD(crypto_tester_t, test_dh, bool,
 
                apub = bpub = asec = bsec = chunk_empty;
 
-               if (!a->set_private_value(a, chunk_create(v->priv_a, v->priv_len)) ||
-                       !b->set_private_value(b, chunk_create(v->priv_b, v->priv_len)))
+               if (!a->set_private_key(a, chunk_create(v->priv_a, v->priv_len)) ||
+                       !b->set_private_key(b, chunk_create(v->priv_b, v->priv_len)))
                {
                        goto failure;
                }
-               if (!a->get_my_public_value(a, &apub) ||
+               if (!a->get_public_key(a, &apub) ||
                        !chunk_equals(apub, chunk_create(v->pub_a, v->pub_len)))
                {
                        goto failure;
                }
-               if (!b->get_my_public_value(b, &bpub) ||
+               if (!b->get_public_key(b, &bpub) ||
                        !chunk_equals(bpub, chunk_create(v->pub_b, v->pub_len)))
                {
                        goto failure;
                }
-               if (!a->set_other_public_value(a, bpub) ||
-                       !b->set_other_public_value(b, apub))
+               if (!a->set_public_key(a, bpub) ||
+                       !b->set_public_key(b, apub))
                {
                        goto failure;
                }
@@ -1557,7 +1557,7 @@ failure:
                if (failed)
                {
                        DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
-                                diffie_hellman_group_names, group, plugin_name, get_name(v));
+                                key_exchange_method_names, method, plugin_name, get_name(v));
                        break;
                }
        }
@@ -1566,21 +1566,21 @@ failure:
        {
                DBG1(DBG_LIB, "%s %N[%s]: no test vectors found / untestable",
                         this->required ? "disabled" : "enabled ",
-                        diffie_hellman_group_names, group, plugin_name);
+                        key_exchange_method_names, method, plugin_name);
                return !this->required;
        }
        if (!failed)
        {
                if (speed)
                {
-                       *speed = bench_dh(this, group, create);
+                       *speed = bench_ke(this, method, create);
                        DBG1(DBG_LIB, "enabled  %N[%s]: passed %u test vectors, %d points",
-                                diffie_hellman_group_names, group, plugin_name, tested, *speed);
+                                key_exchange_method_names, method, plugin_name, tested, *speed);
                }
                else
                {
                        DBG1(DBG_LIB, "enabled  %N[%s]: passed %u test vectors",
-                                diffie_hellman_group_names, group, plugin_name, tested);
+                                key_exchange_method_names, method, plugin_name, tested);
                }
        }
        return !failed;
@@ -1634,10 +1634,10 @@ METHOD(crypto_tester_t, add_rng_vector, void,
        this->rng->insert_last(this->rng, vector);
 }
 
-METHOD(crypto_tester_t, add_dh_vector, void,
-       private_crypto_tester_t *this, dh_test_vector_t *vector)
+METHOD(crypto_tester_t, add_ke_vector, void,
+       private_crypto_tester_t *this, ke_test_vector_t *vector)
 {
-       this->dh->insert_last(this->dh, vector);
+       this->ke->insert_last(this->ke, vector);
 }
 
 METHOD(crypto_tester_t, destroy, void,
@@ -1651,7 +1651,7 @@ METHOD(crypto_tester_t, destroy, void,
        this->xof->destroy(this->xof);
        this->drbg->destroy(this->drbg);
        this->rng->destroy(this->rng);
-       this->dh->destroy(this->dh);
+       this->ke->destroy(this->ke);
        free(this);
 }
 
@@ -1672,7 +1672,7 @@ crypto_tester_t *crypto_tester_create()
                        .test_xof = _test_xof,
                        .test_drbg = _test_drbg,
                        .test_rng = _test_rng,
-                       .test_dh = _test_dh,
+                       .test_ke = _test_ke,
                        .add_crypter_vector = _add_crypter_vector,
                        .add_aead_vector = _add_aead_vector,
                        .add_signer_vector = _add_signer_vector,
@@ -1681,7 +1681,7 @@ crypto_tester_t *crypto_tester_create()
                        .add_xof_vector = _add_xof_vector,
                        .add_drbg_vector = _add_drbg_vector,
                        .add_rng_vector = _add_rng_vector,
-                       .add_dh_vector = _add_dh_vector,
+                       .add_ke_vector = _add_ke_vector,
                        .destroy = _destroy,
                },
                .crypter = linked_list_create(),
@@ -1692,7 +1692,7 @@ crypto_tester_t *crypto_tester_create()
                .xof = linked_list_create(),
                .drbg = linked_list_create(),
                .rng = linked_list_create(),
-               .dh = linked_list_create(),
+               .ke = linked_list_create(),
 
                .required = lib->settings->get_bool(lib->settings,
                                                                "%s.crypto_test.required", FALSE, lib->ns),
index 04de7915810b0e2ccf70640d623c07fdb6d98592..eadfba40e95c9ec43e6f58590072f053c3f218fe 100644 (file)
@@ -34,7 +34,7 @@ typedef struct prf_test_vector_t prf_test_vector_t;
 typedef struct xof_test_vector_t xof_test_vector_t;
 typedef struct drbg_test_vector_t drbg_test_vector_t;
 typedef struct rng_test_vector_t rng_test_vector_t;
-typedef struct dh_test_vector_t dh_test_vector_t;
+typedef struct ke_test_vector_t ke_test_vector_t;
 
 struct crypter_test_vector_t {
        /** encryption algorithm this vector tests */
@@ -159,20 +159,20 @@ struct rng_test_vector_t {
        void *user;
 };
 
-struct dh_test_vector_t {
-       /** diffie hellman group to test */
-       diffie_hellman_group_t group;
-       /** private value of alice */
+struct ke_test_vector_t {
+       /** key exchange method to test */
+       key_exchange_method_t method;
+       /** private key of alice */
        u_char *priv_a;
-       /** private value of bob */
+       /** private key of bob */
        u_char *priv_b;
-       /** length of private values */
+       /** length of private keys */
        size_t priv_len;
-       /** expected public value of alice */
+       /** expected public key of alice */
        u_char *pub_a;
-       /** expected public value of bob */
+       /** expected public key of bob */
        u_char *pub_b;
-       /** size of public values */
+       /** size of public keys */
        size_t pub_len;
        /** expected shared secret */
        u_char *shared;
@@ -279,15 +279,15 @@ struct crypto_tester_t {
                                         rng_constructor_t create,
                                         u_int *speed, const char *plugin_name);
        /**
-        * Test a Diffie-Hellman implementation.
+        * Test a key exchange implementation.
         *
-        * @param group                 group to test
-        * @param create                constructor function for the DH backend
-        * @param speed                 speed test result, NULL to omit
+        * @param ke                    key exchange method to test
+        * @param create                constructor function for the key exchange method
+        * @param speed                 speeed test result, NULL to omit
         * @return                              TRUE if test passed
         */
-       bool (*test_dh)(crypto_tester_t *this, diffie_hellman_group_t group,
-                                       dh_constructor_t create,
+       bool (*test_ke)(crypto_tester_t *this, key_exchange_method_t ke,
+                                       ke_constructor_t create,
                                        u_int *speed, const char *plugin_name);
 
        /**
@@ -351,7 +351,7 @@ struct crypto_tester_t {
         *
         * @param vector                pointer to test vector
         */
-       void (*add_dh_vector)(crypto_tester_t *this, dh_test_vector_t *vector);
+       void (*add_ke_vector)(crypto_tester_t *this, ke_test_vector_t *vector);
 
        /**
         * Destroy a crypto_tester_t.
similarity index 95%
rename from src/libstrongswan/crypto/diffie_hellman.c
rename to src/libstrongswan/crypto/key_exchange.c
index efcfdbc74b94769683faa51740a146fd3d9cb297..1597c0e24e4d8a4ef4644f33ec2c7e5d82665ec6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Tobias Brunner
+ * Copyright (C) 2010-2019 Tobias Brunner
  * Copyright (C) 2005-2010 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * HSR Hochschule fuer Technik Rapperswil
  * for more details.
  */
 
-#include "diffie_hellman.h"
+#include "key_exchange.h"
 
-ENUM_BEGIN(diffie_hellman_group_names, MODP_NONE, MODP_1024_BIT,
+ENUM_BEGIN(key_exchange_method_names, MODP_NONE, MODP_1024_BIT,
        "MODP_NONE",
        "MODP_768",
        "MODP_1024");
-ENUM_NEXT(diffie_hellman_group_names, MODP_1536_BIT, MODP_1536_BIT, MODP_1024_BIT,
+ENUM_NEXT(key_exchange_method_names, MODP_1536_BIT, MODP_1536_BIT, MODP_1024_BIT,
        "MODP_1536");
-ENUM_NEXT(diffie_hellman_group_names, MODP_2048_BIT, ECP_521_BIT, MODP_1536_BIT,
+ENUM_NEXT(key_exchange_method_names, MODP_2048_BIT, ECP_521_BIT, MODP_1536_BIT,
        "MODP_2048",
        "MODP_3072",
        "MODP_4096",
@@ -32,7 +32,7 @@ ENUM_NEXT(diffie_hellman_group_names, MODP_2048_BIT, ECP_521_BIT, MODP_1536_BIT,
        "ECP_256",
        "ECP_384",
        "ECP_521");
-ENUM_NEXT(diffie_hellman_group_names, MODP_1024_160, CURVE_448, ECP_521_BIT,
+ENUM_NEXT(key_exchange_method_names, MODP_1024_160, CURVE_448, ECP_521_BIT,
        "MODP_1024_160",
        "MODP_2048_224",
        "MODP_2048_256",
@@ -44,28 +44,28 @@ ENUM_NEXT(diffie_hellman_group_names, MODP_1024_160, CURVE_448, ECP_521_BIT,
        "ECP_512_BP",
        "CURVE_25519",
        "CURVE_448");
-ENUM_NEXT(diffie_hellman_group_names, MODP_NULL, MODP_NULL, CURVE_448,
+ENUM_NEXT(key_exchange_method_names, MODP_NULL, MODP_NULL, CURVE_448,
        "MODP_NULL");
-ENUM_NEXT(diffie_hellman_group_names, NTRU_112_BIT, NTRU_256_BIT, MODP_NULL,
+ENUM_NEXT(key_exchange_method_names, NTRU_112_BIT, NTRU_256_BIT, MODP_NULL,
        "NTRU_112",
        "NTRU_128",
        "NTRU_192",
        "NTRU_256");
-ENUM_NEXT(diffie_hellman_group_names, NH_128_BIT, NH_128_BIT, NTRU_256_BIT,
+ENUM_NEXT(key_exchange_method_names, NH_128_BIT, NH_128_BIT, NTRU_256_BIT,
        "NEWHOPE_128");
-ENUM_NEXT(diffie_hellman_group_names, MODP_CUSTOM, MODP_CUSTOM, NH_128_BIT,
+ENUM_NEXT(key_exchange_method_names, MODP_CUSTOM, MODP_CUSTOM, NH_128_BIT,
        "MODP_CUSTOM");
-ENUM_END(diffie_hellman_group_names, MODP_CUSTOM);
+ENUM_END(key_exchange_method_names, MODP_CUSTOM);
 
 
 /**
- * List of known diffie hellman group parameters.
+ * List of known Diffie-Hellman group parameters.
  */
 static struct {
        /* Public part of the struct */
        diffie_hellman_params_t public;
        /* The group identifier as specified in IKEv2 */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 } dh_params[] = {
        {
                .group = MODP_768_BIT, .public = {
@@ -435,8 +435,8 @@ static struct {
        },
 };
 
-/**
- * See header.
+/*
+ * Described in header
  */
 void diffie_hellman_init()
 {
@@ -460,16 +460,16 @@ void diffie_hellman_init()
        }
 }
 
-/**
- * Described in header.
+/*
+ * Described in header
  */
-diffie_hellman_params_t *diffie_hellman_get_params(diffie_hellman_group_t group)
+diffie_hellman_params_t *diffie_hellman_get_params(key_exchange_method_t ke)
 {
        int i;
 
        for (i = 0; i < countof(dh_params); i++)
        {
-               if (dh_params[i].group == group)
+               if (dh_params[i].group == ke)
                {
                        return &dh_params[i].public;
                }
@@ -477,12 +477,12 @@ diffie_hellman_params_t *diffie_hellman_get_params(diffie_hellman_group_t group)
        return NULL;
 }
 
-/**
- * See header.
+/*
+ * Described in header
  */
-bool diffie_hellman_group_is_ec(diffie_hellman_group_t group)
+bool key_exchange_is_ecdh(key_exchange_method_t ke)
 {
-       switch (group)
+       switch (ke)
        {
                case ECP_256_BIT:
                case ECP_384_BIT:
@@ -499,15 +499,15 @@ bool diffie_hellman_group_is_ec(diffie_hellman_group_t group)
        }
 }
 
-/**
- * See header.
+/*
+ * Described in header
  */
-bool diffie_hellman_verify_value(diffie_hellman_group_t group, chunk_t value)
+bool key_exchange_verify_pubkey(key_exchange_method_t ke, chunk_t value)
 {
        diffie_hellman_params_t *params;
        bool valid = FALSE;
 
-       switch (group)
+       switch (ke)
        {
                case MODP_768_BIT:
                case MODP_1024_BIT:
@@ -520,7 +520,7 @@ bool diffie_hellman_verify_value(diffie_hellman_group_t group, chunk_t value)
                case MODP_1024_160:
                case MODP_2048_224:
                case MODP_2048_256:
-                       params = diffie_hellman_get_params(group);
+                       params = diffie_hellman_get_params(ke);
                        if (params)
                        {
                                valid = value.len == params->prime.len;
@@ -568,12 +568,12 @@ bool diffie_hellman_verify_value(diffie_hellman_group_t group, chunk_t value)
                case MODP_NONE:
                        /* fail */
                        break;
-               /* compile-warn unhandled groups, fail verification */
+               /* compile-warn unhandled methods, fail verification */
        }
        if (!valid)
        {
                DBG1(DBG_ENC, "invalid DH public value size (%zu bytes) for %N",
-                        value.len, diffie_hellman_group_names, group);
+                        value.len, key_exchange_method_names, ke);
        }
        return valid;
 }
similarity index 56%
rename from src/libstrongswan/crypto/diffie_hellman.h
rename to src/libstrongswan/crypto/key_exchange.h
index ce01bb34633a869b9ef9a2d0c6b377ce3738bebc..0d221c4ed6befa061cd8d36abc8be5c79f3ee6a2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Tobias Brunner
+ * Copyright (C) 2010-2019 Tobias Brunner
  * Copyright (C) 2005-2007 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * HSR Hochschule fuer Technik Rapperswil
  */
 
 /**
- * @defgroup diffie_hellman diffie_hellman
+ * @defgroup key_exchange key_exchange
  * @{ @ingroup crypto
  */
 
-#ifndef DIFFIE_HELLMAN_H_
-#define DIFFIE_HELLMAN_H_
+#ifndef KEY_EXCHANGE_H_
+#define KEY_EXCHANGE_H_
 
-typedef enum diffie_hellman_group_t diffie_hellman_group_t;
-typedef struct diffie_hellman_t diffie_hellman_t;
+typedef enum key_exchange_method_t key_exchange_method_t;
+typedef struct key_exchange_t key_exchange_t;
 typedef struct diffie_hellman_params_t diffie_hellman_params_t;
 
 #include <library.h>
 
 /**
- * Diffie-Hellman group.
+ * Key exchange method.
  *
  * The modulus (or group) to use for a Diffie-Hellman calculation.
  * See IKEv2 RFC 3.3.2 and RFC 3526.
@@ -39,7 +39,7 @@ typedef struct diffie_hellman_params_t diffie_hellman_params_t;
  * ECC Brainpool groups are defined in RFC 6954.
  * Curve25519 and Curve448 groups are defined in RFC 8031.
  */
-enum diffie_hellman_group_t {
+enum key_exchange_method_t {
        MODP_NONE     =  0,
        MODP_768_BIT  =  1,
        MODP_1024_BIT =  2,
@@ -78,75 +78,70 @@ enum diffie_hellman_group_t {
 };
 
 /**
- * enum name for diffie_hellman_group_t.
+ * enum name for key_exchange_method_t.
  */
-extern enum_name_t *diffie_hellman_group_names;
+extern enum_name_t *key_exchange_method_names;
 
 /**
- * Implementation of the Diffie-Hellman algorithm, as in RFC2631.
+ * Implementation of a key exchange algorithms (e.g. Diffie-Hellman).
  */
-struct diffie_hellman_t {
+struct key_exchange_t {
 
        /**
-        * Returns the shared secret of this diffie hellman exchange.
+        * Returns the shared secret of this key exchange method.
         *
-        * Space for returned secret is allocated and must be freed by the caller.
-        *
-        * @param secret        shared secret will be written into this chunk
+        * @param secret        shared secret (allocated)
         * @return                      TRUE if shared secret computed successfully
         */
-       bool (*get_shared_secret)(diffie_hellman_t *this, chunk_t *secret)
+       bool (*get_shared_secret)(key_exchange_t *this, chunk_t *secret)
                __attribute__((warn_unused_result));
 
        /**
-        * Sets the public value of partner.
-        *
-        * Chunk gets cloned and can be destroyed afterwards.
+        * Sets the public key from the peer.
         *
-        * @param value         public value of partner
-        * @return                      TRUE if other public value verified and set
+        * @param value         public key of peer
+        * @return                      TRUE if other public key verified and set
         */
-       bool (*set_other_public_value)(diffie_hellman_t *this, chunk_t value)
+       bool (*set_public_key)(key_exchange_t *this, chunk_t value)
                __attribute__((warn_unused_result));
 
        /**
-        * Gets the own public value to transmit.
-        *
-        * Space for returned chunk is allocated and must be freed by the caller.
+        * Gets the own public key to transmit.
         *
-        * @param value         public value of caller is stored at this location
-        * @return                      TRUE if public value retrieved
+        * @param value         public key (allocated)
+        * @return                      TRUE if public key retrieved
         */
-       bool (*get_my_public_value) (diffie_hellman_t *this, chunk_t *value)
+       bool (*get_public_key)(key_exchange_t *this, chunk_t *value)
                __attribute__((warn_unused_result));
 
        /**
-        * Set an explicit own private value to use.
+        * Set an explicit own private key to use.
         *
         * Calling this method is usually not required, as the DH backend generates
         * an appropriate private value itself. It is optional to implement, and
-        * used mostly for testing purposes.
+        * used mostly for testing purposes.  The private key may be the actual key
+        * or a seed for a DRBG.
         *
-        * @param value         private value to set
+        * @param value         private key value to set
         */
-       bool (*set_private_value)(diffie_hellman_t *this, chunk_t value)
+       bool (*set_private_key)(key_exchange_t *this, chunk_t value)
                __attribute__((warn_unused_result));
 
        /**
-        * Get the DH group used.
+        * Get the key exchange method used.
         *
-        * @return                      DH group set in construction
+        * @return                      key exchange method set in construction
         */
-       diffie_hellman_group_t (*get_dh_group) (diffie_hellman_t *this);
+       key_exchange_method_t (*get_method)(key_exchange_t *this);
 
        /**
-        * Destroys a diffie_hellman_t object.
+        * Destroys a key_exchange_t object.
         */
-       void (*destroy) (diffie_hellman_t *this);
+       void (*destroy)(key_exchange_t *this);
 };
 
 /**
- * Parameters for a specific diffie hellman group.
+ * Parameters for a specific Diffie-Hellman group.
  */
 struct diffie_hellman_params_t {
 
@@ -177,31 +172,31 @@ struct diffie_hellman_params_t {
 void diffie_hellman_init();
 
 /**
- * Get the parameters associated with the specified diffie hellman group.
+ * Get the parameters associated with the specified Diffie-Hellman group.
  *
  * Before calling this method, use diffie_hellman_init() to initialize the
  * DH group table. This is usually done by library_init().
  *
- * @param group                        DH group
+ * @param ke                   key exchange method (DH group)
  * @return                             The parameters or NULL, if the group is not supported
  */
-diffie_hellman_params_t *diffie_hellman_get_params(diffie_hellman_group_t group);
+diffie_hellman_params_t *diffie_hellman_get_params(key_exchange_method_t ke);
 
 /**
- * Check if a given DH group is an ECDH group
+ * Check if a given key exchange method is an ECDH group.
  *
- * @param group                        group to check
- * @return                             TRUE if group is an ECP group
+ * @param ke                   key exchange method to check
+ * @return                             TRUE if key exchange method is an ECP group
  */
-bool diffie_hellman_group_is_ec(diffie_hellman_group_t group);
+bool key_exchange_is_ecdh(key_exchange_method_t ke);
 
 /**
- * Check if a diffie hellman public value is valid for given group.
+ * Check if a public key is valid for given key exchange method.
  *
- * @param group                        group the value is used in
- * @param value                        public DH value to check
- * @return                             TRUE if value looks valid for group
+ * @param ke                   key exchange method
+ * @param value                        public key to check
+ * @return                             TRUE if value looks valid
  */
-bool diffie_hellman_verify_value(diffie_hellman_group_t group, chunk_t value);
+bool key_exchange_verify_pubkey(key_exchange_method_t ke, chunk_t value);
 
-#endif /** DIFFIE_HELLMAN_H_ @}*/
+#endif /** KEY_EXCHANGE_H_ @}*/
index af2c6874a1eda3acea7d319f6e4e086900cec98b..95bbaf9c20ce5ff1fc0ff462986ba6a21a37c96a 100644 (file)
@@ -251,18 +251,18 @@ METHOD(proposal_t, get_algorithm, bool,
        return found;
 }
 
-METHOD(proposal_t, has_dh_group, bool,
-       private_proposal_t *this, diffie_hellman_group_t group)
+METHOD(proposal_t, has_ke_method, bool,
+       private_proposal_t *this, key_exchange_method_t ke)
 {
        bool found = FALSE, any = FALSE;
        enumerator_t *enumerator;
        uint16_t current;
 
-       enumerator = create_enumerator(this, DIFFIE_HELLMAN_GROUP);
+       enumerator = create_enumerator(this, KEY_EXCHANGE_METHOD);
        while (enumerator->enumerate(enumerator, &current, NULL))
        {
                any = TRUE;
-               if (current == group)
+               if (current == ke)
                {
                        found = TRUE;
                        break;
@@ -270,15 +270,15 @@ METHOD(proposal_t, has_dh_group, bool,
        }
        enumerator->destroy(enumerator);
 
-       if (!any && group == MODP_NONE)
+       if (!any && ke == MODP_NONE)
        {
                found = TRUE;
        }
        return found;
 }
 
-METHOD(proposal_t, promote_dh_group, bool,
-       private_proposal_t *this, diffie_hellman_group_t group)
+METHOD(proposal_t, promote_ke_method, bool,
+       private_proposal_t *this, key_exchange_method_t method)
 {
        enumerator_t *enumerator;
        entry_t *entry;
@@ -287,8 +287,8 @@ METHOD(proposal_t, promote_dh_group, bool,
        enumerator = array_create_enumerator(this->transforms);
        while (enumerator->enumerate(enumerator, &entry))
        {
-               if (entry->type == DIFFIE_HELLMAN_GROUP &&
-                       entry->alg == group)
+               if (entry->type == KEY_EXCHANGE_METHOD &&
+                       entry->alg == method)
                {
                        array_remove_at(this->transforms, enumerator);
                        found = TRUE;
@@ -299,8 +299,8 @@ METHOD(proposal_t, promote_dh_group, bool,
        if (found)
        {
                entry_t entry = {
-                       .type = DIFFIE_HELLMAN_GROUP,
-                       .alg = group,
+                       .type = KEY_EXCHANGE_METHOD,
+                       .alg = method,
                };
                array_insert(this->transforms, ARRAY_HEAD, &entry);
        }
@@ -318,7 +318,7 @@ static bool select_algo(private_proposal_t *this, proposal_t *other,
        uint16_t alg1, alg2, ks1, ks2;
        bool found = FALSE, optional = FALSE;
 
-       if (type == DIFFIE_HELLMAN_GROUP)
+       if (type == KEY_EXCHANGE_METHOD)
        {
                optional = this->protocol == PROTO_ESP || this->protocol == PROTO_AH;
        }
@@ -407,7 +407,7 @@ static bool select_algos(private_proposal_t *this, proposal_t *other,
                {
                        continue;
                }
-               if (type == DIFFIE_HELLMAN_GROUP && (flags & PROPOSAL_SKIP_DH))
+               if (type == KEY_EXCHANGE_METHOD && (flags & PROPOSAL_SKIP_KE))
                {
                        continue;
                }
@@ -600,7 +600,7 @@ METHOD(proposal_t, clone_, proposal_t*,
                {
                        continue;
                }
-               if (entry->type == DIFFIE_HELLMAN_GROUP && (flags & PROPOSAL_SKIP_DH))
+               if (entry->type == KEY_EXCHANGE_METHOD && (flags & PROPOSAL_SKIP_KE))
                {
                        continue;
                }
@@ -695,13 +695,13 @@ static bool check_proposal(private_proposal_t *this)
                e = array_create_enumerator(this->transforms);
                while (e->enumerate(e, &entry))
                {
-                       if (entry->type == DIFFIE_HELLMAN_GROUP && !entry->alg)
+                       if (entry->type == KEY_EXCHANGE_METHOD && !entry->alg)
                        {
                                array_remove_at(this->transforms, e);
                        }
                }
                e->destroy(e);
-               if (!get_algorithm(this, DIFFIE_HELLMAN_GROUP, NULL, NULL))
+               if (!get_algorithm(this, KEY_EXCHANGE_METHOD, NULL, NULL))
                {
                        DBG1(DBG_CFG, "a DH group is mandatory in IKE proposals");
                        return FALSE;
@@ -942,8 +942,8 @@ proposal_t *proposal_create_v1(protocol_id_t protocol, uint8_t number,
                        .add_algorithm = _add_algorithm,
                        .create_enumerator = _create_enumerator,
                        .get_algorithm = _get_algorithm,
-                       .has_dh_group = _has_dh_group,
-                       .promote_dh_group = _promote_dh_group,
+                       .has_ke_method = _has_ke_method,
+                       .promote_ke_method = _promote_ke_method,
                        .select = _select_proposal,
                        .matches = _matches,
                        .get_protocol = _get_protocol,
@@ -982,7 +982,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
        encryption_algorithm_t encryption;
        integrity_algorithm_t integrity;
        pseudo_random_function_t prf;
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
        const char *plugin_name;
 
        if (aead)
@@ -1159,7 +1159,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
        enumerator->destroy(enumerator);
 
        /* Round 1 adds ECC and NTRU algorithms with at least 128 bit security strength */
-       enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
+       enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
        while (enumerator->enumerate(enumerator, &group, &plugin_name))
        {
                switch (group)
@@ -1176,7 +1176,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
                        case NTRU_192_BIT:
                        case NTRU_256_BIT:
                        case NH_128_BIT:
-                               add_algorithm(this, DIFFIE_HELLMAN_GROUP, group, 0);
+                               add_algorithm(this, KEY_EXCHANGE_METHOD, group, 0);
                                break;
                        default:
                                break;
@@ -1185,7 +1185,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
        enumerator->destroy(enumerator);
 
        /* Round 2 adds other algorithms with at least 128 bit security strength */
-       enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
+       enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
        while (enumerator->enumerate(enumerator, &group, &plugin_name))
        {
                switch (group)
@@ -1194,7 +1194,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
                        case MODP_4096_BIT:
                        case MODP_6144_BIT:
                        case MODP_8192_BIT:
-                               add_algorithm(this, DIFFIE_HELLMAN_GROUP, group, 0);
+                               add_algorithm(this, KEY_EXCHANGE_METHOD, group, 0);
                                break;
                        default:
                                break;
@@ -1203,7 +1203,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
        enumerator->destroy(enumerator);
 
        /* Round 3 adds algorithms with less than 128 bit security strength */
-       enumerator = lib->crypto->create_dh_enumerator(lib->crypto);
+       enumerator = lib->crypto->create_ke_enumerator(lib->crypto);
        while (enumerator->enumerate(enumerator, &group, &plugin_name))
        {
                switch (group)
@@ -1228,7 +1228,7 @@ static bool proposal_add_supported_ike(private_proposal_t *this, bool aead)
                                /* rarely used */
                                break;
                        case MODP_2048_BIT:
-                               add_algorithm(this, DIFFIE_HELLMAN_GROUP, group, 0);
+                               add_algorithm(this, KEY_EXCHANGE_METHOD, group, 0);
                                break;
                        default:
                                break;
index b8c2fba3ea7a01cb507183891c9eee1724990306..b13f40c32468019f83a82598f214fc55df9a1f19 100644 (file)
@@ -34,7 +34,7 @@ typedef struct proposal_t proposal_t;
 #include <crypto/transform.h>
 #include <crypto/crypters/crypter.h>
 #include <crypto/signers/signer.h>
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 
 /**
  * Protocol ID of a proposal.
@@ -60,8 +60,8 @@ enum proposal_selection_flag_t {
        PROPOSAL_PREFER_SUPPLIED = (1<<0),
        /** Whether to skip and ignore algorithms from a private range. */
        PROPOSAL_SKIP_PRIVATE = (1<<1),
-       /** Whether to skip and ignore diffie hellman groups. */
-       PROPOSAL_SKIP_DH = (1<<2),
+       /** Whether to skip and ignore key exchange methods. */
+       PROPOSAL_SKIP_KE = (1<<2),
 };
 
 /**
@@ -109,21 +109,21 @@ struct proposal_t {
                                                   uint16_t *alg, uint16_t *key_size);
 
        /**
-        * Check if the proposal has a specific DH group.
+        * Check if the proposal has a specific key exchange method.
         *
-        * @param group                 group to check for
+        * @param method                key exchange method to check for
         * @return                              TRUE if algorithm included
         */
-       bool (*has_dh_group)(proposal_t *this, diffie_hellman_group_t group);
+       bool (*has_ke_method)(proposal_t *this, key_exchange_method_t method);
 
        /**
-        * Move the given DH group to the front of the list if it was contained in
-        * the proposal.
+        * Move the given key exchange method to the front of the list if it was
+        * contained in the proposal.
         *
-        * @param group                 group to promote
+        * @param method                key exchange method to promote
         * @return                              TRUE if algorithm included
         */
-       bool (*promote_dh_group)(proposal_t *this, diffie_hellman_group_t group);
+       bool (*promote_ke_method)(proposal_t *this, key_exchange_method_t method);
 
        /**
         * Compare two proposals and select a matching subset.
index ba3fb5233ff4111ea01ad91ae9c74070bdb8b327..217f1792350feb502a03fe765d9ff52121a82834 100644 (file)
@@ -19,7 +19,7 @@
 #include <crypto/transform.h>
 #include <crypto/crypters/crypter.h>
 #include <crypto/signers/signer.h>
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 
 %}
 struct proposal_token {
@@ -142,36 +142,36 @@ prfmd5,           PSEUDO_RANDOM_FUNCTION, PRF_HMAC_MD5,            0
 prfaesxcbc,       PSEUDO_RANDOM_FUNCTION, PRF_AES128_XCBC,         0
 prfcamelliaxcbc,  PSEUDO_RANDOM_FUNCTION, PRF_CAMELLIA128_XCBC,    0
 prfaescmac,       PSEUDO_RANDOM_FUNCTION, PRF_AES128_CMAC,         0
-modpnone,         DIFFIE_HELLMAN_GROUP, MODP_NONE,                 0
-modpnull,         DIFFIE_HELLMAN_GROUP, MODP_NULL,                 0
-modp768,          DIFFIE_HELLMAN_GROUP, MODP_768_BIT,              0
-modp1024,         DIFFIE_HELLMAN_GROUP, MODP_1024_BIT,             0
-modp1536,         DIFFIE_HELLMAN_GROUP, MODP_1536_BIT,             0
-modp2048,         DIFFIE_HELLMAN_GROUP, MODP_2048_BIT,             0
-modp3072,         DIFFIE_HELLMAN_GROUP, MODP_3072_BIT,             0
-modp4096,         DIFFIE_HELLMAN_GROUP, MODP_4096_BIT,             0
-modp6144,         DIFFIE_HELLMAN_GROUP, MODP_6144_BIT,             0
-modp8192,         DIFFIE_HELLMAN_GROUP, MODP_8192_BIT,             0
-ecp192,           DIFFIE_HELLMAN_GROUP, ECP_192_BIT,               0
-ecp224,           DIFFIE_HELLMAN_GROUP, ECP_224_BIT,               0
-ecp256,           DIFFIE_HELLMAN_GROUP, ECP_256_BIT,               0
-ecp384,           DIFFIE_HELLMAN_GROUP, ECP_384_BIT,               0
-ecp521,           DIFFIE_HELLMAN_GROUP, ECP_521_BIT,               0
-modp1024s160,     DIFFIE_HELLMAN_GROUP, MODP_1024_160,             0
-modp2048s224,     DIFFIE_HELLMAN_GROUP, MODP_2048_224,             0
-modp2048s256,     DIFFIE_HELLMAN_GROUP, MODP_2048_256,             0
-ecp224bp,         DIFFIE_HELLMAN_GROUP, ECP_224_BP,                0
-ecp256bp,         DIFFIE_HELLMAN_GROUP, ECP_256_BP,                0
-ecp384bp,         DIFFIE_HELLMAN_GROUP, ECP_384_BP,                0
-ecp512bp,         DIFFIE_HELLMAN_GROUP, ECP_512_BP,                0
-curve25519,       DIFFIE_HELLMAN_GROUP, CURVE_25519,               0
-x25519,           DIFFIE_HELLMAN_GROUP, CURVE_25519,               0
-curve448,         DIFFIE_HELLMAN_GROUP, CURVE_448,                 0
-x448,             DIFFIE_HELLMAN_GROUP, CURVE_448,                 0
-ntru112,          DIFFIE_HELLMAN_GROUP, NTRU_112_BIT,              0
-ntru128,          DIFFIE_HELLMAN_GROUP, NTRU_128_BIT,              0
-ntru192,          DIFFIE_HELLMAN_GROUP, NTRU_192_BIT,              0
-ntru256,          DIFFIE_HELLMAN_GROUP, NTRU_256_BIT,              0
-newhope128,       DIFFIE_HELLMAN_GROUP, NH_128_BIT,                0
+modpnone,         KEY_EXCHANGE_METHOD, MODP_NONE,                  0
+modpnull,         KEY_EXCHANGE_METHOD, MODP_NULL,                  0
+modp768,          KEY_EXCHANGE_METHOD, MODP_768_BIT,               0
+modp1024,         KEY_EXCHANGE_METHOD, MODP_1024_BIT,              0
+modp1536,         KEY_EXCHANGE_METHOD, MODP_1536_BIT,              0
+modp2048,         KEY_EXCHANGE_METHOD, MODP_2048_BIT,              0
+modp3072,         KEY_EXCHANGE_METHOD, MODP_3072_BIT,              0
+modp4096,         KEY_EXCHANGE_METHOD, MODP_4096_BIT,              0
+modp6144,         KEY_EXCHANGE_METHOD, MODP_6144_BIT,              0
+modp8192,         KEY_EXCHANGE_METHOD, MODP_8192_BIT,              0
+ecp192,           KEY_EXCHANGE_METHOD, ECP_192_BIT,                0
+ecp224,           KEY_EXCHANGE_METHOD, ECP_224_BIT,                0
+ecp256,           KEY_EXCHANGE_METHOD, ECP_256_BIT,                0
+ecp384,           KEY_EXCHANGE_METHOD, ECP_384_BIT,                0
+ecp521,           KEY_EXCHANGE_METHOD, ECP_521_BIT,                0
+modp1024s160,     KEY_EXCHANGE_METHOD, MODP_1024_160,              0
+modp2048s224,     KEY_EXCHANGE_METHOD, MODP_2048_224,              0
+modp2048s256,     KEY_EXCHANGE_METHOD, MODP_2048_256,              0
+ecp224bp,         KEY_EXCHANGE_METHOD, ECP_224_BP,                 0
+ecp256bp,         KEY_EXCHANGE_METHOD, ECP_256_BP,                 0
+ecp384bp,         KEY_EXCHANGE_METHOD, ECP_384_BP,                 0
+ecp512bp,         KEY_EXCHANGE_METHOD, ECP_512_BP,                 0
+curve25519,       KEY_EXCHANGE_METHOD, CURVE_25519,                0
+x25519,           KEY_EXCHANGE_METHOD, CURVE_25519,                0
+curve448,         KEY_EXCHANGE_METHOD, CURVE_448,                  0
+x448,             KEY_EXCHANGE_METHOD, CURVE_448,                  0
+ntru112,          KEY_EXCHANGE_METHOD, NTRU_112_BIT,               0
+ntru128,          KEY_EXCHANGE_METHOD, NTRU_128_BIT,               0
+ntru192,          KEY_EXCHANGE_METHOD, NTRU_192_BIT,               0
+ntru256,          KEY_EXCHANGE_METHOD, NTRU_256_BIT,               0
+newhope128,       KEY_EXCHANGE_METHOD, NH_128_BIT,                 0
 noesn,            EXTENDED_SEQUENCE_NUMBERS, NO_EXT_SEQ_NUMBERS,   0
 esn,              EXTENDED_SEQUENCE_NUMBERS, EXT_SEQ_NUMBERS,      0
index e30208ec0054ca0f3756c8ab6986ee7adb29fba0..458eb77daf70617a6300b147f82e0ad83adf6ce2 100644 (file)
@@ -21,7 +21,7 @@ ENUM_BEGIN(transform_type_names, ENCRYPTION_ALGORITHM, EXTENDED_SEQUENCE_NUMBERS
        "ENCRYPTION_ALGORITHM",
        "PSEUDO_RANDOM_FUNCTION",
        "INTEGRITY_ALGORITHM",
-       "DIFFIE_HELLMAN_GROUP",
+       "KEY_EXCHANGE_METHOD",
        "EXTENDED_SEQUENCE_NUMBERS");
 ENUM_NEXT(transform_type_names, HASH_ALGORITHM, DETERMINISTIC_RANDOM_BIT_GENERATOR,
                  EXTENDED_SEQUENCE_NUMBERS,
@@ -57,8 +57,8 @@ enum_name_t* transform_get_enum_names(transform_type_t type)
                        return pseudo_random_function_names;
                case INTEGRITY_ALGORITHM:
                        return integrity_algorithm_names;
-               case DIFFIE_HELLMAN_GROUP:
-                       return diffie_hellman_group_names;
+               case KEY_EXCHANGE_METHOD:
+                       return key_exchange_method_names;
                case EXTENDED_SEQUENCE_NUMBERS:
                        return extended_sequence_numbers_names;
                case EXTENDED_OUTPUT_FUNCTION:
index f7892b821e1ccb4f46ae567d2e1ea7df9a4001ab..51d538dd1ae07fe927f94a991d37342f2f4b639e 100644 (file)
@@ -32,7 +32,7 @@ enum transform_type_t {
        ENCRYPTION_ALGORITHM = 1,
        PSEUDO_RANDOM_FUNCTION = 2,
        INTEGRITY_ALGORITHM = 3,
-       DIFFIE_HELLMAN_GROUP = 4,
+       KEY_EXCHANGE_METHOD = 4,
        EXTENDED_SEQUENCE_NUMBERS = 5,
        HASH_ALGORITHM = 256,
        RANDOM_NUMBER_GENERATOR = 257,
index a55711d1b5ad3e24c7389979f9c0ff3f805e575f..4b541758589fd3f0d379389952c539846c9d659b 100644 (file)
@@ -49,7 +49,7 @@ struct private_botan_diffie_hellman_t {
        /**
         * Diffie Hellman group number
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        /**
         * Private key
@@ -94,10 +94,10 @@ bool load_private_key(private_botan_diffie_hellman_t *this, chunk_t value)
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_botan_diffie_hellman_t *this, chunk_t value)
 {
-       if (!diffie_hellman_verify_value(this->group, value))
+       if (!key_exchange_verify_pubkey(this->group, value))
        {
                return FALSE;
        }
@@ -107,7 +107,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return botan_dh_key_derivation(this->dh_key, value, &this->shared_secret);
 }
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_botan_diffie_hellman_t *this, chunk_t *value)
 {
        *value = chunk_empty;
@@ -129,14 +129,14 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_private_value, bool,
+METHOD(key_exchange_t, set_private_key, bool,
        private_botan_diffie_hellman_t *this, chunk_t value)
 {
        chunk_clear(&this->shared_secret);
        return load_private_key(this, value);
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_botan_diffie_hellman_t *this, chunk_t *secret)
 {
        if (!this->shared_secret.len)
@@ -147,13 +147,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_botan_diffie_hellman_t *this)
 {
        return this->group;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_botan_diffie_hellman_t *this)
 {
        botan_mp_destroy(this->p);
@@ -166,7 +166,7 @@ METHOD(diffie_hellman_t, destroy, void,
 /*
  * Generic internal constructor
  */
-static botan_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
+static botan_diffie_hellman_t *create_generic(key_exchange_method_t group,
                                                                                chunk_t g, chunk_t p, size_t exp_len)
 {
        private_botan_diffie_hellman_t *this;
@@ -175,12 +175,12 @@ static botan_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
 
        INIT(this,
                .public = {
-                       .dh = {
+                       .ke = {
                                .get_shared_secret = _get_shared_secret,
-                               .set_other_public_value = _set_other_public_value,
-                               .get_my_public_value = _get_my_public_value,
-                               .set_private_value = _set_private_value,
-                               .get_dh_group = _get_dh_group,
+                               .set_public_key = _set_public_key,
+                               .get_public_key = _get_public_key,
+                               .set_private_key = _set_private_key,
+                               .get_method = _get_method,
                                .destroy = _destroy,
                        },
                },
@@ -222,7 +222,7 @@ static botan_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
  * Described in header.
  */
 botan_diffie_hellman_t *botan_diffie_hellman_create(
-                                                                                       diffie_hellman_group_t group, ...)
+                                                                                       key_exchange_method_t group, ...)
 {
        diffie_hellman_params_t *params;
        chunk_t g, p;
index 84408229fa17fe2544d3288fd6d2afcad97ecd35..1a5bd0007a1f9be7b602c73ee56fdf78a8f72d74 100644 (file)
@@ -32,7 +32,7 @@
 
 typedef struct botan_diffie_hellman_t botan_diffie_hellman_t;
 
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 
 /**
  * Implementation of the Diffie-Hellman algorithm using Botan.
@@ -40,20 +40,20 @@ typedef struct botan_diffie_hellman_t botan_diffie_hellman_t;
 struct botan_diffie_hellman_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 };
 
 /**
  * Creates a new botan_diffie_hellman_t object.
  *
- * @param group                        Diffie Hellman group number to use
+ * @param group                        Diffie-Hellman group number to use
  * @param ...                  expects generator and prime as chunk_t if MODP_CUSTOM
  * @return                             botan_diffie_hellman_t object,
  *                                             NULL if not supported
  */
 botan_diffie_hellman_t *botan_diffie_hellman_create(
-                                                                                       diffie_hellman_group_t group, ...);
+                                                                                       key_exchange_method_t group, ...);
 
 #endif /** BOTAN_DIFFIE_HELLMAN_H_ @}*/
index 50234b2e02e32e8e8373e8239635ab77fd686d19..054bd5bad94fde0fb22c95c5d19d9024354f34f2 100644 (file)
@@ -48,7 +48,7 @@ struct private_botan_ec_diffie_hellman_t {
        /**
         * Diffie Hellman group
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        /**
         * EC curve name
@@ -66,10 +66,10 @@ struct private_botan_ec_diffie_hellman_t {
        chunk_t shared_secret;
 };
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_botan_ec_diffie_hellman_t *this, chunk_t value)
 {
-       if (!diffie_hellman_verify_value(this->group, value))
+       if (!key_exchange_verify_pubkey(this->group, value))
        {
                return FALSE;
        }
@@ -82,7 +82,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return botan_dh_key_derivation(this->key, value, &this->shared_secret);
 }
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_botan_ec_diffie_hellman_t *this, chunk_t *value)
 {
        chunk_t pkey = chunk_empty;
@@ -104,7 +104,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_private_value, bool,
+METHOD(key_exchange_t, set_private_key, bool,
        private_botan_ec_diffie_hellman_t *this, chunk_t value)
 {
        botan_mp_t scalar;
@@ -132,7 +132,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_botan_ec_diffie_hellman_t *this, chunk_t *secret)
 {
        if (!this->shared_secret.len)
@@ -143,13 +143,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_botan_ec_diffie_hellman_t *this)
 {
        return this->group;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_botan_ec_diffie_hellman_t *this)
 {
        botan_privkey_destroy(this->key);
@@ -161,19 +161,19 @@ METHOD(diffie_hellman_t, destroy, void,
  * Described in header.
  */
 botan_ec_diffie_hellman_t *botan_ec_diffie_hellman_create(
-                                                                                               diffie_hellman_group_t group)
+                                                                                               key_exchange_method_t group)
 {
        private_botan_ec_diffie_hellman_t *this;
        botan_rng_t rng;
 
        INIT(this,
                .public = {
-                       .dh = {
+                       .ke = {
                                .get_shared_secret = _get_shared_secret,
-                               .set_other_public_value = _set_other_public_value,
-                               .get_my_public_value = _get_my_public_value,
-                               .set_private_value = _set_private_value,
-                               .get_dh_group = _get_dh_group,
+                               .set_public_key = _set_public_key,
+                               .get_public_key = _get_public_key,
+                               .set_private_key = _set_private_key,
+                               .get_method = _get_method,
                                .destroy = _destroy,
                        },
                },
index 0ba832ed355ce840e389ce2984ffd1c73741e167..c5fc96895b19bbfc095de70df358506a80840e94 100644 (file)
@@ -39,18 +39,18 @@ typedef struct botan_ec_diffie_hellman_t botan_ec_diffie_hellman_t;
 struct botan_ec_diffie_hellman_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 };
 
 /**
  * Creates a new botan_ec_diffie_hellman_t object.
  *
- * @param group                EC Diffie Hellman group number to use
+ * @param group                EC Diffie-Hellman group number to use
  * @return                     botan_ec_diffie_hellman_t object, NULL if not supported
  */
 botan_ec_diffie_hellman_t *botan_ec_diffie_hellman_create(
-                                                                                               diffie_hellman_group_t group);
+                                                                                               key_exchange_method_t group);
 
 #endif /** BOTAN_EC_DIFFIE_HELLMAN_H_ @}*/
index f045ba07489c67fe65b959652244a140d2a59dbd..75c7988653443f0b861bdf7965edb9c8f9072915 100644 (file)
@@ -74,33 +74,33 @@ METHOD(plugin_t, get_features, int,
 
 #ifdef BOTAN_HAS_DIFFIE_HELLMAN
                /* MODP DH groups */
-               PLUGIN_REGISTER(DH, botan_diffie_hellman_create),
-                       PLUGIN_PROVIDE(DH, MODP_3072_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_4096_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_6144_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_8192_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_2048_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_2048_224),
-                       PLUGIN_PROVIDE(DH, MODP_2048_256),
-                       PLUGIN_PROVIDE(DH, MODP_1536_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_1024_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_1024_160),
-                       PLUGIN_PROVIDE(DH, MODP_768_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_CUSTOM),
+               PLUGIN_REGISTER(KE, botan_diffie_hellman_create),
+                       PLUGIN_PROVIDE(KE, MODP_3072_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_4096_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_6144_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_8192_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_2048_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_2048_224),
+                       PLUGIN_PROVIDE(KE, MODP_2048_256),
+                       PLUGIN_PROVIDE(KE, MODP_1536_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_1024_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_1024_160),
+                       PLUGIN_PROVIDE(KE, MODP_768_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_CUSTOM),
 #endif
 #ifdef BOTAN_HAS_ECDH
                /* EC DH groups */
-               PLUGIN_REGISTER(DH, botan_ec_diffie_hellman_create),
-                       PLUGIN_PROVIDE(DH, ECP_256_BIT),
-                       PLUGIN_PROVIDE(DH, ECP_384_BIT),
-                       PLUGIN_PROVIDE(DH, ECP_521_BIT),
-                       PLUGIN_PROVIDE(DH, ECP_256_BP),
-                       PLUGIN_PROVIDE(DH, ECP_384_BP),
-                       PLUGIN_PROVIDE(DH, ECP_512_BP),
+               PLUGIN_REGISTER(KE, botan_ec_diffie_hellman_create),
+                       PLUGIN_PROVIDE(KE, ECP_256_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_384_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_521_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_256_BP),
+                       PLUGIN_PROVIDE(KE, ECP_384_BP),
+                       PLUGIN_PROVIDE(KE, ECP_512_BP),
 #endif
 #ifdef BOTAN_HAS_X25519
-               PLUGIN_REGISTER(DH, botan_x25519_create),
-                       PLUGIN_PROVIDE(DH, CURVE_25519),
+               PLUGIN_REGISTER(KE, botan_x25519_create),
+                       PLUGIN_PROVIDE(KE, CURVE_25519),
 #endif
 
                /* crypters */
index 8863f3fa63d9b94ecce347f122795859b2381e2a..4109e983ab5d2a80371d9cfcf5f84e2176b95b38 100644 (file)
@@ -43,7 +43,7 @@ struct private_diffie_hellman_t {
        /**
         * Public interface
         */
-       diffie_hellman_t public;
+       key_exchange_t public;
 
        /**
         * Private key
@@ -56,10 +56,10 @@ struct private_diffie_hellman_t {
        chunk_t shared_secret;
 };
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_diffie_hellman_t *this, chunk_t value)
 {
-       if (!diffie_hellman_verify_value(CURVE_25519, value))
+       if (!key_exchange_verify_pubkey(CURVE_25519, value))
        {
                return FALSE;
        }
@@ -69,7 +69,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return botan_dh_key_derivation(this->key, value, &this->shared_secret);
 }
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_diffie_hellman_t *this, chunk_t *value)
 {
        value->len = 0;
@@ -89,7 +89,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_private_value, bool,
+METHOD(key_exchange_t, set_private_key, bool,
        private_diffie_hellman_t *this, chunk_t value)
 {
        if (value.len != 32)
@@ -111,7 +111,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_diffie_hellman_t *this, chunk_t *secret)
 {
        if (!this->shared_secret.len)
@@ -122,13 +122,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_diffie_hellman_t *this)
 {
        return CURVE_25519;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_diffie_hellman_t *this)
 {
        botan_privkey_destroy(this->key);
@@ -139,7 +139,7 @@ METHOD(diffie_hellman_t, destroy, void,
 /*
  * Described in header
  */
-diffie_hellman_t *botan_x25519_create(diffie_hellman_group_t group)
+key_exchange_t *botan_x25519_create(key_exchange_method_t ke)
 {
        private_diffie_hellman_t *this;
        botan_rng_t rng;
@@ -147,10 +147,10 @@ diffie_hellman_t *botan_x25519_create(diffie_hellman_group_t group)
        INIT(this,
                .public = {
                        .get_shared_secret = _get_shared_secret,
-                       .set_other_public_value = _set_other_public_value,
-                       .get_my_public_value = _get_my_public_value,
-                       .set_private_value = _set_private_value,
-                       .get_dh_group = _get_dh_group,
+                       .set_public_key = _set_public_key,
+                       .get_public_key = _get_public_key,
+                       .set_private_key = _set_private_key,
+                       .get_method = _get_method,
                        .destroy = _destroy,
                },
        );
index e95d6cde44d87c7011086ebb5c126d7574752fac..a5a7f3bcb5772b1f49b776f7b70974b1471e2130 100644 (file)
@@ -34,9 +34,9 @@
 /**
  * Creates a new X25519 implementation using Botan.
  *
- * @param group                DH group, must be CURVE_25519
+ * @param ke           key exchange method, must be CURVE_25519
  * @return                     object, NULL if not supported
  */
-diffie_hellman_t *botan_x25519_create(diffie_hellman_group_t group);
+key_exchange_t *botan_x25519_create(key_exchange_method_t ke);
 
 #endif /** BOTAN_X25519_H_ @}*/
index c550263d4e8706d018bcdbfa0928e08730d3d09f..1976d81b76c9fa605607e0e86f828b1f6fbe4f1a 100644 (file)
@@ -72,7 +72,7 @@ static bool generate_key(private_curve25519_dh_t *this)
        return this->drv->set_key(this->drv, key);
 }
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_curve25519_dh_t *this, chunk_t value)
 {
        if (value.len == CURVE25519_KEY_SIZE)
@@ -86,7 +86,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return FALSE;
 }
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_curve25519_dh_t *this, chunk_t *value)
 {
        u_char basepoint[CURVE25519_KEY_SIZE] = { 9 };
@@ -100,7 +100,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
        return FALSE;
 }
 
-METHOD(diffie_hellman_t, set_private_value, bool,
+METHOD(key_exchange_t, set_private_key, bool,
        private_curve25519_dh_t *this, chunk_t value)
 {
        if (value.len != CURVE25519_KEY_SIZE)
@@ -110,7 +110,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
        return this->drv->set_key(this->drv, value.ptr);
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_curve25519_dh_t *this, chunk_t *secret)
 {
        if (!this->computed)
@@ -121,13 +121,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_curve25519_dh_t *this)
 {
        return CURVE_25519;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_curve25519_dh_t *this)
 {
        this->drv->destroy(this->drv);
@@ -137,7 +137,7 @@ METHOD(diffie_hellman_t, destroy, void,
 /*
  * Described in header.
  */
-curve25519_dh_t *curve25519_dh_create(diffie_hellman_group_t group)
+curve25519_dh_t *curve25519_dh_create(key_exchange_method_t group)
 {
        private_curve25519_dh_t *this;
 
@@ -148,12 +148,12 @@ curve25519_dh_t *curve25519_dh_create(diffie_hellman_group_t group)
 
        INIT(this,
                .public = {
-                       .dh = {
+                       .ke = {
                                .get_shared_secret = _get_shared_secret,
-                               .set_other_public_value = _set_other_public_value,
-                               .get_my_public_value = _get_my_public_value,
-                               .set_private_value = _set_private_value,
-                               .get_dh_group = _get_dh_group,
+                               .set_public_key = _set_public_key,
+                               .get_public_key = _get_public_key,
+                               .set_private_key = _set_private_key,
+                               .get_method = _get_method,
                                .destroy = _destroy,
                        },
                },
index 40bc6d1d9552da7a2e4bba02337f5f2914e0601d..69e7effa31c97d8372d8201d150720a1cfde003d 100644 (file)
@@ -31,9 +31,9 @@ typedef struct curve25519_dh_t curve25519_dh_t;
 struct curve25519_dh_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 };
 
 /**
@@ -42,6 +42,6 @@ struct curve25519_dh_t {
  * @param group                        DH group, CURVE_25519
  * @return                             curve25519_dh_t object, NULL on error
  */
-curve25519_dh_t *curve25519_dh_create(diffie_hellman_group_t group);
+curve25519_dh_t *curve25519_dh_create(key_exchange_method_t group);
 
 #endif /** CURVE25519_DH_H_ @}*/
index 48ca43a7abebf35a2a4f612b3efdd487fd745f57..93c04e044f101096ab43a3e0a294411d220ad517 100644 (file)
@@ -48,8 +48,8 @@ METHOD(plugin_t, get_features, int,
 {
        static plugin_feature_t f[] = {
                /* X25519 DH group */
-               PLUGIN_REGISTER(DH, curve25519_dh_create),
-                       PLUGIN_PROVIDE(DH, CURVE_25519),
+               PLUGIN_REGISTER(KE, curve25519_dh_create),
+                       PLUGIN_PROVIDE(KE, CURVE_25519),
                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
                /* Ed25519 private/public keys */
                PLUGIN_REGISTER(PRIVKEY, curve25519_private_key_load, TRUE),
index b57f05e3a12984bbdc8e928da19514df68e57880..bccbb28829dc2f6113cb485f05a3b4be4bead646 100644 (file)
@@ -35,7 +35,7 @@ struct private_gcrypt_dh_t {
        /**
         * Diffie Hellman group number
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        /*
         * Generator value
@@ -73,13 +73,13 @@ struct private_gcrypt_dh_t {
        size_t p_len;
 };
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_gcrypt_dh_t *this, chunk_t value)
 {
        gcry_mpi_t p_min_1;
        gcry_error_t err;
 
-       if (!diffie_hellman_verify_value(this->group, value))
+       if (!key_exchange_verify_pubkey(this->group, value))
        {
                return FALSE;
        }
@@ -138,14 +138,14 @@ static chunk_t export_mpi(gcry_mpi_t value, size_t len)
        return chunk;
 }
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_gcrypt_dh_t *this, chunk_t *value)
 {
        *value = export_mpi(this->ya, this->p_len);
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_private_value, bool,
+METHOD(key_exchange_t, set_private_key, bool,
        private_gcrypt_dh_t *this, chunk_t value)
 {
        gcry_error_t err;
@@ -163,7 +163,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
        return !err;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_gcrypt_dh_t *this, chunk_t *secret)
 {
        if (!this->zz)
@@ -174,13 +174,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_gcrypt_dh_t *this)
 {
        return this->group;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_gcrypt_dh_t *this)
 {
        gcry_mpi_release(this->p);
@@ -195,7 +195,7 @@ METHOD(diffie_hellman_t, destroy, void,
 /*
  * Generic internal constructor
  */
-static gcrypt_dh_t *create_generic(diffie_hellman_group_t group, size_t exp_len,
+static gcrypt_dh_t *create_generic(key_exchange_method_t group, size_t exp_len,
                                                                   chunk_t g, chunk_t p)
 {
        private_gcrypt_dh_t *this;
@@ -205,12 +205,12 @@ static gcrypt_dh_t *create_generic(diffie_hellman_group_t group, size_t exp_len,
 
        INIT(this,
                .public = {
-                       .dh = {
+                       .ke = {
                                .get_shared_secret = _get_shared_secret,
-                               .set_other_public_value = _set_other_public_value,
-                               .get_my_public_value = _get_my_public_value,
-                               .set_private_value = _set_private_value,
-                               .get_dh_group = _get_dh_group,
+                               .set_public_key = _set_public_key,
+                               .get_public_key = _get_public_key,
+                               .set_private_key = _set_private_key,
+                               .get_method = _get_method,
                                .destroy = _destroy,
                        },
                },
@@ -272,7 +272,7 @@ static gcrypt_dh_t *create_generic(diffie_hellman_group_t group, size_t exp_len,
 /*
  * Described in header.
  */
-gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group)
+gcrypt_dh_t *gcrypt_dh_create(key_exchange_method_t group)
 {
 
        diffie_hellman_params_t *params;
@@ -289,7 +289,7 @@ gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group)
 /*
  * Described in header.
  */
-gcrypt_dh_t *gcrypt_dh_create_custom(diffie_hellman_group_t group, ...)
+gcrypt_dh_t *gcrypt_dh_create_custom(key_exchange_method_t group, ...)
 {
        if (group == MODP_CUSTOM)
        {
index 822ffe205f4b13dec16edbabfaf9859fb012b088..c1729f8ac37c608f842882ac18eaa84908b63fa1 100644 (file)
@@ -31,9 +31,9 @@ typedef struct gcrypt_dh_t gcrypt_dh_t;
 struct gcrypt_dh_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 };
 
 /**
@@ -42,7 +42,7 @@ struct gcrypt_dh_t {
  * @param group                        Diffie Hellman group number to use
  * @return                             gcrypt_dh_t object, NULL if not supported
  */
-gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group);
+gcrypt_dh_t *gcrypt_dh_create(key_exchange_method_t group);
 
 /**
  * Creates a new gcrypt_dh_t object for MODP_CUSTOM.
@@ -51,7 +51,7 @@ gcrypt_dh_t *gcrypt_dh_create(diffie_hellman_group_t group);
  * @param ...                  expects generator and prime as chunk_t
  * @return                             gcrypt_dh_t object, NULL if not supported
  */
-gcrypt_dh_t *gcrypt_dh_create_custom(diffie_hellman_group_t group, ...);
+gcrypt_dh_t *gcrypt_dh_create_custom(key_exchange_method_t group, ...);
 
 #endif /** GCRYPT_DH_H_ @}*/
 
index 848568f45e789bc94d37d854ffef5260ac9044be..c09db8db5371cbaa4d75cff0b13833be1d6cb929 100644 (file)
@@ -102,20 +102,20 @@ METHOD(plugin_t, get_features, int,
                        PLUGIN_PROVIDE(HASHER, HASH_SHA384),
                        PLUGIN_PROVIDE(HASHER, HASH_SHA512),
                /* MODP DH groups */
-               PLUGIN_REGISTER(DH, gcrypt_dh_create),
-                       PLUGIN_PROVIDE(DH, MODP_3072_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_4096_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_6144_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_8192_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_2048_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_2048_224),
-                       PLUGIN_PROVIDE(DH, MODP_2048_256),
-                       PLUGIN_PROVIDE(DH, MODP_1536_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_1024_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_1024_160),
-                       PLUGIN_PROVIDE(DH, MODP_768_BIT),
-               PLUGIN_REGISTER(DH, gcrypt_dh_create_custom),
-                       PLUGIN_PROVIDE(DH, MODP_CUSTOM),
+               PLUGIN_REGISTER(KE, gcrypt_dh_create),
+                       PLUGIN_PROVIDE(KE, MODP_3072_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_4096_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_6144_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_8192_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_2048_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_2048_224),
+                       PLUGIN_PROVIDE(KE, MODP_2048_256),
+                       PLUGIN_PROVIDE(KE, MODP_1536_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_1024_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_1024_160),
+                       PLUGIN_PROVIDE(KE, MODP_768_BIT),
+               PLUGIN_REGISTER(KE, gcrypt_dh_create_custom),
+                       PLUGIN_PROVIDE(KE, MODP_CUSTOM),
                /* RSA private/public key loading */
                PLUGIN_REGISTER(PUBKEY, gcrypt_rsa_public_key_load, TRUE),
                        PLUGIN_PROVIDE(PUBKEY, KEY_RSA),
index f07dd36cc57637a6aa80099363c7eb64c1c008a5..94e2b60b4eb40b20a37af7404f4c605b0c3122b6 100644 (file)
@@ -42,7 +42,7 @@ struct private_gmp_diffie_hellman_t {
        /**
         * Diffie Hellman group number.
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        /*
         * Generator value.
@@ -85,12 +85,12 @@ struct private_gmp_diffie_hellman_t {
        bool computed;
 };
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_gmp_diffie_hellman_t *this, chunk_t value)
 {
        mpz_t p_min_1;
 
-       if (!diffie_hellman_verify_value(this->group, value))
+       if (!key_exchange_verify_pubkey(this->group, value))
        {
                return FALSE;
        }
@@ -150,7 +150,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return this->computed;
 }
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_gmp_diffie_hellman_t *this,chunk_t *value)
 {
        value->len = this->p_len;
@@ -162,7 +162,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_private_value, bool,
+METHOD(key_exchange_t, set_private_key, bool,
        private_gmp_diffie_hellman_t *this, chunk_t value)
 {
        mpz_import(this->xa, value.len, 1, 1, 1, 0, value.ptr);
@@ -171,7 +171,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_gmp_diffie_hellman_t *this, chunk_t *secret)
 {
        if (!this->computed)
@@ -187,13 +187,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_gmp_diffie_hellman_t *this)
 {
        return this->group;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_gmp_diffie_hellman_t *this)
 {
        mpz_clear(this->p);
@@ -208,7 +208,7 @@ METHOD(diffie_hellman_t, destroy, void,
 /**
  * Generic internal constructor
  */
-static gmp_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
+static gmp_diffie_hellman_t *create_generic(key_exchange_method_t group,
                                                                                        size_t exp_len, chunk_t g, chunk_t p)
 {
        private_gmp_diffie_hellman_t *this;
@@ -217,12 +217,12 @@ static gmp_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
 
        INIT(this,
                .public = {
-                       .dh = {
+                       .ke = {
                                .get_shared_secret = _get_shared_secret,
-                               .set_other_public_value = _set_other_public_value,
-                               .get_my_public_value = _get_my_public_value,
-                               .set_private_value = _set_private_value,
-                               .get_dh_group = _get_dh_group,
+                               .set_public_key = _set_public_key,
+                               .get_public_key = _get_public_key,
+                               .set_private_key = _set_private_key,
+                               .get_method = _get_method,
                                .destroy = _destroy,
                        },
                },
@@ -274,7 +274,7 @@ static gmp_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
 /*
  * Described in header
  */
-gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
+gmp_diffie_hellman_t *gmp_diffie_hellman_create(key_exchange_method_t group)
 {
        diffie_hellman_params_t *params;
 
@@ -291,7 +291,7 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group)
  * Described in header
  */
 gmp_diffie_hellman_t *gmp_diffie_hellman_create_custom(
-                                                                                       diffie_hellman_group_t group, ...)
+                                                                                       key_exchange_method_t group, ...)
 {
        if (group == MODP_CUSTOM)
        {
index dfc8560e2fc9544c8f27c6c892507bdee95cf824..941f097872e0068c0a991107513f4dfb6d2ea3f2 100644 (file)
@@ -32,9 +32,9 @@ typedef struct gmp_diffie_hellman_t gmp_diffie_hellman_t;
 struct gmp_diffie_hellman_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 };
 
 /**
@@ -43,7 +43,7 @@ struct gmp_diffie_hellman_t {
  * @param group                        Diffie Hellman group number to use
  * @return                             gmp_diffie_hellman_t object, NULL if not supported
  */
-gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group);
+gmp_diffie_hellman_t *gmp_diffie_hellman_create(key_exchange_method_t group);
 
 /**
  * Creates a new gmp_diffie_hellman_t object for MODP_CUSTOM.
@@ -53,7 +53,7 @@ gmp_diffie_hellman_t *gmp_diffie_hellman_create(diffie_hellman_group_t group);
  * @return                             gmp_diffie_hellman_t object, NULL if not supported
  */
 gmp_diffie_hellman_t *gmp_diffie_hellman_create_custom(
-                                                       diffie_hellman_group_t group, ...);
+                                                       key_exchange_method_t group, ...);
 
 #endif /** GMP_DIFFIE_HELLMAN_H_ @}*/
 
index b0ae2d81dec20975f446ba52abbbbc6d906c7805..b8cff9ce672f306902b5b93a4e023223c928a1f1 100644 (file)
@@ -44,31 +44,31 @@ METHOD(plugin_t, get_features, int,
 {
        static plugin_feature_t f[] = {
                /* DH groups */
-               PLUGIN_REGISTER(DH, gmp_diffie_hellman_create),
-                       PLUGIN_PROVIDE(DH, MODP_3072_BIT),
+               PLUGIN_REGISTER(KE, gmp_diffie_hellman_create),
+                       PLUGIN_PROVIDE(KE, MODP_3072_BIT),
                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
-                       PLUGIN_PROVIDE(DH, MODP_4096_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_4096_BIT),
                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
-                       PLUGIN_PROVIDE(DH, MODP_6144_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_6144_BIT),
                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
-                       PLUGIN_PROVIDE(DH, MODP_8192_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_8192_BIT),
                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
-                       PLUGIN_PROVIDE(DH, MODP_2048_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_2048_BIT),
                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
-                       PLUGIN_PROVIDE(DH, MODP_2048_224),
+                       PLUGIN_PROVIDE(KE, MODP_2048_224),
                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
-                       PLUGIN_PROVIDE(DH, MODP_2048_256),
+                       PLUGIN_PROVIDE(KE, MODP_2048_256),
                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
-                       PLUGIN_PROVIDE(DH, MODP_1536_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_1536_BIT),
                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
-                       PLUGIN_PROVIDE(DH, MODP_1024_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_1024_BIT),
                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
-                       PLUGIN_PROVIDE(DH, MODP_1024_160),
+                       PLUGIN_PROVIDE(KE, MODP_1024_160),
                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
-                       PLUGIN_PROVIDE(DH, MODP_768_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_768_BIT),
                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
-               PLUGIN_REGISTER(DH, gmp_diffie_hellman_create_custom),
-                       PLUGIN_PROVIDE(DH, MODP_CUSTOM),
+               PLUGIN_REGISTER(KE, gmp_diffie_hellman_create_custom),
+                       PLUGIN_PROVIDE(KE, MODP_CUSTOM),
                                PLUGIN_DEPENDS(RNG, RNG_STRONG),
                        /* private/public keys */
                PLUGIN_REGISTER(PRIVKEY, gmp_rsa_private_key_load, TRUE),
index 4632762152d20c799b19ef7fc5f5422d8ad93d3a..4f708492c017b67d6b7b0375353a38c1341f9e94 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <ntt_fft.h>
 #include <ntt_fft_reduce.h>
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 #include <utils/debug.h>
 
 static const int seed_len =   32;  /* 256 bits */
@@ -277,7 +277,7 @@ static uint8_t* unpack_rec(private_newhope_ke_t *this, uint8_t *x)
        return r;
 }
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_newhope_ke_t *this, chunk_t *value)
 {
        uint16_t n, q;
@@ -396,7 +396,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
        }
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_newhope_ke_t *this, chunk_t *secret)
 {
        if (this->shared_secret.len == 0)
@@ -409,7 +409,7 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_newhope_ke_t *this, chunk_t value)
 {
        newhope_reconciliation_t * rec;
@@ -435,7 +435,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
                if (value.len != poly_len + seed_len)
                {
                        DBG1(DBG_LIB, "received %N KE payload of incorrect size",
-                                                  diffie_hellman_group_names, NH_128_BIT);
+                                                  key_exchange_method_names, NH_128_BIT);
                        return FALSE;
                }
                a_seed = chunk_create(value.ptr + poly_len, seed_len);
@@ -544,7 +544,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
                if (value.len != poly_len + rec_len)
                {
                        DBG1(DBG_LIB, "received %N KE payload of incorrect size",
-                                                  diffie_hellman_group_names, NH_128_BIT);
+                                                  key_exchange_method_names, NH_128_BIT);
                        return FALSE;
                }
 
@@ -580,13 +580,13 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        }
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_newhope_ke_t *this)
 {
        return NH_128_BIT;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_newhope_ke_t *this)
 {
        chunk_clear(&this->shared_secret);
@@ -600,17 +600,17 @@ METHOD(diffie_hellman_t, destroy, void,
 /*
  * Described in header.
  */
-newhope_ke_t *newhope_ke_create(diffie_hellman_group_t group, chunk_t g, chunk_t p)
+newhope_ke_t *newhope_ke_create(key_exchange_method_t ke, chunk_t g, chunk_t p)
 {
        private_newhope_ke_t *this;
 
        INIT(this,
                .public = {
-                       .dh = {
+                       .ke = {
                                .get_shared_secret = _get_shared_secret,
-                               .set_other_public_value = _set_other_public_value,
-                               .get_my_public_value = _get_my_public_value,
-                               .get_dh_group = _get_dh_group,
+                               .set_public_key = _set_public_key,
+                               .get_public_key = _get_public_key,
+                               .get_method = _get_method,
                                .destroy = _destroy,
                        },
                },
index 677d04f90f944deaba37d9a73d8cfa04c77556ee..0101174b88c0b1922ae3e97e231cee3d9cb59dcd 100644 (file)
@@ -31,20 +31,20 @@ typedef struct newhope_ke_t newhope_ke_t;
 struct newhope_ke_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 };
 
 /**
  * Creates a new newhope_ke_t object.
  *
- * @param group                        New Hope DH group number
+ * @param ke                   New Hope key exchange number
  * @param g                            not used
  * @param p                            not used
  * @return                             newhope_ke_t object, NULL if not supported
  */
-newhope_ke_t *newhope_ke_create(diffie_hellman_group_t group, chunk_t g, chunk_t p);
+newhope_ke_t *newhope_ke_create(key_exchange_method_t ke, chunk_t g, chunk_t p);
 
 #endif /** NEWHOPE_KE_H_ @}*/
 
index 444e61a1dd8c9188077551e0684ee31412e63930..45fa6d5d19737ca73a58396b3cf227614e6485e8 100644 (file)
@@ -41,8 +41,8 @@ METHOD(plugin_t, get_features, int,
        private_newhope_plugin_t *this, plugin_feature_t *features[])
 {
        static plugin_feature_t f[] = {
-               PLUGIN_REGISTER(DH, newhope_ke_create),
-                       PLUGIN_PROVIDE(DH, NH_128_BIT),
+               PLUGIN_REGISTER(KE, newhope_ke_create),
+                       PLUGIN_PROVIDE(KE, NH_128_BIT),
                                PLUGIN_DEPENDS(XOF, XOF_SHAKE_128),
                                PLUGIN_DEPENDS(XOF, XOF_CHACHA20),
        };
index 33b744fe19df617ffdf66a7f1baf14fd1f5f3a87..1d9fa82203c561abd178e83eaef83ce565fa72aa 100644 (file)
@@ -26,7 +26,7 @@ const int count = 1000;
 START_TEST(test_newhope_ke_good)
 {
        chunk_t i_msg, r_msg, i_shared_secret, r_shared_secret;
-       diffie_hellman_t *i_nh, *r_nh;
+       key_exchange_t *i_nh, *r_nh;
        struct timespec start, stop;
        int i;
 
@@ -34,24 +34,24 @@ START_TEST(test_newhope_ke_good)
 
        for (i = 0; i < count; i++)
        {
-               i_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
+               i_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
                ck_assert(i_nh != NULL);
-               ck_assert(i_nh->get_dh_group(i_nh) == NH_128_BIT);
+               ck_assert(i_nh->get_method(i_nh) == NH_128_BIT);
 
-               ck_assert(i_nh->get_my_public_value(i_nh, &i_msg));
+               ck_assert(i_nh->get_public_key(i_nh, &i_msg));
                ck_assert(i_msg.len = 1824);
 
-               r_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
+               r_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
                ck_assert(r_nh != NULL);
 
-               ck_assert(r_nh->set_other_public_value(r_nh, i_msg));
-               ck_assert(r_nh->get_my_public_value(r_nh, &r_msg));
+               ck_assert(r_nh->set_public_key(r_nh, i_msg));
+               ck_assert(r_nh->get_public_key(r_nh, &r_msg));
                ck_assert(r_msg.len == 2048);
 
                ck_assert(r_nh->get_shared_secret(r_nh, &r_shared_secret));
                ck_assert(r_shared_secret.len == 32);
 
-               ck_assert(i_nh->set_other_public_value(i_nh, r_msg));
+               ck_assert(i_nh->set_public_key(i_nh, r_msg));
                ck_assert(i_nh->get_shared_secret(i_nh, &i_shared_secret));
                ck_assert(i_shared_secret.len == 32);
                ck_assert(chunk_equals(i_shared_secret, r_shared_secret));
@@ -76,26 +76,26 @@ END_TEST
 START_TEST(test_newhope_ke_wrong)
 {
        chunk_t i_msg, r_msg, i_shared_secret, r_shared_secret;
-       diffie_hellman_t *i_nh, *r_nh;
+       key_exchange_t *i_nh, *r_nh;
 
-       i_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
+       i_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
        ck_assert(i_nh != NULL);
-       ck_assert(i_nh->get_my_public_value(i_nh, &i_msg));
+       ck_assert(i_nh->get_public_key(i_nh, &i_msg));
 
-       r_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
+       r_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
        ck_assert(r_nh != NULL);
-       ck_assert(r_nh->set_other_public_value(r_nh, i_msg));
-       ck_assert(r_nh->get_my_public_value(r_nh, &r_msg));
+       ck_assert(r_nh->set_public_key(r_nh, i_msg));
+       ck_assert(r_nh->get_public_key(r_nh, &r_msg));
 
        /* destroy 1st instance of i_nh */
        i_nh->destroy(i_nh);
        chunk_free(&i_msg);
 
        /* create 2nd instance of i_nh */
-       i_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
+       i_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
        ck_assert(i_nh != NULL);
-       ck_assert(i_nh->get_my_public_value(i_nh, &i_msg));
-       ck_assert(i_nh->set_other_public_value(i_nh, r_msg));
+       ck_assert(i_nh->get_public_key(i_nh, &i_msg));
+       ck_assert(i_nh->set_public_key(i_nh, r_msg));
 
        ck_assert(r_nh->get_shared_secret(r_nh, &r_shared_secret));
        ck_assert(i_nh->get_shared_secret(i_nh, &i_shared_secret));
@@ -113,7 +113,7 @@ END_TEST
 
 START_TEST(test_newhope_ke_fail_i)
 {
-       diffie_hellman_t *i_nh;
+       key_exchange_t *i_nh;
        char buf_ff[2048];
        int i;
 
@@ -130,10 +130,10 @@ START_TEST(test_newhope_ke_fail_i)
 
                for (i = 0; i < countof(r_msg); i++)
        {
-               i_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
+               i_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
                ck_assert(i_nh != NULL);
-               ck_assert(i_nh->get_my_public_value(i_nh, &i_msg));
-               ck_assert(!i_nh->set_other_public_value(i_nh, r_msg[i]));
+               ck_assert(i_nh->get_public_key(i_nh, &i_msg));
+               ck_assert(!i_nh->set_public_key(i_nh, r_msg[i]));
                chunk_free(&i_msg);
                i_nh->destroy(i_nh);
        }
@@ -142,7 +142,7 @@ END_TEST
 
 START_TEST(test_newhope_ke_fail_r)
 {
-       diffie_hellman_t *r_nh;
+       key_exchange_t *r_nh;
        char buf_ff[1824];
        int i;
 
@@ -157,9 +157,9 @@ START_TEST(test_newhope_ke_fail_r)
 
        for (i = 0; i < countof(i_msg); i++)
        {
-               r_nh = lib->crypto->create_dh(lib->crypto, NH_128_BIT);
+               r_nh = lib->crypto->create_ke(lib->crypto, NH_128_BIT);
                ck_assert(r_nh != NULL);
-               ck_assert(!r_nh->set_other_public_value(r_nh, i_msg[i]));
+               ck_assert(!r_nh->set_public_key(r_nh, i_msg[i]));
                r_nh->destroy(r_nh);
        }
 }
index 3e6c3d0833cb2447ebb2c04491ec113922095104..8ac7fff3fbc0218f1d68fde168ca285839a444f0 100644 (file)
@@ -18,7 +18,7 @@
 #include "ntru_private_key.h"
 #include "ntru_public_key.h"
 
-#include <crypto/diffie_hellman.h>
+#include <crypto/key_exchange.h>
 #include <crypto/drbgs/drbg.h>
 #include <utils/debug.h>
 
@@ -56,7 +56,7 @@ struct private_ntru_ke_t {
        /**
         * Diffie Hellman group number.
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        /**
         * NTRU Parameter Set
@@ -109,7 +109,7 @@ struct private_ntru_ke_t {
        drbg_t *drbg;
 };
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_ntru_ke_t *this, chunk_t *value)
 {
        *value = chunk_empty;
@@ -140,7 +140,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_ntru_ke_t *this, chunk_t *secret)
 {
        if (!this->computed || !this->shared_secret.len)
@@ -153,7 +153,7 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_ntru_ke_t *this, chunk_t value)
 {
        if (this->privkey)
@@ -219,13 +219,13 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return this->computed;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_ntru_ke_t *this)
 {
        return this->group;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_ntru_ke_t *this)
 {
        DESTROY_IF(this->privkey);
@@ -239,7 +239,7 @@ METHOD(diffie_hellman_t, destroy, void,
 /*
  * Described in header.
  */
-ntru_ke_t *ntru_ke_create(diffie_hellman_group_t group, chunk_t g, chunk_t p)
+ntru_ke_t *ntru_ke_create(key_exchange_method_t group, chunk_t g, chunk_t p)
 {
        private_ntru_ke_t *this;
        const ntru_param_set_id_t *param_sets;
@@ -312,11 +312,11 @@ ntru_ke_t *ntru_ke_create(diffie_hellman_group_t group, chunk_t g, chunk_t p)
 
        INIT(this,
                .public = {
-                       .dh = {
+                       .ke = {
                                .get_shared_secret = _get_shared_secret,
-                               .set_other_public_value = _set_other_public_value,
-                               .get_my_public_value = _get_my_public_value,
-                               .get_dh_group = _get_dh_group,
+                               .set_public_key = _set_public_key,
+                               .get_public_key = _get_public_key,
+                               .get_method = _get_method,
                                .destroy = _destroy,
                        },
                },
index b8bbf5e5491530f35940ad3d25590657d2d0c6e8..e8c5afcf42692750ed60cb8677954c0310597338 100644 (file)
@@ -31,9 +31,9 @@ typedef struct ntru_ke_t ntru_ke_t;
 struct ntru_ke_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 };
 
 /**
@@ -44,7 +44,7 @@ struct ntru_ke_t {
  * @param p                            not used
  * @return                             ntru_ke_t object, NULL if not supported
  */
-ntru_ke_t *ntru_ke_create(diffie_hellman_group_t group, chunk_t g, chunk_t p);
+ntru_ke_t *ntru_ke_create(key_exchange_method_t group, chunk_t g, chunk_t p);
 
 #endif /** NTRU_KE_H_ @}*/
 
index dc6bd31676c7f7e32e4cc2c991dcc7aaee6ee5dd..a7351d527cff74eaa33e141e3b0c36c60c394cc2 100644 (file)
@@ -41,20 +41,20 @@ METHOD(plugin_t, get_features, int,
        private_ntru_plugin_t *this, plugin_feature_t *features[])
 {
        static plugin_feature_t f[] = {
-               PLUGIN_REGISTER(DH, ntru_ke_create),
-                       PLUGIN_PROVIDE(DH, NTRU_112_BIT),
+               PLUGIN_REGISTER(KE, ntru_ke_create),
+                       PLUGIN_PROVIDE(KE, NTRU_112_BIT),
                                PLUGIN_DEPENDS(RNG, RNG_TRUE),
                                PLUGIN_DEPENDS(SIGNER, AUTH_HMAC_SHA2_256_256),
                                PLUGIN_DEPENDS(XOF, XOF_MGF1_SHA1),
-                       PLUGIN_PROVIDE(DH, NTRU_128_BIT),
+                       PLUGIN_PROVIDE(KE, NTRU_128_BIT),
                                PLUGIN_DEPENDS(RNG, RNG_TRUE),
                                PLUGIN_DEPENDS(SIGNER, AUTH_HMAC_SHA2_256_256),
                                PLUGIN_DEPENDS(XOF, XOF_MGF1_SHA1),
-                       PLUGIN_PROVIDE(DH, NTRU_192_BIT),
+                       PLUGIN_PROVIDE(KE, NTRU_192_BIT),
                                PLUGIN_DEPENDS(RNG, RNG_TRUE),
                                PLUGIN_DEPENDS(SIGNER, AUTH_HMAC_SHA2_256_256),
                                PLUGIN_DEPENDS(XOF, XOF_MGF1_SHA256),
-                       PLUGIN_PROVIDE(DH, NTRU_256_BIT),
+                       PLUGIN_PROVIDE(KE, NTRU_256_BIT),
                                PLUGIN_DEPENDS(RNG, RNG_TRUE),
                                PLUGIN_DEPENDS(SIGNER, AUTH_HMAC_SHA2_256_256),
                                PLUGIN_DEPENDS(XOF, XOF_MGF1_SHA256),
index a567f5f4f2a41eb13cc5dac1f1d08ffb1ebb72a9..9e4c3c1324563b0628d4da55fd2c4f80fa0428da 100644 (file)
@@ -47,7 +47,7 @@ struct private_openssl_diffie_hellman_t {
        /**
         * Diffie Hellman group number.
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        /**
         * Diffie Hellman object
@@ -70,7 +70,7 @@ struct private_openssl_diffie_hellman_t {
        bool computed;
 };
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_openssl_diffie_hellman_t *this, chunk_t *value)
 {
        const BIGNUM *pubkey;
@@ -82,7 +82,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_openssl_diffie_hellman_t *this, chunk_t *secret)
 {
        if (!this->computed)
@@ -98,12 +98,12 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
 }
 
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_openssl_diffie_hellman_t *this, chunk_t value)
 {
        int len;
 
-       if (!diffie_hellman_verify_value(this->group, value))
+       if (!key_exchange_verify_pubkey(this->group, value))
        {
                return FALSE;
        }
@@ -123,7 +123,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_private_value, bool,
+METHOD(key_exchange_t, set_private_key, bool,
        private_openssl_diffie_hellman_t *this, chunk_t value)
 {
        BIGNUM *privkey;
@@ -142,7 +142,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
        return FALSE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_openssl_diffie_hellman_t *this)
 {
        return this->group;
@@ -180,7 +180,7 @@ static status_t set_modulus(private_openssl_diffie_hellman_t *this)
        return SUCCESS;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_openssl_diffie_hellman_t *this)
 {
        BN_clear_free(this->pub_key);
@@ -193,19 +193,19 @@ METHOD(diffie_hellman_t, destroy, void,
  * Described in header.
  */
 openssl_diffie_hellman_t *openssl_diffie_hellman_create(
-                                                                                       diffie_hellman_group_t group, ...)
+                                                                                       key_exchange_method_t group, ...)
 {
        private_openssl_diffie_hellman_t *this;
        const BIGNUM *privkey;
 
        INIT(this,
                .public = {
-                       .dh = {
+                       .ke = {
                                .get_shared_secret = _get_shared_secret,
-                               .set_other_public_value = _set_other_public_value,
-                               .get_my_public_value = _get_my_public_value,
-                               .set_private_value = _set_private_value,
-                               .get_dh_group = _get_dh_group,
+                               .set_public_key = _set_public_key,
+                               .get_public_key = _get_public_key,
+                               .set_private_key = _set_private_key,
+                               .get_method = _get_method,
                                .destroy = _destroy,
                        },
                },
index 43d1f3fa889fb93f609f39328e80aba38cac6436..999283555616cb07b5127d986e35010b6a6629df 100644 (file)
@@ -31,20 +31,20 @@ typedef struct openssl_diffie_hellman_t openssl_diffie_hellman_t;
 struct openssl_diffie_hellman_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 };
 
 /**
  * Creates a new openssl_diffie_hellman_t object.
  *
- * @param group                        Diffie Hellman group number to use
+ * @param group                        Diffie-Hellman group number to use
  * @param ...                  expects generator and prime as chunk_t if MODP_CUSTOM
  * @return                             openssl_diffie_hellman_t object, NULL if not supported
  */
 openssl_diffie_hellman_t *openssl_diffie_hellman_create(
-                                                                                       diffie_hellman_group_t group, ...);
+                                                                                       key_exchange_method_t group, ...);
 
 #endif /** OPENSSL_DIFFIE_HELLMAN_H_ @}*/
 
index 19de540b65a972760bdb9eff1eddee5fd1b0702c..48827493586011bc607020e838d67a68ec83ba3f 100644 (file)
@@ -41,7 +41,7 @@ struct private_openssl_ec_diffie_hellman_t {
        /**
         * Diffie Hellman group number.
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        /**
         * EC private (public) key
@@ -217,10 +217,10 @@ error:
        return ret;
 }
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_openssl_ec_diffie_hellman_t *this, chunk_t value)
 {
-       if (!diffie_hellman_verify_value(this->group, value))
+       if (!key_exchange_verify_pubkey(this->group, value))
        {
                return FALSE;
        }
@@ -242,14 +242,14 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_openssl_ec_diffie_hellman_t *this,chunk_t *value)
 {
        ecp2chunk(this->ec_group, EC_KEY_get0_public_key(this->key), value, FALSE);
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_private_value, bool,
+METHOD(key_exchange_t, set_private_key, bool,
        private_openssl_ec_diffie_hellman_t *this, chunk_t value)
 {
        EC_POINT *pub = NULL;
@@ -292,7 +292,7 @@ error:
        return ret;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_openssl_ec_diffie_hellman_t *this, chunk_t *secret)
 {
        if (!this->computed)
@@ -303,13 +303,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_openssl_ec_diffie_hellman_t *this)
 {
        return this->group;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_openssl_ec_diffie_hellman_t *this)
 {
        if (this->pub_key)
@@ -339,7 +339,7 @@ METHOD(diffie_hellman_t, destroy, void,
  */
 typedef struct {
        /** DH group */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        /** The prime p specifying the base field */
        const chunk_t p;
@@ -535,7 +535,7 @@ failed:
 /**
  * Create an EC_KEY for ECC Brainpool curves as defined above
  */
-static EC_KEY *ec_key_new_brainpool(diffie_hellman_group_t group)
+static EC_KEY *ec_key_new_brainpool(key_exchange_method_t group)
 {
        bp_curve *curve = NULL;
        EC_GROUP *ec_group;
@@ -573,7 +573,7 @@ static EC_KEY *ec_key_new_brainpool(diffie_hellman_group_t group)
 /**
  * Create an EC_KEY for ECC Brainpool curves as defined by OpenSSL
  */
-static EC_KEY *ec_key_new_brainpool(diffie_hellman_group_t group)
+static EC_KEY *ec_key_new_brainpool(key_exchange_method_t group)
 {
        switch (group)
        {
@@ -595,18 +595,19 @@ static EC_KEY *ec_key_new_brainpool(diffie_hellman_group_t group)
 /*
  * Described in header.
  */
-openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(diffie_hellman_group_t group)
+openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(
+                                                                                                       key_exchange_method_t group)
 {
        private_openssl_ec_diffie_hellman_t *this;
 
        INIT(this,
                .public = {
-                       .dh = {
+                       .ke = {
                                .get_shared_secret = _get_shared_secret,
-                               .set_other_public_value = _set_other_public_value,
-                               .get_my_public_value = _get_my_public_value,
-                               .set_private_value = _set_private_value,
-                               .get_dh_group = _get_dh_group,
+                               .set_public_key = _set_public_key,
+                               .get_public_key = _get_public_key,
+                               .set_private_key = _set_private_key,
+                               .get_method = _get_method,
                                .destroy = _destroy,
                        },
                },
index 2f58c976d77073f0f0b7267fcda8ee70599298f4..cdc1fee2cead7e32964a92409ebd843b5dd334bf 100644 (file)
@@ -31,18 +31,18 @@ typedef struct openssl_ec_diffie_hellman_t openssl_ec_diffie_hellman_t;
 struct openssl_ec_diffie_hellman_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 };
 
 /**
  * Creates a new openssl_ec_diffie_hellman_t object.
  *
- * @param group                        EC Diffie Hellman group number to use
- * @return                             openssl_ec_diffie_hellman_t object, NULL if not supported
+ * @param group                        EC Diffie-Hellman group number to use
+ * @return                             openssl_ec_diffie_hellman_t object, NULL if unsupported
  */
-openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(diffie_hellman_group_t group);
+openssl_ec_diffie_hellman_t *openssl_ec_diffie_hellman_create(
+                                                                                               key_exchange_method_t group);
 
 #endif /** OPENSSL_EC_DIFFIE_HELLMAN_H_ @}*/
-
index e17bb32809b2bbcf89029a2d9e66a4d74afe7e01..8f99eb2569b6aa9e360544bee8db4f42bb81604a 100644 (file)
@@ -622,32 +622,32 @@ METHOD(plugin_t, get_features, int,
 #endif /* OPENSSL_VERSION_NUMBER */
 #ifndef OPENSSL_NO_ECDH
                /* EC DH groups */
-               PLUGIN_REGISTER(DH, openssl_ec_diffie_hellman_create),
-                       PLUGIN_PROVIDE(DH, ECP_256_BIT),
-                       PLUGIN_PROVIDE(DH, ECP_384_BIT),
-                       PLUGIN_PROVIDE(DH, ECP_521_BIT),
-                       PLUGIN_PROVIDE(DH, ECP_224_BIT),
-                       PLUGIN_PROVIDE(DH, ECP_192_BIT),
-                       PLUGIN_PROVIDE(DH, ECP_256_BP),
-                       PLUGIN_PROVIDE(DH, ECP_384_BP),
-                       PLUGIN_PROVIDE(DH, ECP_512_BP),
-                       PLUGIN_PROVIDE(DH, ECP_224_BP),
+               PLUGIN_REGISTER(KE, openssl_ec_diffie_hellman_create),
+                       PLUGIN_PROVIDE(KE, ECP_256_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_384_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_521_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_224_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_192_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_256_BP),
+                       PLUGIN_PROVIDE(KE, ECP_384_BP),
+                       PLUGIN_PROVIDE(KE, ECP_512_BP),
+                       PLUGIN_PROVIDE(KE, ECP_224_BP),
 #endif /* OPENSSL_NO_ECDH */
 #ifndef OPENSSL_NO_DH
                /* MODP DH groups */
-               PLUGIN_REGISTER(DH, openssl_diffie_hellman_create),
-                       PLUGIN_PROVIDE(DH, MODP_3072_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_4096_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_6144_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_8192_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_2048_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_2048_224),
-                       PLUGIN_PROVIDE(DH, MODP_2048_256),
-                       PLUGIN_PROVIDE(DH, MODP_1536_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_1024_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_1024_160),
-                       PLUGIN_PROVIDE(DH, MODP_768_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_CUSTOM),
+               PLUGIN_REGISTER(KE, openssl_diffie_hellman_create),
+                       PLUGIN_PROVIDE(KE, MODP_3072_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_4096_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_6144_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_8192_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_2048_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_2048_224),
+                       PLUGIN_PROVIDE(KE, MODP_2048_256),
+                       PLUGIN_PROVIDE(KE, MODP_1536_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_1024_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_1024_160),
+                       PLUGIN_PROVIDE(KE, MODP_768_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_CUSTOM),
 #endif
 #ifndef OPENSSL_NO_RSA
                /* RSA private/public key loading */
@@ -738,11 +738,11 @@ METHOD(plugin_t, get_features, int,
 #endif
 #endif /* OPENSSL_NO_ECDSA */
 #if OPENSSL_VERSION_NUMBER >= 0x1010100fL && !defined(OPENSSL_NO_EC)
-               PLUGIN_REGISTER(DH, openssl_x_diffie_hellman_create),
+               PLUGIN_REGISTER(KE, openssl_x_diffie_hellman_create),
                        /* available since 1.1.0a, but we require 1.1.1 features */
-                       PLUGIN_PROVIDE(DH, CURVE_25519),
+                       PLUGIN_PROVIDE(KE, CURVE_25519),
                        /* available since 1.1.1 */
-                       PLUGIN_PROVIDE(DH, CURVE_448),
+                       PLUGIN_PROVIDE(KE, CURVE_448),
                /* EdDSA private/public key loading */
                PLUGIN_REGISTER(PUBKEY, openssl_ed_public_key_load, TRUE),
                        PLUGIN_PROVIDE(PUBKEY, KEY_ED25519),
index 37943f5bf68b31580fdfd3c08e799adee51d369f..b26359beaf0e114c50cd76249ecba21db96cc3f4 100644 (file)
 
 #include <utils/debug.h>
 
-typedef struct private_diffie_hellman_t private_diffie_hellman_t;
+typedef struct private_key_exchange_t private_key_exchange_t;
 
 /**
  * Private data
  */
-struct private_diffie_hellman_t {
+struct private_key_exchange_t {
        /**
         * Public interface.
         */
-       diffie_hellman_t public;
+       key_exchange_t public;
 
        /**
-        * Diffie Hellman group number.
+        * Key exchange method.
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t ke;
 
        /**
         * Private (public) key
@@ -56,11 +56,11 @@ struct private_diffie_hellman_t {
 };
 
 /**
- * Map a DH group to a key type
+ * Map a key exchange method to a key type
  */
-static int map_key_type(diffie_hellman_group_t group)
+static int map_key_type(key_exchange_method_t ke)
 {
-       switch (group)
+       switch (ke)
        {
                case CURVE_25519:
                        return EVP_PKEY_X25519;
@@ -74,7 +74,7 @@ static int map_key_type(diffie_hellman_group_t group)
 /**
  * Compute the shared secret
  */
-static bool compute_shared_key(private_diffie_hellman_t *this, EVP_PKEY *pub,
+static bool compute_shared_key(private_key_exchange_t *this, EVP_PKEY *pub,
                                                           chunk_t *shared_secret)
 {
        EVP_PKEY_CTX *ctx;
@@ -115,22 +115,22 @@ error:
        return success;
 }
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
-       private_diffie_hellman_t *this, chunk_t value)
+METHOD(key_exchange_t, set_public_key, bool,
+       private_key_exchange_t *this, chunk_t value)
 {
        EVP_PKEY *pub;
 
-       if (!diffie_hellman_verify_value(this->group, value))
+       if (!key_exchange_verify_pubkey(this->ke, value))
        {
                return FALSE;
        }
 
-       pub =  EVP_PKEY_new_raw_public_key(map_key_type(this->group), NULL,
+       pub =  EVP_PKEY_new_raw_public_key(map_key_type(this->ke), NULL,
                                        value.ptr, value.len);
        if (!pub)
        {
                DBG1(DBG_LIB, "%N public value is malformed",
-                        diffie_hellman_group_names, this->group);
+                        key_exchange_method_names, this->ke);
                return FALSE;
        }
 
@@ -139,7 +139,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        if (!compute_shared_key(this, pub, &this->shared_secret))
        {
                DBG1(DBG_LIB, "%N shared secret computation failed",
-                        diffie_hellman_group_names, this->group);
+                        key_exchange_method_names, this->ke);
                EVP_PKEY_free(pub);
                return FALSE;
        }
@@ -148,8 +148,8 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
-       private_diffie_hellman_t *this, chunk_t *value)
+METHOD(key_exchange_t, get_public_key, bool,
+       private_key_exchange_t *this, chunk_t *value)
 {
        size_t len;
 
@@ -168,11 +168,11 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_private_value, bool,
-       private_diffie_hellman_t *this, chunk_t value)
+METHOD(key_exchange_t, set_private_key, bool,
+       private_key_exchange_t *this, chunk_t value)
 {
        EVP_PKEY_free(this->key);
-       this->key = EVP_PKEY_new_raw_private_key(map_key_type(this->group), NULL,
+       this->key = EVP_PKEY_new_raw_private_key(map_key_type(this->ke), NULL,
                                                                                         value.ptr, value.len);
        if (!this->key)
        {
@@ -181,8 +181,8 @@ METHOD(diffie_hellman_t, set_private_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
-       private_diffie_hellman_t *this, chunk_t *secret)
+METHOD(key_exchange_t, get_shared_secret, bool,
+       private_key_exchange_t *this, chunk_t *secret)
 {
        if (!this->computed)
        {
@@ -192,14 +192,14 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
-       private_diffie_hellman_t *this)
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
+       private_key_exchange_t *this)
 {
-       return this->group;
+       return this->ke;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
-       private_diffie_hellman_t *this)
+METHOD(key_exchange_t, destroy, void,
+       private_key_exchange_t *this)
 {
        EVP_PKEY_free(this->key);
        chunk_clear(&this->shared_secret);
@@ -209,13 +209,13 @@ METHOD(diffie_hellman_t, destroy, void,
 /*
  * Described in header
  */
-diffie_hellman_t *openssl_x_diffie_hellman_create(diffie_hellman_group_t group)
+key_exchange_t *openssl_x_diffie_hellman_create(key_exchange_method_t ke)
 {
-       private_diffie_hellman_t *this;
+       private_key_exchange_t *this;
        EVP_PKEY_CTX *ctx = NULL;
        EVP_PKEY *key = NULL;
 
-       switch (group)
+       switch (ke)
        {
                case CURVE_25519:
                        ctx = EVP_PKEY_CTX_new_id(NID_X25519, NULL);
@@ -232,7 +232,7 @@ diffie_hellman_t *openssl_x_diffie_hellman_create(diffie_hellman_group_t group)
                EVP_PKEY_keygen(ctx, &key) <= 0)
        {
                DBG1(DBG_LIB, "generating key for %N failed",
-                        diffie_hellman_group_names, group);
+                        key_exchange_method_names, ke);
                EVP_PKEY_CTX_free(ctx);
                return NULL;
        }
@@ -241,13 +241,13 @@ diffie_hellman_t *openssl_x_diffie_hellman_create(diffie_hellman_group_t group)
        INIT(this,
                .public = {
                        .get_shared_secret = _get_shared_secret,
-                       .set_other_public_value = _set_other_public_value,
-                       .get_my_public_value = _get_my_public_value,
-                       .set_private_value = _set_private_value,
-                       .get_dh_group = _get_dh_group,
+                       .set_public_key = _set_public_key,
+                       .get_public_key = _get_public_key,
+                       .set_private_key = _set_private_key,
+                       .get_method = _get_method,
                        .destroy = _destroy,
                },
-               .group = group,
+               .ke = ke,
                .key = key,
        );
        return &this->public;
index e28f38d15f38fed33e221bde91d030659240f2ba..004d33a04cb203ad320a2bb35ec93ac49bc15d09 100644 (file)
 #include <library.h>
 
 /**
- * Creates a new diffie_hellman_t object.
+ * Creates a new key_exchange_t object.
  *
- * @param group                        Diffie Hellman group number to use
+ * @param ke                   key exchange method to use
  * @return                             object, NULL if not supported
  */
-diffie_hellman_t *openssl_x_diffie_hellman_create(diffie_hellman_group_t group);
+key_exchange_t *openssl_x_diffie_hellman_create(key_exchange_method_t ke);
 
 #endif /** OPENSSL_X_DIFFIE_HELLMAN_H_ @}*/
 
index 565a57f9a6ed6c033c70d74808f8f16edd4cbc36..f9710c584a72b7082bac77de1d40f777a365c450 100644 (file)
@@ -45,9 +45,9 @@ struct private_pkcs11_dh_t {
        CK_SESSION_HANDLE session;
 
        /**
-        * Diffie Hellman group number.
+        * Diffie-Hellman group number.
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        /**
         * Handle for own private value
@@ -113,10 +113,10 @@ static bool derive_secret(private_pkcs11_dh_t *this, chunk_t other)
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_pkcs11_dh_t *this, chunk_t value)
 {
-       if (!diffie_hellman_verify_value(this->group, value))
+       if (!key_exchange_verify_pubkey(this->group, value))
        {
                return FALSE;
        }
@@ -154,14 +154,14 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return derive_secret(this, value);
 }
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_pkcs11_dh_t *this, chunk_t *value)
 {
        *value = chunk_clone(this->pub_key);
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_pkcs11_dh_t *this, chunk_t *secret)
 {
        if (!this->secret.ptr)
@@ -172,13 +172,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_pkcs11_dh_t *this)
 {
        return this->group;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_pkcs11_dh_t *this)
 {
        this->lib->f->C_CloseSession(this->session);
@@ -321,7 +321,7 @@ static pkcs11_library_t *find_token(private_pkcs11_dh_t *this,
 /**
  * Generic internal constructor
  */
-static private_pkcs11_dh_t *create_generic(diffie_hellman_group_t group,
+static private_pkcs11_dh_t *create_generic(key_exchange_method_t group,
                                                                                   CK_MECHANISM_TYPE key,
                                                                                   CK_MECHANISM_TYPE derive)
 {
@@ -329,11 +329,11 @@ static private_pkcs11_dh_t *create_generic(diffie_hellman_group_t group,
 
        INIT(this,
                .public = {
-                       .dh = {
+                       .ke = {
                                .get_shared_secret = _get_shared_secret,
-                               .set_other_public_value = _set_other_public_value,
-                               .get_my_public_value = _get_my_public_value,
-                               .get_dh_group = _get_dh_group,
+                               .set_public_key = _set_public_key,
+                               .get_public_key = _get_public_key,
+                               .get_method = _get_method,
                                .destroy = _destroy,
                        },
                },
@@ -351,7 +351,7 @@ static private_pkcs11_dh_t *create_generic(diffie_hellman_group_t group,
        return this;
 }
 
-static pkcs11_dh_t *create_ecp(diffie_hellman_group_t group, chunk_t ecparam)
+static pkcs11_dh_t *create_ecp(key_exchange_method_t group, chunk_t ecparam)
 {
        private_pkcs11_dh_t *this = create_generic(group, CKM_EC_KEY_PAIR_GEN,
                                                                                           CKM_ECDH1_DERIVE);
@@ -372,7 +372,7 @@ static pkcs11_dh_t *create_ecp(diffie_hellman_group_t group, chunk_t ecparam)
 /**
  * Constructor for MODP DH
  */
-static pkcs11_dh_t *create_modp(diffie_hellman_group_t group, size_t exp_len,
+static pkcs11_dh_t *create_modp(key_exchange_method_t group, size_t exp_len,
                                                                chunk_t g, chunk_t p)
 {
        private_pkcs11_dh_t *this = create_generic(group, CKM_DH_PKCS_KEY_PAIR_GEN,
@@ -392,7 +392,7 @@ static pkcs11_dh_t *create_modp(diffie_hellman_group_t group, size_t exp_len,
 /**
  * Lookup the EC params for the given group.
  */
-static chunk_t ecparams_lookup(diffie_hellman_group_t group)
+static chunk_t ecparams_lookup(key_exchange_method_t group)
 {
        switch (group)
        {
@@ -415,7 +415,7 @@ static chunk_t ecparams_lookup(diffie_hellman_group_t group)
 /**
  * Described in header.
  */
-pkcs11_dh_t *pkcs11_dh_create(diffie_hellman_group_t group, ...)
+pkcs11_dh_t *pkcs11_dh_create(key_exchange_method_t group, ...)
 {
        switch (group)
        {
index 3f68c62ec6f7567a19d8b755355b471eeb8612bf..949a47d4eb046549bab1bbaa7ff85ece6bdcb7b7 100644 (file)
@@ -31,19 +31,19 @@ typedef struct pkcs11_dh_t pkcs11_dh_t;
 struct pkcs11_dh_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 };
 
 /**
  * Creates a new pkcs11_dh_t object.
  *
- * @param group                        Diffie Hellman group number to use
+ * @param group                        Diffie-Hellman group number to use
  * @param ...                  expects generator and prime as chunk_t if MODP_CUSTOM
  * @return                             pkcs11_dh_t object, NULL if not supported
  */
-pkcs11_dh_t *pkcs11_dh_create(diffie_hellman_group_t group, ...);
+pkcs11_dh_t *pkcs11_dh_create(key_exchange_method_t group, ...);
 
 #endif /** PKCS11_DH_H_ @}*/
 
index d6bf4de4226609edb77671ac76598f9c95679c12..0c2f21b49a04b25eaeebb8b55acf84ba8ed52e9f 100644 (file)
@@ -198,27 +198,27 @@ METHOD(plugin_t, get_features, int,
                        PLUGIN_PROVIDE(HASHER, HASH_SHA512),
        };
        static plugin_feature_t f_dh[] = {
-               PLUGIN_REGISTER(DH, pkcs11_dh_create),
-                       PLUGIN_PROVIDE(DH, MODP_2048_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_2048_224),
-                       PLUGIN_PROVIDE(DH, MODP_2048_256),
-                       PLUGIN_PROVIDE(DH, MODP_1536_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_3072_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_4096_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_6144_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_8192_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_1024_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_1024_160),
-                       PLUGIN_PROVIDE(DH, MODP_768_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_CUSTOM),
+               PLUGIN_REGISTER(KE, pkcs11_dh_create),
+                       PLUGIN_PROVIDE(KE, MODP_2048_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_2048_224),
+                       PLUGIN_PROVIDE(KE, MODP_2048_256),
+                       PLUGIN_PROVIDE(KE, MODP_1536_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_3072_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_4096_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_6144_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_8192_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_1024_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_1024_160),
+                       PLUGIN_PROVIDE(KE, MODP_768_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_CUSTOM),
        };
        static plugin_feature_t f_ecdh[] = {
-               PLUGIN_REGISTER(DH, pkcs11_dh_create),
-                       PLUGIN_PROVIDE(DH, ECP_192_BIT),
-                       PLUGIN_PROVIDE(DH, ECP_224_BIT),
-                       PLUGIN_PROVIDE(DH, ECP_256_BIT),
-                       PLUGIN_PROVIDE(DH, ECP_384_BIT),
-                       PLUGIN_PROVIDE(DH, ECP_521_BIT),
+               PLUGIN_REGISTER(KE, pkcs11_dh_create),
+                       PLUGIN_PROVIDE(KE, ECP_192_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_224_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_256_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_384_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_521_BIT),
        };
        static plugin_feature_t f_rng[] = {
                PLUGIN_REGISTER(RNG, pkcs11_rng_create),
index fa3d1f31b68cabb23683638ab533b7c1954e31e6..f9c2ea26ba2afa7c3af2db5dfc002dbe8a340ef4 100644 (file)
@@ -33,7 +33,7 @@ ENUM(plugin_feature_names, FEATURE_NONE, FEATURE_CUSTOM,
        "PRF",
        "XOF",
        "DRBG",
-       "DH",
+       "KE",
        "RNG",
        "NONCE_GEN",
        "PRIVKEY",
@@ -96,8 +96,8 @@ uint32_t plugin_feature_hash(plugin_feature_t *feature)
                case FEATURE_DRBG:
                        data = chunk_from_thing(feature->arg.drbg);
                        break;
-               case FEATURE_DH:
-                       data = chunk_from_thing(feature->arg.dh_group);
+               case FEATURE_KE:
+                       data = chunk_from_thing(feature->arg.ke);
                        break;
                case FEATURE_PRIVKEY:
                        data = chunk_from_thing(feature->arg.privkey);
@@ -173,8 +173,8 @@ bool plugin_feature_matches(plugin_feature_t *a, plugin_feature_t *b)
                                return a->arg.xof == b->arg.xof;
                        case FEATURE_DRBG:
                                return a->arg.drbg == b->arg.drbg;
-                       case FEATURE_DH:
-                               return a->arg.dh_group == b->arg.dh_group;
+                       case FEATURE_KE:
+                               return a->arg.ke == b->arg.ke;
                        case FEATURE_RNG:
                                return a->arg.rng_quality <= b->arg.rng_quality;
                        case FEATURE_NONCE_GEN:
@@ -233,7 +233,7 @@ bool plugin_feature_equals(plugin_feature_t *a, plugin_feature_t *b)
                        case FEATURE_PRF:
                        case FEATURE_XOF:
                        case FEATURE_DRBG:
-                       case FEATURE_DH:
+                       case FEATURE_KE:
                        case FEATURE_NONCE_GEN:
                        case FEATURE_RESOLVER:
                        case FEATURE_PRIVKEY:
@@ -334,9 +334,9 @@ char* plugin_feature_get_string(plugin_feature_t *feature)
                                return str;
                        }
                        break;
-               case FEATURE_DH:
+               case FEATURE_KE:
                        if (asprintf(&str, "%N:%N", plugin_feature_names, feature->type,
-                                       diffie_hellman_group_names, feature->arg.dh_group) > 0)
+                                       key_exchange_method_names, feature->arg.ke) > 0)
                        {
                                return str;
                        }
@@ -502,8 +502,8 @@ bool plugin_feature_load(plugin_t *plugin, plugin_feature_t *feature,
                        lib->crypto->add_drbg(lib->crypto, feature->arg.drbg,
                                                                name, reg->arg.reg.f);
                        break;
-               case FEATURE_DH:
-                       lib->crypto->add_dh(lib->crypto, feature->arg.dh_group,
+               case FEATURE_KE:
+                       lib->crypto->add_ke(lib->crypto, feature->arg.ke,
                                                                name, reg->arg.reg.f);
                        break;
                case FEATURE_RNG:
@@ -595,8 +595,8 @@ bool plugin_feature_unload(plugin_t *plugin, plugin_feature_t *feature,
                case FEATURE_DRBG:
                        lib->crypto->remove_drbg(lib->crypto, reg->arg.reg.f);
                        break;
-               case FEATURE_DH:
-                       lib->crypto->remove_dh(lib->crypto, reg->arg.reg.f);
+               case FEATURE_KE:
+                       lib->crypto->remove_ke(lib->crypto, reg->arg.reg.f);
                        break;
                case FEATURE_RNG:
                        lib->crypto->remove_rng(lib->crypto, reg->arg.reg.f);
index 2692de2ceb12fc2b687b608d812f7e300f04b851..0c6b0a8d5497c240514edbca3d38438df076ce23 100644 (file)
@@ -115,8 +115,8 @@ struct plugin_feature_t {
                FEATURE_XOF,
                /** drbg_t */
                FEATURE_DRBG,
-               /** diffie_hellman_t */
-               FEATURE_DH,
+               /** key_exchange_t */
+               FEATURE_KE,
                /** rng_t */
                FEATURE_RNG,
                /** nonce_gen_t */
@@ -182,8 +182,8 @@ struct plugin_feature_t {
                drbg_type_t drbg;
                /** FEATURE_HASHER */
                hash_algorithm_t hasher;
-               /** FEATURE_DH */
-               diffie_hellman_group_t dh_group;
+               /** FEATURE_KE */
+               key_exchange_method_t ke;
                /** FEATURE_RNG */
                rng_quality_t rng_quality;
                /** FEATURE_PRIVKEY */
@@ -289,7 +289,7 @@ struct plugin_feature_t {
 #define _PLUGIN_FEATURE_PRF(kind, alg)                                         __PLUGIN_FEATURE(kind, PRF, .prf = alg)
 #define _PLUGIN_FEATURE_XOF(kind, alg)                                         __PLUGIN_FEATURE(kind, XOF, .xof = alg)
 #define _PLUGIN_FEATURE_DRBG(kind, type)                                       __PLUGIN_FEATURE(kind, DRBG, .drbg = type)
-#define _PLUGIN_FEATURE_DH(kind, group)                                                __PLUGIN_FEATURE(kind, DH, .dh_group = group)
+#define _PLUGIN_FEATURE_KE(kind, method)                                       __PLUGIN_FEATURE(kind, KE, .ke = method)
 #define _PLUGIN_FEATURE_RNG(kind, quality)                                     __PLUGIN_FEATURE(kind, RNG, .rng_quality = quality)
 #define _PLUGIN_FEATURE_NONCE_GEN(kind, ...)                           __PLUGIN_FEATURE(kind, NONCE_GEN, .custom = NULL)
 #define _PLUGIN_FEATURE_PRIVKEY(kind, type)                                    __PLUGIN_FEATURE(kind, PRIVKEY, .privkey = type)
@@ -323,7 +323,7 @@ struct plugin_feature_t {
 #define _PLUGIN_FEATURE_REGISTER_PRF(type, f)                          __PLUGIN_FEATURE_REGISTER(type, f)
 #define _PLUGIN_FEATURE_REGISTER_XOF(type, f)                          __PLUGIN_FEATURE_REGISTER(type, f)
 #define _PLUGIN_FEATURE_REGISTER_DRBG(type, f)                         __PLUGIN_FEATURE_REGISTER(type, f)
-#define _PLUGIN_FEATURE_REGISTER_DH(type, f)                           __PLUGIN_FEATURE_REGISTER(type, f)
+#define _PLUGIN_FEATURE_REGISTER_KE(type, f)                           __PLUGIN_FEATURE_REGISTER(type, f)
 #define _PLUGIN_FEATURE_REGISTER_RNG(type, f)                          __PLUGIN_FEATURE_REGISTER(type, f)
 #define _PLUGIN_FEATURE_REGISTER_NONCE_GEN(type, f)                    __PLUGIN_FEATURE_REGISTER(type, f)
 #define _PLUGIN_FEATURE_REGISTER_PRIVKEY(type, f, final)       __PLUGIN_FEATURE_REGISTER_BUILDER(type, f, final)
index e108d6fc210f3eea8b7abace68903a46b3f09e38..41340cf5c17f1c3ac0b5fb0ef147a6df96323b64 100644 (file)
@@ -331,26 +331,26 @@ TEST_VECTOR_RNG(rng_runs_1)
 TEST_VECTOR_RNG(rng_runs_2)
 TEST_VECTOR_RNG(rng_runs_3)
 
-TEST_VECTOR_DH(modp768)
-TEST_VECTOR_DH(modp1024)
-TEST_VECTOR_DH(modp1536)
-TEST_VECTOR_DH(modp2048)
-TEST_VECTOR_DH(modp3072)
-TEST_VECTOR_DH(modp4096)
-TEST_VECTOR_DH(modp6144)
-TEST_VECTOR_DH(modp8192)
-TEST_VECTOR_DH(modp1024_160)
-TEST_VECTOR_DH(modp2048_224)
-TEST_VECTOR_DH(modp2048_256)
-TEST_VECTOR_DH(ecp192)
-TEST_VECTOR_DH(ecp224)
-TEST_VECTOR_DH(ecp256)
-TEST_VECTOR_DH(ecp384)
-TEST_VECTOR_DH(ecp521)
-TEST_VECTOR_DH(ecp224bp)
-TEST_VECTOR_DH(ecp256bp)
-TEST_VECTOR_DH(ecp384bp)
-TEST_VECTOR_DH(ecp512bp)
-TEST_VECTOR_DH(curve25519_1)
-TEST_VECTOR_DH(curve25519_2)
-TEST_VECTOR_DH(curve448_1)
+TEST_VECTOR_KE(modp768)
+TEST_VECTOR_KE(modp1024)
+TEST_VECTOR_KE(modp1536)
+TEST_VECTOR_KE(modp2048)
+TEST_VECTOR_KE(modp3072)
+TEST_VECTOR_KE(modp4096)
+TEST_VECTOR_KE(modp6144)
+TEST_VECTOR_KE(modp8192)
+TEST_VECTOR_KE(modp1024_160)
+TEST_VECTOR_KE(modp2048_224)
+TEST_VECTOR_KE(modp2048_256)
+TEST_VECTOR_KE(ecp192)
+TEST_VECTOR_KE(ecp224)
+TEST_VECTOR_KE(ecp256)
+TEST_VECTOR_KE(ecp384)
+TEST_VECTOR_KE(ecp521)
+TEST_VECTOR_KE(ecp224bp)
+TEST_VECTOR_KE(ecp256bp)
+TEST_VECTOR_KE(ecp384bp)
+TEST_VECTOR_KE(ecp512bp)
+TEST_VECTOR_KE(curve25519_1)
+TEST_VECTOR_KE(curve25519_2)
+TEST_VECTOR_KE(curve448_1)
index 23c024a37b495d7ea924624e59e97a191fcb2403..693d56073cbf5dead68952399b7bb98cea9e9d6d 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * From RFC 7748
  */
-dh_test_vector_t curve25519_1 = {
-       .group = CURVE_25519, .priv_len = 32, .pub_len = 32, .shared_len = 32,
+ke_test_vector_t curve25519_1 = {
+       .method = CURVE_25519, .priv_len = 32, .pub_len = 32, .shared_len = 32,
        .priv_a = "\x77\x07\x6d\x0a\x73\x18\xa5\x7d\x3c\x16\xc1\x72\x51\xb2\x66\x45"
                          "\xdf\x4c\x2f\x87\xeb\xc0\x99\x2a\xb1\x77\xfb\xa5\x1d\xb9\x2c\x2a",
        .priv_b = "\x5d\xab\x08\x7e\x62\x4a\x8a\x4b\x79\xe1\x7f\x8b\x83\x80\x0e\xe6"
@@ -35,8 +35,8 @@ dh_test_vector_t curve25519_1 = {
 /**
  * From RFC 8031
  */
-dh_test_vector_t curve25519_2 = {
-       .group = CURVE_25519, .priv_len = 32, .pub_len = 32, .shared_len = 32,
+ke_test_vector_t curve25519_2 = {
+       .method = CURVE_25519, .priv_len = 32, .pub_len = 32, .shared_len = 32,
        .priv_a = "\x75\x1f\xb4\x30\x86\x55\xb4\x76\xb6\x78\x9b\x73\x25\xf9\xea\x8c"
                          "\xdd\xd1\x6a\x58\x53\x3f\xf6\xd9\xe6\x00\x09\x46\x4a\x5f\x9d\x94",
        .priv_b = "\x0a\x54\x64\x52\x53\x29\x0d\x60\xdd\xad\xd0\xe0\x30\xba\xcd\x9e"
index fccbb808ad8c2376750a8207c06132bf412c999a..0922b8b4b1897bb253084e3af7709b69f642799e 100644 (file)
@@ -18,8 +18,8 @@
 /**
  * From RFC 7748
  */
-dh_test_vector_t curve448_1 = {
-       .group = CURVE_448, .priv_len = 56, .pub_len = 56, .shared_len = 56,
+ke_test_vector_t curve448_1 = {
+       .method = CURVE_448, .priv_len = 56, .pub_len = 56, .shared_len = 56,
        .priv_a = "\x9a\x8f\x49\x25\xd1\x51\x9f\x57\x75\xcf\x46\xb0\x4b\x58\x00\xd4"
                          "\xee\x9e\xe8\xba\xe8\xbc\x55\x65\xd4\x98\xc2\x8d\xd9\xc9\xba\xf5"
                          "\x74\xa9\x41\x97\x44\x89\x73\x91\x00\x63\x82\xa6\xf1\x27\xab\x1d"
index b3c94b2dea5bd8d045299755dd2db801fb0635d5..95b94bc6ff26bf09f5391430fcb2d451a45d1d3c 100644 (file)
@@ -19,8 +19,8 @@
  * Test vectors from RFC5114
  */
 
-dh_test_vector_t ecp192 = {
-       .group = ECP_192_BIT, .priv_len = 24, .pub_len = 48, .shared_len = 24,
+ke_test_vector_t ecp192 = {
+       .method = ECP_192_BIT, .priv_len = 24, .pub_len = 48, .shared_len = 24,
        .priv_a = "\x32\x3f\xa3\x16\x9d\x8e\x9c\x65\x93\xf5\x94\x76\xbc\x14\x20\x00"
                          "\xab\x5b\xe0\xe2\x49\xc4\x34\x26",
        .priv_b = "\x63\x1f\x95\xbb\x4a\x67\x63\x2c\x9c\x47\x6e\xee\x9a\xb6\x95\xab"
@@ -35,8 +35,8 @@ dh_test_vector_t ecp192 = {
                          "\xe5\xff\x4f\x83\x7f\x54\xfe\xbe",
 };
 
-dh_test_vector_t ecp224 = {
-       .group = ECP_224_BIT, .priv_len = 28, .pub_len = 56, .shared_len = 28,
+ke_test_vector_t ecp224 = {
+       .method = ECP_224_BIT, .priv_len = 28, .pub_len = 56, .shared_len = 28,
        .priv_a = "\xb5\x58\xeb\x6c\x28\x8d\xa7\x07\xbb\xb4\xf8\xfb\xae\x2a\xb9\xe9"
                          "\xcb\x62\xe3\xbc\x5c\x75\x73\xe2\x2e\x26\xd3\x7f",
        .priv_b = "\xac\x3b\x1a\xdd\x3d\x97\x70\xe6\xf6\xa7\x08\xee\x9f\x3b\x8e\x0a"
@@ -53,8 +53,8 @@ dh_test_vector_t ecp224 = {
                          "\xd9\x6e\xcc\x3b\x6d\xc1\x71\x4a\x4e\xa9\x49\xfa",
 };
 
-dh_test_vector_t ecp256 = {
-       .group = ECP_256_BIT, .priv_len = 32, .pub_len = 64, .shared_len = 32,
+ke_test_vector_t ecp256 = {
+       .method = ECP_256_BIT, .priv_len = 32, .pub_len = 64, .shared_len = 32,
        .priv_a = "\x81\x42\x64\x14\x5f\x2f\x56\xf2\xe9\x6a\x8e\x33\x7a\x12\x84\x99"
                          "\x3f\xaf\x43\x2a\x5a\xbc\xe5\x9e\x86\x7b\x72\x91\xd5\x07\xa3\xaf",
        .priv_b = "\x2c\xe1\x78\x8e\xc1\x97\xe0\x96\xdb\x95\xa2\x00\xcc\x0a\xb2\x6a"
@@ -71,8 +71,8 @@ dh_test_vector_t ecp256 = {
                          "\xf5\x81\x1e\x9d\xc8\xec\x8e\xea\x7f\x80\xd2\x1c\x82\x0c\x27\x88",
 };
 
-dh_test_vector_t ecp384 = {
-       .group = ECP_384_BIT, .priv_len = 48, .pub_len = 96, .shared_len = 48,
+ke_test_vector_t ecp384 = {
+       .method = ECP_384_BIT, .priv_len = 48, .pub_len = 96, .shared_len = 48,
        .priv_a = "\xd2\x73\x35\xea\x71\x66\x4a\xf2\x44\xdd\x14\xe9\xfd\x12\x60\x71"
                          "\x5d\xfd\x8a\x79\x65\x57\x1c\x48\xd7\x09\xee\x7a\x79\x62\xa1\x56"
                          "\xd7\x06\xa9\x0c\xbc\xb5\xdf\x29\x86\xf0\x5f\xea\xdb\x93\x76\xf1",
@@ -96,8 +96,8 @@ dh_test_vector_t ecp384 = {
                          "\x27\xaa\x8a\x45\x40\x88\x4c\x37\xde\x15\x9a\x58\x02\x8a\xbc\x0e",
 };
 
-dh_test_vector_t ecp521 = {
-       .group = ECP_521_BIT, .priv_len = 66, .pub_len = 132, .shared_len = 66,
+ke_test_vector_t ecp521 = {
+       .method = ECP_521_BIT, .priv_len = 66, .pub_len = 132, .shared_len = 66,
        .priv_a = "\x01\x13\xf8\x2d\xa8\x25\x73\x5e\x3d\x97\x27\x66\x83\xb2\xb7\x42"
                          "\x77\xba\xd2\x73\x35\xea\x71\x66\x4a\xf2\x43\x0c\xc4\xf3\x34\x59"
                          "\xb9\x66\x9e\xe7\x8b\x3f\xfb\x9b\x86\x83\x01\x5d\x34\x4d\xcb\xfe"
index de439986837780eb8c552d2be0d766d160602115..efbd20283ce51eaf4a3f54d66a62d4cbb2cefb8d 100644 (file)
@@ -19,8 +19,8 @@
  * Test vectors from RFC6923/RFC7027
  */
 
-dh_test_vector_t ecp224bp = {
-       .group = ECP_224_BP, .priv_len = 28, .pub_len = 56, .shared_len = 28,
+ke_test_vector_t ecp224bp = {
+       .method = ECP_224_BP, .priv_len = 28, .pub_len = 56, .shared_len = 28,
        .priv_a = "\x7c\x4b\x7a\x2c\x8a\x4b\xad\x1f\xbb\x7d\x79\xcc\x09\x55\xdb\x7c"
                          "\x6a\x46\x60\xca\x64\xcc\x47\x78\x15\x9b\x49\x5e",
        .priv_b = "\x63\x97\x6d\x4a\xae\x6c\xd0\xf6\xdd\x18\xde\xfe\xf5\x5d\x96\x56"
@@ -37,8 +37,8 @@ dh_test_vector_t ecp224bp = {
                          "\xdc\xcb\xe3\xb6\x5d\x0f\x96\x7d\xca\xb5\x74\xeb",
 };
 
-dh_test_vector_t ecp256bp = {
-       .group = ECP_256_BP, .priv_len = 32, .pub_len = 64, .shared_len = 32,
+ke_test_vector_t ecp256bp = {
+       .method = ECP_256_BP, .priv_len = 32, .pub_len = 64, .shared_len = 32,
        .priv_a = "\x81\xdb\x1e\xe1\x00\x15\x0f\xf2\xea\x33\x8d\x70\x82\x71\xbe\x38"
                          "\x30\x0c\xb5\x42\x41\xd7\x99\x50\xf7\x7b\x06\x30\x39\x80\x4f\x1d",
        .priv_b = "\x55\xe4\x0b\xc4\x1e\x37\xe3\xe2\xad\x25\xc3\xc6\x65\x45\x11\xff"
@@ -55,8 +55,8 @@ dh_test_vector_t ecp256bp = {
                          "\xf9\x65\x56\xec\x91\xe6\xae\x79\x39\xbc\xe3\x1f\x3a\x18\xbf\x2b",
 };
 
-dh_test_vector_t ecp384bp = {
-       .group = ECP_384_BP, .priv_len = 48, .pub_len = 96, .shared_len = 48,
+ke_test_vector_t ecp384bp = {
+       .method = ECP_384_BP, .priv_len = 48, .pub_len = 96, .shared_len = 48,
        .priv_a = "\x1e\x20\xf5\xe0\x48\xa5\x88\x6f\x1f\x15\x7c\x74\xe9\x1b\xde\x2b"
                          "\x98\xc8\xb5\x2d\x58\xe5\x00\x3d\x57\x05\x3f\xc4\xb0\xbd\x65\xd6"
                          "\xf1\x5e\xb5\xd1\xee\x16\x10\xdf\x87\x07\x95\x14\x36\x27\xd0\x42",
@@ -80,8 +80,8 @@ dh_test_vector_t ecp384bp = {
                          "\xad\xf6\x40\x37\x15\xc3\x5d\x4f\xb2\xa5\x44\x4f\x57\x5d\x4f\x42",
 };
 
-dh_test_vector_t ecp512bp = {
-       .group = ECP_512_BP, .priv_len = 64, .pub_len = 128, .shared_len = 64,
+ke_test_vector_t ecp512bp = {
+       .method = ECP_512_BP, .priv_len = 64, .pub_len = 128, .shared_len = 64,
        .priv_a = "\x16\x30\x2f\xf0\xdb\xbb\x5a\x8d\x73\x3d\xab\x71\x41\xc1\xb4\x5a"
                          "\xcb\xc8\x71\x59\x39\x67\x7f\x6a\x56\x85\x0a\x38\xbd\x87\xbd\x59"
                          "\xb0\x9e\x80\x27\x96\x09\xff\x33\x3e\xb9\xd4\xc0\x61\x23\x1f\xb2"
index 482e41c36aeb6ec99681feb18d6d87c5745a7847..cf1ea2a9bfff59a9dd46fc42d7369174b2854249 100644 (file)
@@ -20,8 +20,8 @@
  * these have been generated.
  */
 
-dh_test_vector_t modp768 = {
-       .group = MODP_768_BIT, .priv_len = 32, .pub_len = 96, .shared_len = 96,
+ke_test_vector_t modp768 = {
+       .method = MODP_768_BIT, .priv_len = 32, .pub_len = 96, .shared_len = 96,
        .priv_a = "\x60\x91\xff\xc6\xde\x28\xc1\xcc\xc7\xc6\x5d\xa6\x11\xab\xfa\xe8"
                          "\x6a\x10\x74\xb2\x22\x43\xe3\x70\x6c\xb6\xde\x2f\xe2\x9d\x11\x42",
        .priv_b = "\x76\xe0\x2f\xc3\xea\xbe\x6a\x0f\xce\xd6\xc3\x1e\x59\x45\xd1\x67"
@@ -46,8 +46,8 @@ dh_test_vector_t modp768 = {
                          "\x3d\xaa\xad\x22\xe8\x68\xb7\xe2\x50\x02\x9d\x30\x7e\xe5\x41\x48",
 };
 
-dh_test_vector_t modp1024 = {
-       .group = MODP_1024_BIT, .priv_len = 32, .pub_len = 128, .shared_len = 128,
+ke_test_vector_t modp1024 = {
+       .method = MODP_1024_BIT, .priv_len = 32, .pub_len = 128, .shared_len = 128,
        .priv_a = "\xe5\x3c\x20\x5d\xa0\xd8\xe4\xbf\xb4\x17\x49\x44\x32\x0f\xc6\xe4"
                          "\xea\x66\xfe\x44\xe3\xc9\x31\xac\x5d\xa1\x45\x0a\xea\x47\xeb\xcf",
        .priv_b = "\x7f\x9a\xf7\x21\xeb\x7c\xd2\xa9\x00\xa3\x6e\x39\x9e\xbc\x5c\x65"
@@ -78,8 +78,8 @@ dh_test_vector_t modp1024 = {
                          "\x48\x02\xd7\x4a\x4f\x75\x3b\x29\x4a\x96\x50\x3f\x26\x05\xd3\xf1",
 };
 
-dh_test_vector_t modp1536 = {
-       .group = MODP_1536_BIT, .priv_len = 32, .pub_len = 192, .shared_len = 192,
+ke_test_vector_t modp1536 = {
+       .method = MODP_1536_BIT, .priv_len = 32, .pub_len = 192, .shared_len = 192,
        .priv_a = "\x22\xd9\xdc\xc7\x30\x79\x93\x6a\x85\x8c\x07\xaa\x85\xed\x07\xb3"
                          "\xd1\xe8\xb6\x70\xe7\xca\xaf\xa1\x92\x83\x76\x96\x07\x0f\xef\x29",
        .priv_b = "\x32\x34\x74\xde\x77\x88\xe0\x03\x6b\x30\x95\x49\x56\x0b\x00\x0d"
@@ -122,8 +122,8 @@ dh_test_vector_t modp1536 = {
                          "\x38\x1b\x1e\x5b\x7a\xa5\xd0\x9a\xb6\x6b\x74\x99\x7c\xba\xed\x20",
 };
 
-dh_test_vector_t modp2048 = {
-       .group = MODP_2048_BIT, .priv_len = 48, .pub_len = 256, .shared_len = 256,
+ke_test_vector_t modp2048 = {
+       .method = MODP_2048_BIT, .priv_len = 48, .pub_len = 256, .shared_len = 256,
        .priv_a = "\xaf\x3b\xfd\x38\x62\xca\xa1\x17\x74\xce\x2b\x74\x84\x08\x07\xc1"
                          "\xde\x5c\xd6\xa7\x61\x9b\xb3\xa0\xc7\xaf\x39\xee\xda\xa6\xeb\x89"
                          "\xe2\xe9\xc1\x44\xb3\x62\x5b\x27\x31\x87\x9c\xb5\x8f\xa3\x76\x6d",
@@ -180,8 +180,8 @@ dh_test_vector_t modp2048 = {
                          "\xee\x9c\x12\x15\xdd\x23\x93\xde\x02\xf5\xc1\x76\x7f\x07\x0e\x28",
 };
 
-dh_test_vector_t modp3072 = {
-       .group = MODP_3072_BIT, .priv_len = 48, .pub_len = 384, .shared_len = 384,
+ke_test_vector_t modp3072 = {
+       .method = MODP_3072_BIT, .priv_len = 48, .pub_len = 384, .shared_len = 384,
        .priv_a = "\x51\xf8\xaa\xb6\x63\x20\x1e\xb2\x86\xba\xd2\x99\x32\xb2\xe5\x8a"
                          "\x92\x96\xbf\x2a\xa7\x78\x79\xcc\x8c\x64\x29\xd5\xa6\x68\xad\xf7"
                          "\x60\x57\xad\xc3\x77\xcc\x75\xfd\x86\x47\x96\xb8\xfa\x7b\x42\x8c",
@@ -262,8 +262,8 @@ dh_test_vector_t modp3072 = {
                          "\xdc\x87\x87\x5b\xe5\x88\xc0\xcd\xee\xee\xfd\x19\xcc\x4f\x1d\x40",
 };
 
-dh_test_vector_t modp4096 = {
-       .group = MODP_4096_BIT, .priv_len = 64, .pub_len = 512, .shared_len = 512,
+ke_test_vector_t modp4096 = {
+       .method = MODP_4096_BIT, .priv_len = 64, .pub_len = 512, .shared_len = 512,
        .priv_a = "\xab\x69\xbc\xe9\x61\xf9\x8a\xa9\xd5\x91\xe3\xfd\x9a\xbc\x46\xc8"
                          "\x0d\xde\x39\x02\x84\xf1\x91\x42\xe8\x81\x5a\xb0\x80\x54\x72\x2b"
                          "\xbd\x2e\x14\x1e\x27\x9e\xc7\xfd\x30\xaa\xfa\xca\x66\x40\x93\x73"
@@ -370,8 +370,8 @@ dh_test_vector_t modp4096 = {
                          "\x4f\xb9\x39\x02\x12\xb9\xb2\xa3\x5d\x4a\xfa\x17\xb3\xee\xc0\x8a",
 };
 
-dh_test_vector_t modp6144 = {
-       .group = MODP_6144_BIT, .priv_len = 64, .pub_len = 768, .shared_len = 768,
+ke_test_vector_t modp6144 = {
+       .method = MODP_6144_BIT, .priv_len = 64, .pub_len = 768, .shared_len = 768,
        .priv_a = "\xab\x36\xf0\x65\x7c\x4f\xba\xdc\x2a\x3b\x07\xed\xd1\xc8\xaf\xcb"
                          "\x42\xaf\xcd\x7f\xf9\x1c\x57\x01\x37\x25\x50\x0d\x89\x42\x9f\x34"
                          "\x79\x8f\x99\xf5\xde\x53\xd1\x08\x8f\xd9\xf6\x60\xa1\xa5\x2b\xe4"
@@ -526,8 +526,8 @@ dh_test_vector_t modp6144 = {
                          "\xb8\xd0\xeb\x41\xb6\x7c\xfb\x9d\x9d\xfd\x62\x0e\xb7\x99\xca\x17",
 };
 
-dh_test_vector_t modp8192 = {
-       .group = MODP_8192_BIT, .priv_len = 64, .pub_len = 1024, .shared_len = 1024,
+ke_test_vector_t modp8192 = {
+       .method = MODP_8192_BIT, .priv_len = 64, .pub_len = 1024, .shared_len = 1024,
        .priv_a = "\xa6\x48\x81\x47\x45\xfe\x1e\xd1\x98\x9b\x75\xba\x6d\xd5\x01\xe4"
                          "\x4e\x77\x6d\xc9\x97\xa0\xae\x27\x37\x64\x61\xb0\xee\x79\x65\x94"
                          "\xc2\xe6\xdb\x07\xe5\xf9\xd8\x7d\x94\x4d\x37\x01\x22\x38\xe5\x70"
index bb64e2df9a36fcc944de1455f151dda172014165..31cf5614d62d405473f80799af0695cd317dd7bd 100644 (file)
@@ -19,8 +19,8 @@
  * Test vectors from RFC5114
  */
 
-dh_test_vector_t modp1024_160 = {
-       .group = MODP_1024_160, .priv_len = 20, .pub_len = 128, .shared_len = 128,
+ke_test_vector_t modp1024_160 = {
+       .method = MODP_1024_160, .priv_len = 20, .pub_len = 128, .shared_len = 128,
        .priv_a = "\xB9\xA3\xB3\xAE\x8F\xEF\xC1\xA2\x93\x04\x96\x50\x70\x86\xF8\x45"
                          "\x5D\x48\x94\x3E",
        .priv_b = "\x93\x92\xC9\xF9\xEB\x6A\x7A\x6A\x90\x22\xF7\xD8\x3E\x72\x23\xC6"
@@ -51,8 +51,8 @@ dh_test_vector_t modp1024_160 = {
                          "\x16\x7E\xCD\x91\x55\x41\x6F\x46\xF4\x08\xED\x31\xB6\x3C\x6E\x6D",
 };
 
-dh_test_vector_t modp2048_224 = {
-       .group = MODP_2048_224, .priv_len = 28, .pub_len = 256, .shared_len = 256,
+ke_test_vector_t modp2048_224 = {
+       .method = MODP_2048_224, .priv_len = 28, .pub_len = 256, .shared_len = 256,
        .priv_a = "\x22\xe6\x26\x01\xdb\xff\xd0\x67\x08\xa6\x80\xf7\x47\xf3\x61\xf7"
                          "\x6d\x8f\x4f\x72\x1a\x05\x48\xe4\x83\x29\x4b\x0c",
        .priv_b = "\x4f\xf3\xbc\x96\xc7\xfc\x6a\x6d\x71\xd3\xb3\x63\x80\x0a\x7c\xdf"
@@ -107,8 +107,8 @@ dh_test_vector_t modp2048_224 = {
                          "\x7f\xcb\x51\x0b\x69\x98\xff\xd3\xaa\x6d\xe7\x3c\xf9\xf6\x38\x69",
 };
 
-dh_test_vector_t modp2048_256 = {
-       .group = MODP_2048_256, .priv_len = 32, .pub_len = 256, .shared_len = 256,
+ke_test_vector_t modp2048_256 = {
+       .method = MODP_2048_256, .priv_len = 32, .pub_len = 256, .shared_len = 256,
        .priv_a = "\x08\x81\x38\x2c\xdb\x87\x66\x0c\x6d\xc1\x3e\x61\x49\x38\xd5\xb9"
                          "\xc8\xb2\xf2\x48\x58\x1c\xc5\xe3\x1b\x35\x45\x43\x97\xfc\xe5\x0e",
        .priv_b = "\x7d\x62\xa7\xe3\xef\x36\xde\x61\x7b\x13\xd1\xaf\xb8\x2c\x78\x0d"
index 7b11b19aa58d1922b2980b24e84047f45d53ad82..cf5e6e6182320885571c45214a4809f79d0b8039 100644 (file)
@@ -27,7 +27,7 @@
 #define TEST_VECTOR_XOF(x) extern xof_test_vector_t x;
 #define TEST_VECTOR_DRBG(x) extern drbg_test_vector_t x;
 #define TEST_VECTOR_RNG(x) extern rng_test_vector_t x;
-#define TEST_VECTOR_DH(x) extern dh_test_vector_t x;
+#define TEST_VECTOR_KE(x) extern ke_test_vector_t x;
 
 #include "test_vectors.h"
 
@@ -39,7 +39,7 @@
 #undef TEST_VECTOR_XOF
 #undef TEST_VECTOR_DRBG
 #undef TEST_VECTOR_RNG
-#undef TEST_VECTOR_DH
+#undef TEST_VECTOR_KE
 
 #define TEST_VECTOR_CRYPTER(x)
 #define TEST_VECTOR_AEAD(x)
@@ -49,7 +49,7 @@
 #define TEST_VECTOR_XOF(x)
 #define TEST_VECTOR_DRBG(x)
 #define TEST_VECTOR_RNG(x)
-#define TEST_VECTOR_DH(x)
+#define TEST_VECTOR_KE(x)
 
 /* create test vector arrays */
 #undef TEST_VECTOR_CRYPTER
@@ -116,13 +116,13 @@ static rng_test_vector_t *rng[] = {
 #undef TEST_VECTOR_RNG
 #define TEST_VECTOR_RNG(x)
 
-#undef TEST_VECTOR_DH
-#define TEST_VECTOR_DH(x) &x,
-static dh_test_vector_t *dh[] = {
+#undef TEST_VECTOR_KE
+#define TEST_VECTOR_KE(x) &x,
+static ke_test_vector_t *ke[] = {
 #include "test_vectors.h"
 };
-#undef TEST_VECTOR_DH
-#define TEST_VECTOR_DH(x)
+#undef TEST_VECTOR_KE
+#define TEST_VECTOR_KE(x)
 
 typedef struct private_test_vectors_plugin_t private_test_vectors_plugin_t;
 
@@ -218,10 +218,10 @@ plugin_t *test_vectors_plugin_create()
                lib->crypto->add_test_vector(lib->crypto,
                                                                         RANDOM_NUMBER_GENERATOR, rng[i]);
        }
-       for (i = 0; i < countof(dh); i++)
+       for (i = 0; i < countof(ke); i++)
        {
                lib->crypto->add_test_vector(lib->crypto,
-                                                                        DIFFIE_HELLMAN_GROUP, dh[i]);
+                                                                        KEY_EXCHANGE_METHOD, ke[i]);
        }
 
        return &this->public.plugin;
index 6fefe523d5a787d5e2c7471378235e28abcf9ea7..9856e8d40d925ded53039a512fd0085bf6182d35 100644 (file)
@@ -44,12 +44,12 @@ struct private_wolfssl_diffie_hellman_t {
        wolfssl_diffie_hellman_t public;
 
        /**
-        * Diffie Hellman group number.
+        * Diffie-Hellman group number.
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        /**
-        * Diffie Hellman object
+        * Diffie-Hellman object
         */
        DhKey dh;
 
@@ -74,14 +74,14 @@ struct private_wolfssl_diffie_hellman_t {
        chunk_t shared_secret;
 };
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_wolfssl_diffie_hellman_t *this, chunk_t *value)
 {
        *value = chunk_copy_pad(chunk_alloc(this->len), this->pub, 0x00);
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_wolfssl_diffie_hellman_t *this, chunk_t *secret)
 {
        if (!this->shared_secret.len)
@@ -92,12 +92,12 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_wolfssl_diffie_hellman_t *this, chunk_t value)
 {
        word32 len;
 
-       if (!diffie_hellman_verify_value(this->group, value))
+       if (!key_exchange_verify_pubkey(this->group, value))
        {
                return FALSE;
        }
@@ -115,7 +115,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_private_value, bool,
+METHOD(key_exchange_t, set_private_key, bool,
        private_wolfssl_diffie_hellman_t *this, chunk_t value)
 {
        bool success = FALSE;
@@ -141,13 +141,13 @@ METHOD(diffie_hellman_t, set_private_value, bool,
        return success;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_wolfssl_diffie_hellman_t *this)
 {
        return this->group;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_wolfssl_diffie_hellman_t *this)
 {
        wc_FreeDhKey(&this->dh);
@@ -200,7 +200,7 @@ static int wolfssl_priv_key_size(int len)
 /**
  * Generic internal constructor
  */
-static wolfssl_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
+static wolfssl_diffie_hellman_t *create_generic(key_exchange_method_t group,
                                                                                                chunk_t g, chunk_t p)
 {
        private_wolfssl_diffie_hellman_t *this;
@@ -209,12 +209,12 @@ static wolfssl_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
 
        INIT(this,
                .public = {
-                       .dh = {
+                       .ke = {
                                .get_shared_secret = _get_shared_secret,
-                               .set_other_public_value = _set_other_public_value,
-                               .get_my_public_value = _get_my_public_value,
-                               .set_private_value = _set_private_value,
-                               .get_dh_group = _get_dh_group,
+                               .set_public_key = _set_public_key,
+                               .get_public_key = _get_public_key,
+                               .set_private_key = _set_private_key,
+                               .get_method = _get_method,
                                .destroy = _destroy,
                        },
                },
@@ -263,7 +263,7 @@ static wolfssl_diffie_hellman_t *create_generic(diffie_hellman_group_t group,
  * Described in header
  */
 wolfssl_diffie_hellman_t *wolfssl_diffie_hellman_create(
-                                                                                       diffie_hellman_group_t group, ...)
+                                                                                       key_exchange_method_t group, ...)
 {
        diffie_hellman_params_t *params;
        chunk_t g, p;
index 2f286ca42096901712ee0852ecbe743da4bd3154..4d580561318d4d35d8eb053e1e2fa9b23bfb5cac 100644 (file)
@@ -38,20 +38,20 @@ typedef struct wolfssl_diffie_hellman_t wolfssl_diffie_hellman_t;
 struct wolfssl_diffie_hellman_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 };
 
 /**
  * Creates a new wolfssl_diffie_hellman_t object.
  *
- * @param group                        Diffie Hellman group number to use
+ * @param group                        Diffie-Hellman group number to use
  * @param ...                  expects generator and prime as chunk_t if MODP_CUSTOM
  * @return                             wolfssl_diffie_hellman_t object, NULL if not supported
  */
 wolfssl_diffie_hellman_t *wolfssl_diffie_hellman_create(
-                                                                                       diffie_hellman_group_t group, ...);
+                                                                                       key_exchange_method_t group, ...);
 
 #endif /** WOLFSSL_PLUGIN_DIFFIE_HELLMAN_H_ @}*/
 
index ceff4172c14ab5bcd669c737b9bd2ac88d322541..6bdafdfcbdb163e4bf447c2d60003945a7d83993 100644 (file)
@@ -45,7 +45,7 @@ struct private_wolfssl_ec_diffie_hellman_t {
        /**
         * Diffie Hellman group number.
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        /**
         * EC curve id for creating keys
@@ -178,12 +178,12 @@ static bool compute_shared_key(private_wolfssl_ec_diffie_hellman_t *this,
        return success;
 }
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_wolfssl_ec_diffie_hellman_t *this, chunk_t value)
 {
        ecc_point *pub_key;
 
-       if (!diffie_hellman_verify_value(this->group, value))
+       if (!key_exchange_verify_pubkey(this->group, value))
        {
                return FALSE;
        }
@@ -213,13 +213,13 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_wolfssl_ec_diffie_hellman_t *this,chunk_t *value)
 {
        return ecp2chunk(this->keysize, &this->key.pubkey, value, FALSE);
 }
 
-METHOD(diffie_hellman_t, set_private_value, bool,
+METHOD(key_exchange_t, set_private_key, bool,
        private_wolfssl_ec_diffie_hellman_t *this, chunk_t value)
 {
        bool success = FALSE;
@@ -257,7 +257,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
        return success;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_wolfssl_ec_diffie_hellman_t *this, chunk_t *secret)
 {
        if (!this->shared_secret.len)
@@ -268,13 +268,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_wolfssl_ec_diffie_hellman_t *this)
 {
        return this->group;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_wolfssl_ec_diffie_hellman_t *this)
 {
        wc_ecc_free(&this->key);
@@ -285,19 +285,19 @@ METHOD(diffie_hellman_t, destroy, void,
 /*
  * Described in header
  */
-wolfssl_ec_diffie_hellman_t *wolfssl_ec_diffie_hellman_create(diffie_hellman_group_t group)
+wolfssl_ec_diffie_hellman_t *wolfssl_ec_diffie_hellman_create(key_exchange_method_t group)
 {
        private_wolfssl_ec_diffie_hellman_t *this;
        WC_RNG rng;
 
        INIT(this,
                .public = {
-                       .dh = {
+                       .ke = {
                                .get_shared_secret = _get_shared_secret,
-                               .set_other_public_value = _set_other_public_value,
-                               .get_my_public_value = _get_my_public_value,
-                               .set_private_value = _set_private_value,
-                               .get_dh_group = _get_dh_group,
+                               .set_public_key = _set_public_key,
+                               .get_public_key = _get_public_key,
+                               .set_private_key = _set_private_key,
+                               .get_method = _get_method,
                                .destroy = _destroy,
                        },
                },
index d36f83f060c7ed9fc360f9e43e001364e335d97f..5864e22c851095696aa741514a4e534ffc4eed36 100644 (file)
@@ -38,19 +38,19 @@ typedef struct wolfssl_ec_diffie_hellman_t wolfssl_ec_diffie_hellman_t;
 struct wolfssl_ec_diffie_hellman_t {
 
        /**
-        * Implements diffie_hellman_t interface.
+        * Implements key_exchange_t interface.
         */
-       diffie_hellman_t dh;
+       key_exchange_t ke;
 };
 
 /**
  * Creates a new wolfssl_ec_diffie_hellman_t object.
  *
- * @param group                        EC Diffie Hellman group number to use
+ * @param group                        EC Diffie-Hellman group number to use
  * @return                             wolfssl_ec_diffie_hellman_t object, NULL if not
  *                                             supported
  */
 wolfssl_ec_diffie_hellman_t *wolfssl_ec_diffie_hellman_create(
-                                                                                               diffie_hellman_group_t group);
+                                                                                               key_exchange_method_t group);
 
 #endif /** WOLFSSL_PLUGIN_EC_DIFFIE_HELLMAN_H_ @}*/
index 925f08ee37c792c9275b1b8d4b5e533ba7023bf7..f731c6f269ec8b810a01cbe71e0e42298c26b360 100644 (file)
@@ -193,68 +193,68 @@ METHOD(plugin_t, get_features, int,
 #endif
 #ifdef HAVE_ECC_DHE
                /* EC DH groups */
-               PLUGIN_REGISTER(DH, wolfssl_ec_diffie_hellman_create),
+               PLUGIN_REGISTER(KE, wolfssl_ec_diffie_hellman_create),
        #if !defined(NO_ECC256) || defined(HAVE_ALL_CURVES)
-                       PLUGIN_PROVIDE(DH, ECP_256_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_256_BIT),
        #endif
        #if defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)
-                       PLUGIN_PROVIDE(DH, ECP_384_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_384_BIT),
        #endif
        #if defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)
-                       PLUGIN_PROVIDE(DH, ECP_521_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_521_BIT),
        #endif
        #if defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES)
-                       PLUGIN_PROVIDE(DH, ECP_224_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_224_BIT),
        #endif
        #if defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)
-                       PLUGIN_PROVIDE(DH, ECP_192_BIT),
+                       PLUGIN_PROVIDE(KE, ECP_192_BIT),
        #endif
        #ifdef HAVE_BRAINPOOL
                #if !define(NO_ECC256) || defined(HAVE_ALL_CURVES)
-                       PLUGIN_PROVIDE(DH, ECP_256_BP),
+                       PLUGIN_PROVIDE(KE, ECP_256_BP),
                #endif
                #if defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)
-                       PLUGIN_PROVIDE(DH, ECP_384_BP),
+                       PLUGIN_PROVIDE(KE, ECP_384_BP),
                #endif
                #if defined(HAVE_ECC512) || defined(HAVE_ALL_CURVES)
-                       PLUGIN_PROVIDE(DH, ECP_512_BP),
+                       PLUGIN_PROVIDE(KE, ECP_512_BP),
                #endif
                #if defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES)
-                       PLUGIN_PROVIDE(DH, ECP_224_BP),
+                       PLUGIN_PROVIDE(KE, ECP_224_BP),
                #endif
        #endif
 #endif /* HAVE_ECC_DHE */
 #ifndef NO_DH
                /* MODP DH groups */
-               PLUGIN_REGISTER(DH, wolfssl_diffie_hellman_create),
+               PLUGIN_REGISTER(KE, wolfssl_diffie_hellman_create),
        #if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (3072 * 2)
-                       PLUGIN_PROVIDE(DH, MODP_3072_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_3072_BIT),
        #endif
        #if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (4096 * 2)
-                       PLUGIN_PROVIDE(DH, MODP_4096_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_4096_BIT),
        #endif
        #if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (6144 * 2)
-                       PLUGIN_PROVIDE(DH, MODP_6144_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_6144_BIT),
        #endif
        #if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (8192 * 2)
-                       PLUGIN_PROVIDE(DH, MODP_8192_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_8192_BIT),
        #endif
        #if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (2048 * 2)
-                       PLUGIN_PROVIDE(DH, MODP_2048_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_2048_224),
-                       PLUGIN_PROVIDE(DH, MODP_2048_256),
+                       PLUGIN_PROVIDE(KE, MODP_2048_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_2048_224),
+                       PLUGIN_PROVIDE(KE, MODP_2048_256),
        #endif
        #if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (1536 * 2)
-                       PLUGIN_PROVIDE(DH, MODP_1536_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_1536_BIT),
        #endif
        #if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (1024 * 2)
-                       PLUGIN_PROVIDE(DH, MODP_1024_BIT),
-                       PLUGIN_PROVIDE(DH, MODP_1024_160),
+                       PLUGIN_PROVIDE(KE, MODP_1024_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_1024_160),
        #endif
        #if !defined(USE_FAST_MATH) || FP_MAX_BITS >= (768 * 2)
-                       PLUGIN_PROVIDE(DH, MODP_768_BIT),
+                       PLUGIN_PROVIDE(KE, MODP_768_BIT),
        #endif
-                       PLUGIN_PROVIDE(DH, MODP_CUSTOM),
+                       PLUGIN_PROVIDE(KE, MODP_CUSTOM),
 #endif /* NO_DH */
 #ifndef NO_RSA
                /* RSA private/public key loading */
@@ -378,8 +378,8 @@ METHOD(plugin_t, get_features, int,
        #endif /* HAVE_ECC_VERIFY */
 #endif /* HAVE_ECC */
 #ifdef HAVE_CURVE25519
-               PLUGIN_REGISTER(DH, wolfssl_x_diffie_hellman_create),
-                       PLUGIN_PROVIDE(DH, CURVE_25519),
+               PLUGIN_REGISTER(KE, wolfssl_x_diffie_hellman_create),
+                       PLUGIN_PROVIDE(KE, CURVE_25519),
 #endif
 #ifdef HAVE_ED25519
                /* EdDSA private/public key loading */
index 5c21eb66c22837a1880e2269f6137f31113ca307..24c2c8fc4b7b09e21613e3ad0f1f58e3b71838a3 100644 (file)
@@ -37,15 +37,16 @@ typedef struct private_diffie_hellman_t private_diffie_hellman_t;
  * Private data
  */
 struct private_diffie_hellman_t {
+
        /**
         * Public interface.
         */
-       diffie_hellman_t public;
+       key_exchange_t public;
 
        /**
         * Diffie Hellman group number.
         */
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        /**
         * Private (public) key
@@ -73,13 +74,13 @@ static bool compute_shared_key(private_diffie_hellman_t *this,
        return ret == 0;
 }
 
-METHOD(diffie_hellman_t, set_other_public_value, bool,
+METHOD(key_exchange_t, set_public_key, bool,
        private_diffie_hellman_t *this, chunk_t value)
 {
        curve25519_key pub;
        int ret;
 
-       if (!diffie_hellman_verify_value(this->group, value))
+       if (!key_exchange_verify_pubkey(this->group, value))
        {
                return FALSE;
        }
@@ -88,7 +89,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        if (ret != 0)
        {
                DBG1(DBG_LIB, "%N public key initialization failed",
-                        diffie_hellman_group_names, this->group);
+                        key_exchange_method_names, this->group);
                return FALSE;
        }
 
@@ -97,7 +98,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        if (ret != 0)
        {
                DBG1(DBG_LIB, "%N public value is malformed",
-                        diffie_hellman_group_names, this->group);
+                        key_exchange_method_names, this->group);
                return FALSE;
        }
 
@@ -106,7 +107,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        if (!compute_shared_key(this, &pub, &this->shared_secret))
        {
                DBG1(DBG_LIB, "%N shared secret computation failed",
-                        diffie_hellman_group_names, this->group);
+                        key_exchange_method_names, this->group);
                chunk_clear(&this->shared_secret);
                wc_curve25519_free(&pub);
                return FALSE;
@@ -115,7 +116,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_my_public_value, bool,
+METHOD(key_exchange_t, get_public_key, bool,
        private_diffie_hellman_t *this, chunk_t *value)
 {
        word32 len = CURVE25519_KEYSIZE;
@@ -130,7 +131,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, set_private_value, bool,
+METHOD(key_exchange_t, set_private_key, bool,
        private_diffie_hellman_t *this, chunk_t value)
 {
        curve25519_key pub;
@@ -158,7 +159,7 @@ METHOD(diffie_hellman_t, set_private_value, bool,
        return ret == 0;
 }
 
-METHOD(diffie_hellman_t, get_shared_secret, bool,
+METHOD(key_exchange_t, get_shared_secret, bool,
        private_diffie_hellman_t *this, chunk_t *secret)
 {
        if (!this->shared_secret.len)
@@ -169,13 +170,13 @@ METHOD(diffie_hellman_t, get_shared_secret, bool,
        return TRUE;
 }
 
-METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+METHOD(key_exchange_t, get_method, key_exchange_method_t,
        private_diffie_hellman_t *this)
 {
        return this->group;
 }
 
-METHOD(diffie_hellman_t, destroy, void,
+METHOD(key_exchange_t, destroy, void,
        private_diffie_hellman_t *this)
 {
        wc_curve25519_free(&this->key);
@@ -186,7 +187,7 @@ METHOD(diffie_hellman_t, destroy, void,
 /*
  * Described in header
  */
-diffie_hellman_t *wolfssl_x_diffie_hellman_create(diffie_hellman_group_t group)
+key_exchange_t *wolfssl_x_diffie_hellman_create(key_exchange_method_t group)
 {
        private_diffie_hellman_t *this;
        WC_RNG rng;
@@ -195,10 +196,10 @@ diffie_hellman_t *wolfssl_x_diffie_hellman_create(diffie_hellman_group_t group)
        INIT(this,
                .public = {
                        .get_shared_secret = _get_shared_secret,
-                       .set_other_public_value = _set_other_public_value,
-                       .get_my_public_value = _get_my_public_value,
-                       .set_private_value = _set_private_value,
-                       .get_dh_group = _get_dh_group,
+                       .set_public_key = _set_public_key,
+                       .get_public_key = _get_public_key,
+                       .set_private_key = _set_private_key,
+                       .get_method = _get_method,
                        .destroy = _destroy,
                },
                .group = group,
index 56760e5d2cfbd363e556dd15978b087c112bd04b..8ddb532e3c86c18538cf1e191ff36101be3c503b 100644 (file)
 #include <library.h>
 
 /**
- * Creates a new diffie_hellman_t object.
+ * Creates a new key_exchange_t object.
  *
- * @param group                        Diffie Hellman group number to use
+ * @param group                        Diffie-Hellman group number to use
  * @return                             object, NULL if not supported
  */
-diffie_hellman_t *wolfssl_x_diffie_hellman_create(diffie_hellman_group_t group);
+key_exchange_t *wolfssl_x_diffie_hellman_create(key_exchange_method_t group);
 
 #endif /** WOLFSSL_PLUGIN_X_DIFFIE_HELLMAN_H_ @}*/
index f0c851f5737ee714b85a91539874f181bfdb8a1b..7180ee37bb6a29e3c9f8aab6b3fc000917837ec2 100644 (file)
@@ -140,93 +140,93 @@ START_TEST(test_create_rng)
 }
 END_TEST
 
-static diffie_hellman_t *dh_create(char *plugin)
+static key_exchange_t *ke_create(char *plugin)
 {
-       return (diffie_hellman_t*)plugin;
+       return (key_exchange_t*)plugin;
 }
 
-static diffie_hellman_t *dh_create_modp1024(diffie_hellman_group_t group, ...)
+static key_exchange_t *ke_create_modp1024(key_exchange_method_t group, ...)
 {
        ck_assert(group == MODP_1024_BIT);
-       return dh_create("plugin1");
+       return ke_create("plugin1");
 }
 
-static diffie_hellman_t *dh_create_modp1024_second(diffie_hellman_group_t group,
-                                                                                                  ...)
+static key_exchange_t *ke_create_modp1024_second(key_exchange_method_t group,
+                                                                                                ...)
 {
        ck_assert(group == MODP_1024_BIT);
-       return dh_create("plugin2");
+       return ke_create("plugin2");
 }
 
-static diffie_hellman_t *dh_create_modp2048(diffie_hellman_group_t group, ...)
+static key_exchange_t *ke_create_modp2048(key_exchange_method_t group, ...)
 {
        ck_assert(group == MODP_2048_BIT);
-       return dh_create("plugin1");
+       return ke_create("plugin1");
 }
 
-static diffie_hellman_t *dh_create_modp2048_second(diffie_hellman_group_t group,
-                                                                                                  ...)
+static key_exchange_t *ke_create_modp2048_second(key_exchange_method_t group,
+                                                                                                ...)
 {
        ck_assert(group == MODP_2048_BIT);
-       return dh_create("plugin2");
+       return ke_create("plugin2");
 }
 
 static struct {
        char *exp1024;
        char *exp2048;
        struct {
-               diffie_hellman_group_t g;
-               dh_constructor_t create;
+               key_exchange_method_t ke;
+               ke_constructor_t create;
                char *plugin;
        } data[4];
-} dh_data[] = {
+} ke_data[] = {
        { NULL, NULL, {
                { MODP_NONE, NULL, NULL }
        }},
        { "plugin1", NULL, {
-               { MODP_1024_BIT, dh_create_modp1024, "plugin1" },
+               { MODP_1024_BIT, ke_create_modp1024, "plugin1" },
                { MODP_NONE, NULL, NULL }
        }},
        { "plugin1", NULL, {
-               { MODP_1024_BIT, dh_create_modp1024, "plugin1" },
-               { MODP_1024_BIT, dh_create_modp1024_second, "plugin2" },
+               { MODP_1024_BIT, ke_create_modp1024, "plugin1" },
+               { MODP_1024_BIT, ke_create_modp1024_second, "plugin2" },
                { MODP_NONE, NULL, NULL }
        }},
        { "plugin2", NULL, {
-               { MODP_1024_BIT, dh_create_modp1024_second, "plugin2" },
-               { MODP_1024_BIT, dh_create_modp1024, "plugin1" },
+               { MODP_1024_BIT, ke_create_modp1024_second, "plugin2" },
+               { MODP_1024_BIT, ke_create_modp1024, "plugin1" },
                { MODP_NONE, NULL, NULL }
        }},
        { "plugin1", "plugin1", {
-               { MODP_1024_BIT, dh_create_modp1024, "plugin1" },
-               { MODP_2048_BIT, dh_create_modp2048, "plugin1" },
+               { MODP_1024_BIT, ke_create_modp1024, "plugin1" },
+               { MODP_2048_BIT, ke_create_modp2048, "plugin1" },
                { MODP_NONE, NULL }
        }},
        { "plugin1", "plugin1", {
-               { MODP_2048_BIT, dh_create_modp2048, "plugin1" },
-               { MODP_1024_BIT, dh_create_modp1024, "plugin1" },
+               { MODP_2048_BIT, ke_create_modp2048, "plugin1" },
+               { MODP_1024_BIT, ke_create_modp1024, "plugin1" },
                { MODP_NONE, NULL }
        }},
        { "plugin1", "plugin1", {
-               { MODP_2048_BIT, dh_create_modp2048, "plugin1" },
-               { MODP_2048_BIT, dh_create_modp2048_second, "plugin2" },
-               { MODP_1024_BIT, dh_create_modp1024, "plugin1" },
+               { MODP_2048_BIT, ke_create_modp2048, "plugin1" },
+               { MODP_2048_BIT, ke_create_modp2048_second, "plugin2" },
+               { MODP_1024_BIT, ke_create_modp1024, "plugin1" },
                { MODP_NONE, NULL }
        }},
        { "plugin1", "plugin2", {
-               { MODP_2048_BIT, dh_create_modp2048_second, "plugin2" },
-               { MODP_2048_BIT, dh_create_modp2048, "plugin1" },
-               { MODP_1024_BIT, dh_create_modp1024, "plugin1" },
+               { MODP_2048_BIT, ke_create_modp2048_second, "plugin2" },
+               { MODP_2048_BIT, ke_create_modp2048, "plugin1" },
+               { MODP_1024_BIT, ke_create_modp1024, "plugin1" },
                { MODP_NONE, NULL }
        }},
 };
 
-static void verify_dh(crypto_factory_t *factory, diffie_hellman_group_t request,
+static void verify_ke(crypto_factory_t *factory, key_exchange_method_t request,
                                          char *expected)
 {
        char *plugin;
 
-       plugin = (char*)factory->create_dh(factory, request);
+       plugin = (char*)factory->create_ke(factory, request);
        if (!expected)
        {
                ck_assert(!plugin);
@@ -238,56 +238,56 @@ static void verify_dh(crypto_factory_t *factory, diffie_hellman_group_t request,
        }
 }
 
-START_TEST(test_create_dh)
+START_TEST(test_create_ke)
 {
        enumerator_t *enumerator;
        crypto_factory_t *factory;
-       diffie_hellman_group_t group;
+       key_exchange_method_t ke;
        char *plugin;
        int i, len = 0;
 
 
        factory = crypto_factory_create();
-       for (i = 0; dh_data[_i].data[i].g != MODP_NONE; i++)
+       for (i = 0; ke_data[_i].data[i].ke != MODP_NONE; i++)
        {
-               ck_assert(factory->add_dh(factory, dh_data[_i].data[i].g,
-                                                                 dh_data[_i].data[i].plugin,
-                                                                 dh_data[_i].data[i].create));
+               ck_assert(factory->add_ke(factory, ke_data[_i].data[i].ke,
+                                                                 ke_data[_i].data[i].plugin,
+                                                                 ke_data[_i].data[i].create));
        }
-       verify_dh(factory, MODP_1024_BIT, dh_data[_i].exp1024);
-       verify_dh(factory, MODP_2048_BIT, dh_data[_i].exp2048);
+       verify_ke(factory, MODP_1024_BIT, ke_data[_i].exp1024);
+       verify_ke(factory, MODP_2048_BIT, ke_data[_i].exp2048);
 
-       len = countof(dh_data[_i].data);
-       enumerator = factory->create_dh_enumerator(factory);
-       for (i = 0; enumerator->enumerate(enumerator, &group, &plugin) && i < len;)
+       len = countof(ke_data[_i].data);
+       enumerator = factory->create_ke_enumerator(factory);
+       for (i = 0; enumerator->enumerate(enumerator, &ke, &plugin) && i < len;)
        {
-               ck_assert_int_eq(dh_data[_i].data[i].g, group);
-               while (dh_data[_i].data[i].g == group)
-               {       /* skip other entries by the same group */
+               ck_assert_int_eq(ke_data[_i].data[i].ke, ke);
+               while (ke_data[_i].data[i].ke == ke)
+               {       /* skip other entries of the same method */
                        i++;
                }
-               switch (group)
+               switch (ke)
                {
                        case MODP_1024_BIT:
-                               ck_assert(dh_data[_i].exp1024);
-                               ck_assert_str_eq(dh_data[_i].exp1024, plugin);
+                               ck_assert(ke_data[_i].exp1024);
+                               ck_assert_str_eq(ke_data[_i].exp1024, plugin);
                                break;
                        case MODP_2048_BIT:
-                               ck_assert(dh_data[_i].exp2048);
-                               ck_assert_str_eq(dh_data[_i].exp2048, plugin);
+                               ck_assert(ke_data[_i].exp2048);
+                               ck_assert_str_eq(ke_data[_i].exp2048, plugin);
                                break;
                        default:
-                               fail("unexpected DH group");
+                               fail("unexpected key exchange method");
                                break;
                }
        }
        ck_assert(!enumerator->enumerate(enumerator));
-       ck_assert_int_eq(dh_data[_i].data[i].g, MODP_NONE);
+       ck_assert_int_eq(ke_data[_i].data[i].ke, MODP_NONE);
        enumerator->destroy(enumerator);
 
-       for (i = 0; dh_data[_i].data[i].g != MODP_NONE; i++)
+       for (i = 0; ke_data[_i].data[i].ke != MODP_NONE; i++)
        {
-               factory->remove_dh(factory, dh_data[_i].data[i].create);
+               factory->remove_ke(factory, ke_data[_i].data[i].create);
        }
        factory->destroy(factory);
 }
@@ -304,8 +304,8 @@ Suite *crypto_factory_suite_create()
        tcase_add_loop_test(tc, test_create_rng, 0, countof(rng_data));
        suite_add_tcase(s, tc);
 
-       tc = tcase_create("create_dh");
-       tcase_add_loop_test(tc, test_create_dh, 0, countof(dh_data));
+       tc = tcase_create("create_ke");
+       tcase_add_loop_test(tc, test_create_ke, 0, countof(ke_data));
        suite_add_tcase(s, tc);
 
        return s;
index 2144d1dd3fc5a096d364aefc2906cde7dc156084..cd390a04a6579653e8f7a0cb9003a944aeabf2ae 100644 (file)
@@ -53,8 +53,8 @@ IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_public_key_create_from_data, ntru_public_ke
  * NTRU parameter sets to test
  */
 static struct {
-       diffie_hellman_group_t group;
-       char *group_name;
+       key_exchange_method_t ke;
+       char *name;
 } params[] = {
        { NTRU_112_BIT, "NTRU_112" },
        { NTRU_128_BIT, "NTRU_128" },
@@ -810,39 +810,39 @@ END_TEST
 START_TEST(test_ntru_ke)
 {
        chunk_t pub_key, cipher_text, i_shared_secret, r_shared_secret;
-       diffie_hellman_t *i_ntru, *r_ntru;
+       key_exchange_t *i_ntru, *r_ntru;
        char buf[10];
        int k, n, len;
 
        k = (_i) / countof(parameter_sets);
        n = (_i) % countof(parameter_sets);
 
-       len = snprintf(buf, sizeof(buf), "%N", diffie_hellman_group_names,
-                                  params[k].group);
+       len = snprintf(buf, sizeof(buf), "%N", key_exchange_method_names,
+                                  params[k].ke);
        ck_assert(len == 8);
-       ck_assert(streq(buf, params[k].group_name));
+       ck_assert(streq(buf, params[k].name));
 
        lib->settings->set_str(lib->settings,
                                "libstrongswan.plugins.ntru.parameter_set", parameter_sets[n]);
 
-       i_ntru = lib->crypto->create_dh(lib->crypto, params[k].group);
+       i_ntru = lib->crypto->create_ke(lib->crypto, params[k].ke);
        ck_assert(i_ntru != NULL);
-       ck_assert(i_ntru->get_dh_group(i_ntru) == params[k].group);
+       ck_assert(i_ntru->get_method(i_ntru) == params[k].ke);
 
-       ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key));
+       ck_assert(i_ntru->get_public_key(i_ntru, &pub_key));
        ck_assert(pub_key.len > 0);
 
-       r_ntru = lib->crypto->create_dh(lib->crypto, params[k].group);
+       r_ntru = lib->crypto->create_ke(lib->crypto, params[k].ke);
        ck_assert(r_ntru != NULL);
 
-       ck_assert(r_ntru->set_other_public_value(r_ntru, pub_key));
-       ck_assert(r_ntru->get_my_public_value(r_ntru, &cipher_text));
+       ck_assert(r_ntru->set_public_key(r_ntru, pub_key));
+       ck_assert(r_ntru->get_public_key(r_ntru, &cipher_text));
        ck_assert(cipher_text.len > 0);
 
        ck_assert(r_ntru->get_shared_secret(r_ntru, &r_shared_secret));
        ck_assert(r_shared_secret.len > 0);
 
-       ck_assert(i_ntru->set_other_public_value(i_ntru, cipher_text));
+       ck_assert(i_ntru->set_public_key(i_ntru, cipher_text));
        ck_assert(i_ntru->get_shared_secret(i_ntru, &i_shared_secret));
        ck_assert(chunk_equals(i_shared_secret, r_shared_secret));
 
@@ -857,12 +857,12 @@ END_TEST
 
 START_TEST(test_ntru_retransmission)
 {
-       diffie_hellman_t *i_ntru;
+       key_exchange_t *i_ntru;
        chunk_t pub_key1, pub_key2;
 
-       i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_256_BIT);
-       ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key1));
-       ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key2));
+       i_ntru = lib->crypto->create_ke(lib->crypto, NTRU_256_BIT);
+       ck_assert(i_ntru->get_public_key(i_ntru, &pub_key1));
+       ck_assert(i_ntru->get_public_key(i_ntru, &pub_key2));
        ck_assert(chunk_equals(pub_key1, pub_key2));
 
        chunk_free(&pub_key1);
@@ -884,12 +884,12 @@ chunk_t oid_tests[] = {
 
 START_TEST(test_ntru_pubkey_oid)
 {
-       diffie_hellman_t *r_ntru;
+       key_exchange_t *r_ntru;
        chunk_t cipher_text;
 
-       r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
-       ck_assert(!r_ntru->set_other_public_value(r_ntru, oid_tests[_i]));
-       ck_assert(r_ntru->get_my_public_value(r_ntru, &cipher_text));
+       r_ntru = lib->crypto->create_ke(lib->crypto, NTRU_128_BIT);
+       ck_assert(!r_ntru->set_public_key(r_ntru, oid_tests[_i]));
+       ck_assert(r_ntru->get_public_key(r_ntru, &cipher_text));
        ck_assert(cipher_text.len == 0);
        r_ntru->destroy(r_ntru);
 }
@@ -897,21 +897,21 @@ END_TEST
 
 START_TEST(test_ntru_wrong_set)
 {
-       diffie_hellman_t *i_ntru, *r_ntru;
+       key_exchange_t *i_ntru, *r_ntru;
        chunk_t pub_key, cipher_text;
 
        lib->settings->set_str(lib->settings,
                                                  "libstrongswan.plugins.ntru.parameter_set",
                                                  "x9_98_bandwidth");
-       i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_112_BIT);
-       ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key));
+       i_ntru = lib->crypto->create_ke(lib->crypto, NTRU_112_BIT);
+       ck_assert(i_ntru->get_public_key(i_ntru, &pub_key));
 
        lib->settings->set_str(lib->settings,
                                                  "libstrongswan.plugins.ntru.parameter_set",
                                                  "optimum");
-       r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_112_BIT);
-       ck_assert(!r_ntru->set_other_public_value(r_ntru, pub_key));
-       ck_assert(r_ntru->get_my_public_value(r_ntru, &cipher_text));
+       r_ntru = lib->crypto->create_ke(lib->crypto, NTRU_112_BIT);
+       ck_assert(!r_ntru->set_public_key(r_ntru, pub_key));
+       ck_assert(r_ntru->get_public_key(r_ntru, &cipher_text));
        ck_assert(cipher_text.len == 0);
 
        chunk_free(&pub_key);
@@ -932,7 +932,7 @@ START_TEST(test_ntru_ciphertext)
                chunk_create(buf_ff, sizeof(buf_ff)),
        };
 
-       diffie_hellman_t *i_ntru;
+       key_exchange_t *i_ntru;
        chunk_t pub_key, shared_secret;
        int i;
 
@@ -941,9 +941,9 @@ START_TEST(test_ntru_ciphertext)
 
        for (i = 0; i < countof(test); i++)
        {
-               i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
-               ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key));
-               ck_assert(!i_ntru->set_other_public_value(i_ntru, test[i]));
+               i_ntru = lib->crypto->create_ke(lib->crypto, NTRU_128_BIT);
+               ck_assert(i_ntru->get_public_key(i_ntru, &pub_key));
+               ck_assert(!i_ntru->set_public_key(i_ntru, test[i]));
                ck_assert(!i_ntru->get_shared_secret(i_ntru, &shared_secret));
                ck_assert(shared_secret.len == 0);
 
@@ -955,18 +955,18 @@ END_TEST
 
 START_TEST(test_ntru_wrong_ciphertext)
 {
-       diffie_hellman_t *i_ntru, *r_ntru, *m_ntru;
+       key_exchange_t *i_ntru, *r_ntru, *m_ntru;
        chunk_t pub_key_i, pub_key_m, cipher_text, shared_secret;
 
-       i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
-       r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
-       m_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT);
+       i_ntru = lib->crypto->create_ke(lib->crypto, NTRU_128_BIT);
+       r_ntru = lib->crypto->create_ke(lib->crypto, NTRU_128_BIT);
+       m_ntru = lib->crypto->create_ke(lib->crypto, NTRU_128_BIT);
 
-       ck_assert(i_ntru->get_my_public_value(i_ntru, &pub_key_i));
-       ck_assert(m_ntru->get_my_public_value(m_ntru, &pub_key_m));
-       ck_assert(r_ntru->set_other_public_value(r_ntru, pub_key_m));
-       ck_assert(r_ntru->get_my_public_value(r_ntru, &cipher_text));
-       ck_assert(!i_ntru->set_other_public_value(i_ntru, cipher_text));
+       ck_assert(i_ntru->get_public_key(i_ntru, &pub_key_i));
+       ck_assert(m_ntru->get_public_key(m_ntru, &pub_key_m));
+       ck_assert(r_ntru->set_public_key(r_ntru, pub_key_m));
+       ck_assert(r_ntru->get_public_key(r_ntru, &cipher_text));
+       ck_assert(!i_ntru->set_public_key(i_ntru, cipher_text));
        ck_assert(!i_ntru->get_shared_secret(i_ntru, &shared_secret));
        ck_assert(shared_secret.len == 0);
 
index c323119ea78b732b566cb4baa3875a3a143e8883..1d0003684b56388564706cbcad04d4614447bc29 100644 (file)
@@ -97,11 +97,11 @@ static struct {
        { PROTO_ESP, "aes128-aes256-sha1-sha256", "aes256-aes128-sha256-sha1", "aes128-sha1" },
        { PROTO_ESP, "aes256-aes128-sha256-sha1", "aes128-aes256-sha1-sha256", "aes256-sha256" },
        { PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256", NULL },
-       { PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256", "aes128-sha256", PROPOSAL_SKIP_DH },
+       { PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256", "aes128-sha256", PROPOSAL_SKIP_KE },
        { PROTO_ESP, "aes128-sha256", "aes128-sha256-modp3072", NULL },
-       { PROTO_ESP, "aes128-sha256", "aes128-sha256-modp3072", "aes128-sha256", PROPOSAL_SKIP_DH },
-       { PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256-modp3072", "aes128-sha256", PROPOSAL_SKIP_DH },
-       { PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256-ecp256", "aes128-sha256", PROPOSAL_SKIP_DH },
+       { PROTO_ESP, "aes128-sha256", "aes128-sha256-modp3072", "aes128-sha256", PROPOSAL_SKIP_KE },
+       { PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256-modp3072", "aes128-sha256", PROPOSAL_SKIP_KE },
+       { PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256-ecp256", "aes128-sha256", PROPOSAL_SKIP_KE },
        { PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256-modpnone", NULL },
        { PROTO_ESP, "aes128-sha256-modpnone", "aes128-sha256-modp3072", NULL },
        { PROTO_ESP, "aes128-sha256-modp3072-modpnone", "aes128-sha256", "aes128-sha256" },
@@ -219,10 +219,10 @@ static struct {
                                 { "aes256-modp2048", "aes128-modp2048" }, NULL },
        { PROTO_ESP, { "aes128-modp1024", "aes256-modp1024" },
                                 { "aes256-modp2048", "aes128-modp2048" }, "aes128",
-               PROPOSAL_SKIP_DH },
+               PROPOSAL_SKIP_KE },
        { PROTO_ESP, { "aes128-modp1024", "aes256-modp1024" },
                                 { "aes256-modp2048", "aes128-modp2048" }, "aes256",
-               PROPOSAL_PREFER_SUPPLIED | PROPOSAL_SKIP_DH },
+               PROPOSAL_PREFER_SUPPLIED | PROPOSAL_SKIP_KE },
 };
 
 START_TEST(test_select_proposal)
@@ -274,38 +274,38 @@ START_TEST(test_select_proposal)
 }
 END_TEST
 
-START_TEST(test_promote_dh_group)
+START_TEST(test_promote_ke_method)
 {
        proposal_t *proposal;
 
        proposal = proposal_create_from_string(PROTO_IKE,
                                                                                   "aes128-sha256-modp3072-ecp256");
-       ck_assert(proposal->promote_dh_group(proposal, ECP_256_BIT));
+       ck_assert(proposal->promote_ke_method(proposal, ECP_256_BIT));
        assert_proposal_eq(proposal, "IKE:AES_CBC_128/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/ECP_256/MODP_3072");
        proposal->destroy(proposal);
 }
 END_TEST
 
-START_TEST(test_promote_dh_group_already_front)
+START_TEST(test_promote_ke_method_already_front)
 {
        proposal_t *proposal;
 
        proposal = proposal_create_from_string(PROTO_IKE,
                                                                                   "aes128-sha256-modp3072-ecp256");
-       ck_assert(proposal->promote_dh_group(proposal, MODP_3072_BIT));
+       ck_assert(proposal->promote_ke_method(proposal, MODP_3072_BIT));
        assert_proposal_eq(proposal, "IKE:AES_CBC_128/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_3072/ECP_256");
        proposal->destroy(proposal);
 }
 END_TEST
 
-START_TEST(test_promote_dh_group_not_contained)
+START_TEST(test_promote_ke_method_not_contained)
 {
        proposal_t *proposal;
 
        proposal = proposal_create_from_string(PROTO_IKE,
                                                                                   "aes128-sha256-modp3072-ecp256");
 
-       ck_assert(!proposal->promote_dh_group(proposal, MODP_2048_BIT));
+       ck_assert(!proposal->promote_ke_method(proposal, MODP_2048_BIT));
        assert_proposal_eq(proposal, "IKE:AES_CBC_128/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_3072/ECP_256");
        proposal->destroy(proposal);
 }
@@ -420,11 +420,11 @@ static struct {
        { PROTO_ESP, "aes128-serpent", "aes128-serpent" },
        { PROTO_ESP, "aes128-serpent", "aes128", PROPOSAL_SKIP_PRIVATE },
        { PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256-modp3072" },
-       { PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256", PROPOSAL_SKIP_DH },
+       { PROTO_ESP, "aes128-sha256-modp3072", "aes128-sha256", PROPOSAL_SKIP_KE },
        { PROTO_ESP, "aes128-serpent-modp3072", "aes128-serpent",
-               PROPOSAL_SKIP_DH },
+               PROPOSAL_SKIP_KE },
        { PROTO_ESP, "aes128-serpent-modp3072", "aes128",
-               PROPOSAL_SKIP_PRIVATE | PROPOSAL_SKIP_DH },
+               PROPOSAL_SKIP_PRIVATE | PROPOSAL_SKIP_KE },
 };
 
 START_TEST(test_clone)
@@ -474,10 +474,10 @@ Suite *proposal_suite_create()
                                                countof(select_proposal_data));
        suite_add_tcase(s, tc);
 
-       tc = tcase_create("promote_dh_group");
-       tcase_add_test(tc, test_promote_dh_group);
-       tcase_add_test(tc, test_promote_dh_group_already_front);
-       tcase_add_test(tc, test_promote_dh_group_not_contained);
+       tc = tcase_create("promote_ke_method");
+       tcase_add_test(tc, test_promote_ke_method);
+       tcase_add_test(tc, test_promote_ke_method_already_front);
+       tcase_add_test(tc, test_promote_ke_method_not_contained);
        suite_add_tcase(s, tc);
 
        tc = tcase_create("unknown transform types");
index 0cc862fe67d14bc3685d95fddeec5ade50948334..e927401d5c25a2aa5733cb376e32167cc6d468d7 100644 (file)
@@ -31,7 +31,7 @@ static transform_type_t tfs[] = {
        EXTENDED_OUTPUT_FUNCTION,
        DETERMINISTIC_RANDOM_BIT_GENERATOR,
        RANDOM_NUMBER_GENERATOR,
-       DIFFIE_HELLMAN_GROUP,
+       KEY_EXCHANGE_METHOD,
 };
 
 START_TEST(test_vectors)
index 901410331c9f1182918dd7e10a3eade4b6842b91..1689311513933961169ce5a82b06708d85003d57 100644 (file)
@@ -50,7 +50,7 @@ TEST_SUITE(rng_tester_suite_create)
 TEST_SUITE_DEPEND(mgf1_sha1_suite_create, XOF, XOF_MGF1_SHA1)
 TEST_SUITE_DEPEND(mgf1_sha256_suite_create, XOF, XOF_MGF1_SHA256)
 TEST_SUITE_DEPEND(prf_plus_suite_create, PRF, PRF_HMAC_SHA2_256)
-TEST_SUITE_DEPEND(ntru_suite_create, DH, NTRU_112_BIT)
+TEST_SUITE_DEPEND(ntru_suite_create, KE, NTRU_112_BIT)
 TEST_SUITE_DEPEND(fetch_http_suite_create, FETCHER, "http://")
 TEST_SUITE_DEPEND(ed25519_suite_create, PRIVKEY_GEN, KEY_ED25519)
 TEST_SUITE_DEPEND(ed448_suite_create, PRIVKEY_GEN, KEY_ED448)
index ebadb91c80fd8164da6053607ce813b75b67c79d..e1e13cc9914f18c8f503de60ac5db939115837ff 100644 (file)
@@ -409,7 +409,7 @@ struct private_tls_crypto_t {
 typedef struct {
        tls_cipher_suite_t suite;
        key_type_t key;
-       diffie_hellman_group_t dh;
+       key_exchange_method_t dh;
        hash_algorithm_t hash;
        pseudo_random_function_t prf;
        integrity_algorithm_t mac;
@@ -775,21 +775,21 @@ static void filter_key_exchange_config_suites(private_tls_crypto_t *this,
                        while (enumerator->enumerate(enumerator, &token))
                        {
                                if (strcaseeq(token, "ecdhe-ecdsa") &&
-                                       diffie_hellman_group_is_ec(suites[i].dh) &&
+                                       key_exchange_is_ecdh(suites[i].dh) &&
                                        suites[i].key == KEY_ECDSA)
                                {
                                        suites[remaining++] = suites[i];
                                        break;
                                }
                                if (strcaseeq(token, "ecdhe-rsa") &&
-                                       diffie_hellman_group_is_ec(suites[i].dh) &&
+                                       key_exchange_is_ecdh(suites[i].dh) &&
                                        suites[i].key == KEY_RSA)
                                {
                                        suites[remaining++] = suites[i];
                                        break;
                                }
                                if (strcaseeq(token, "dhe-rsa") &&
-                                       !diffie_hellman_group_is_ec(suites[i].dh) &&
+                                       !key_exchange_is_ecdh(suites[i].dh) &&
                                        suites[i].dh != MODP_NONE &&
                                        suites[i].key == KEY_RSA)
                                {
@@ -989,7 +989,7 @@ static void filter_unsupported_suites(suite_algs_t suites[], int *count)
        filter_suite(suites, count, offsetof(suite_algs_t, hash),
                                 lib->crypto->create_hasher_enumerator);
        filter_suite(suites, count, offsetof(suite_algs_t, dh),
-                                lib->crypto->create_dh_enumerator);
+                                lib->crypto->create_ke_enumerator);
 }
 
 /**
@@ -1194,7 +1194,7 @@ METHOD(tls_crypto_t, select_cipher_suite, tls_cipher_suite_t,
        return 0;
 }
 
-METHOD(tls_crypto_t, get_dh_group, diffie_hellman_group_t,
+METHOD(tls_crypto_t, get_dh_group, key_exchange_method_t,
        private_tls_crypto_t *this)
 {
        suite_algs_t *algs;
@@ -1286,7 +1286,7 @@ static signature_scheme_t hashsig_to_scheme(key_type_t type,
  * Mapping groups to TLS named curves
  */
 static struct {
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
        tls_named_curve_t curve;
 } curves[] = {
        { ECP_256_BIT, TLS_SECP256R1},
@@ -1299,7 +1299,7 @@ static struct {
 CALLBACK(group_filter, bool,
        void *null, enumerator_t *orig, va_list args)
 {
-       diffie_hellman_group_t group, *out;
+       key_exchange_method_t group, *out;
        tls_named_curve_t *curve;
        char *plugin;
        int i;
@@ -1331,7 +1331,7 @@ METHOD(tls_crypto_t, create_ec_enumerator, enumerator_t*,
        private_tls_crypto_t *this)
 {
        return enumerator_create_filter(
-                                                       lib->crypto->create_dh_enumerator(lib->crypto),
+                                                       lib->crypto->create_ke_enumerator(lib->crypto),
                                                        group_filter, NULL, NULL);
 }
 
index a42e07bb3890ee3b6a814355c7993a9665f19320..9578511e4277012fb281c021677b11cc6afbe004 100644 (file)
@@ -418,9 +418,9 @@ struct tls_crypto_t {
        /**
         * Get the Diffie-Hellman group to use, if any.
         *
-        * @return                              Diffie Hellman group, ord MODP_NONE
+        * @return                              Diffie-Hellman group, or MODP_NONE
         */
-       diffie_hellman_group_t (*get_dh_group)(tls_crypto_t *this);
+       key_exchange_method_t (*get_dh_group)(tls_crypto_t *this);
 
        /**
         * Write the list of supported hash/sig algorithms to writer.
@@ -432,7 +432,7 @@ struct tls_crypto_t {
        /**
         * Create an enumerator over supported ECDH groups.
         *
-        * Enumerates over (diffie_hellman_group_t, tls_named_curve_t)
+        * Enumerates over (key_exchange_method_t, tls_named_curve_t)
         *
         * @return                              enumerator
         */
index 1f2439ca13c0bae2695aa63817b45e842d96c4ba..dc523fac0cf0b66b366013df9590e9a0a491e33c 100644 (file)
@@ -112,7 +112,7 @@ struct private_tls_peer_t {
        /**
         * DHE exchange
         */
-       diffie_hellman_t *dh;
+       key_exchange_t *dh;
 
        /**
         * Resuming a session?
@@ -384,7 +384,7 @@ static status_t process_modp_key_exchange(private_tls_peer_t *this,
        public->destroy(public);
        free(chunk.ptr);
 
-       this->dh = lib->crypto->create_dh(lib->crypto, MODP_CUSTOM,
+       this->dh = lib->crypto->create_ke(lib->crypto, MODP_CUSTOM,
                                                                          generator, prime);
        if (!this->dh)
        {
@@ -392,7 +392,7 @@ static status_t process_modp_key_exchange(private_tls_peer_t *this,
                this->alert->add(this->alert, TLS_FATAL, TLS_INTERNAL_ERROR);
                return NEED_MORE;
        }
-       if (!this->dh->set_other_public_value(this->dh, pub))
+       if (!this->dh->set_public_key(this->dh, pub))
        {
                DBG1(DBG_TLS, "applying DH public value failed");
                this->alert->add(this->alert, TLS_FATAL, TLS_INTERNAL_ERROR);
@@ -406,10 +406,10 @@ static status_t process_modp_key_exchange(private_tls_peer_t *this,
 /**
  * Get the EC group for a TLS named curve
  */
-static diffie_hellman_group_t curve_to_ec_group(private_tls_peer_t *this,
-                                                                                               tls_named_curve_t curve)
+static key_exchange_method_t curve_to_ec_group(private_tls_peer_t *this,
+                                                                                          tls_named_curve_t curve)
 {
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
        tls_named_curve_t current;
        enumerator_t *enumerator;
 
@@ -432,7 +432,7 @@ static diffie_hellman_group_t curve_to_ec_group(private_tls_peer_t *this,
 static status_t process_ec_key_exchange(private_tls_peer_t *this,
                                                                                bio_reader_t *reader)
 {
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
        public_key_t *public;
        uint8_t type;
        uint16_t curve;
@@ -491,11 +491,11 @@ static status_t process_ec_key_exchange(private_tls_peer_t *this,
        public->destroy(public);
        free(chunk.ptr);
 
-       this->dh = lib->crypto->create_dh(lib->crypto, group);
+       this->dh = lib->crypto->create_ke(lib->crypto, group);
        if (!this->dh)
        {
                DBG1(DBG_TLS, "DH group %N not supported",
-                        diffie_hellman_group_names, group);
+                        key_exchange_method_names, group);
                this->alert->add(this->alert, TLS_FATAL, TLS_INTERNAL_ERROR);
                return NEED_MORE;
        }
@@ -507,7 +507,7 @@ static status_t process_ec_key_exchange(private_tls_peer_t *this,
                this->alert->add(this->alert, TLS_FATAL, TLS_INTERNAL_ERROR);
                return NEED_MORE;
        }
-       if (!this->dh->set_other_public_value(this->dh, chunk_skip(pub, 1)))
+       if (!this->dh->set_public_key(this->dh, chunk_skip(pub, 1)))
        {
                DBG1(DBG_TLS, "applying DH public value failed");
                this->alert->add(this->alert, TLS_FATAL, TLS_INTERNAL_ERROR);
@@ -524,7 +524,7 @@ static status_t process_ec_key_exchange(private_tls_peer_t *this,
 static status_t process_key_exchange(private_tls_peer_t *this,
                                                                         bio_reader_t *reader)
 {
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        this->crypto->append_handshake(this->crypto,
                                                                TLS_SERVER_KEY_EXCHANGE, reader->peek(reader));
@@ -537,7 +537,7 @@ static status_t process_key_exchange(private_tls_peer_t *this,
                this->alert->add(this->alert, TLS_FATAL, TLS_HANDSHAKE_FAILURE);
                return NEED_MORE;
        }
-       if (diffie_hellman_group_is_ec(group))
+       if (key_exchange_is_ecdh(group))
        {
                return process_ec_key_exchange(this, reader);
        }
@@ -1008,12 +1008,12 @@ static status_t send_key_exchange_dhe(private_tls_peer_t *this,
        }
        chunk_clear(&premaster);
 
-       if (!this->dh->get_my_public_value(this->dh, &pub))
+       if (!this->dh->get_public_key(this->dh, &pub))
        {
                this->alert->add(this->alert, TLS_FATAL, TLS_INTERNAL_ERROR);
                return NEED_MORE;
        }
-       if (this->dh->get_dh_group(this->dh) == MODP_CUSTOM)
+       if (this->dh->get_method(this->dh) == MODP_CUSTOM)
        {
                writer->write_data16(writer, pub);
        }
index 70d17f22c6bd4beee436c4eda39079e356b49cf1..cc9de7d29828469371c6a855b68a701326b56509 100644 (file)
@@ -117,7 +117,7 @@ struct private_tls_server_t {
        /**
         * DHE exchange
         */
-       diffie_hellman_t *dh;
+       key_exchange_t *dh;
 
        /**
         * Selected TLS cipher suite
@@ -474,7 +474,7 @@ static status_t process_key_exchange_dhe(private_tls_server_t *this,
        this->crypto->append_handshake(this->crypto,
                                                                   TLS_CLIENT_KEY_EXCHANGE, reader->peek(reader));
 
-       ec = diffie_hellman_group_is_ec(this->dh->get_dh_group(this->dh));
+       ec = key_exchange_is_ecdh(this->dh->get_method(this->dh));
        if ((ec && !reader->read_data8(reader, &pub)) ||
                (!ec && (!reader->read_data16(reader, &pub) || pub.len == 0)))
        {
@@ -494,7 +494,7 @@ static status_t process_key_exchange_dhe(private_tls_server_t *this,
                }
                pub = chunk_skip(pub, 1);
        }
-       if (!this->dh->set_other_public_value(this->dh, pub))
+       if (!this->dh->set_public_key(this->dh, pub))
        {
                DBG1(DBG_TLS, "applying DH public value failed");
                this->alert->add(this->alert, TLS_FATAL, TLS_INTERNAL_ERROR);
@@ -806,9 +806,9 @@ static status_t send_certificate_request(private_tls_server_t *this,
  * Get the TLS curve of a given EC DH group
  */
 static tls_named_curve_t ec_group_to_curve(private_tls_server_t *this,
-                                                                                  diffie_hellman_group_t group)
+                                                                                  key_exchange_method_t group)
 {
-       diffie_hellman_group_t current;
+       key_exchange_method_t current;
        tls_named_curve_t curve;
        enumerator_t *enumerator;
 
@@ -878,13 +878,13 @@ static bool find_supported_curve(private_tls_server_t *this,
  */
 static status_t send_server_key_exchange(private_tls_server_t *this,
                                                        tls_handshake_type_t *type, bio_writer_t *writer,
-                                                       diffie_hellman_group_t group)
+                                                       key_exchange_method_t group)
 {
        diffie_hellman_params_t *params = NULL;
        tls_named_curve_t curve;
        chunk_t chunk;
 
-       if (diffie_hellman_group_is_ec(group))
+       if (key_exchange_is_ecdh(group))
        {
                curve = ec_group_to_curve(this, group);
                if (!curve || (!peer_supports_curve(this, curve) &&
@@ -904,23 +904,23 @@ static status_t send_server_key_exchange(private_tls_server_t *this,
                if (!params)
                {
                        DBG1(DBG_TLS, "no parameters found for DH group %N",
-                                diffie_hellman_group_names, group);
+                                key_exchange_method_names, group);
                        this->alert->add(this->alert, TLS_FATAL, TLS_INTERNAL_ERROR);
                        return NEED_MORE;
                }
-               DBG2(DBG_TLS, "selected DH group %N", diffie_hellman_group_names, group);
+               DBG2(DBG_TLS, "selected DH group %N", key_exchange_method_names, group);
                writer->write_data16(writer, params->prime);
                writer->write_data16(writer, params->generator);
        }
-       this->dh = lib->crypto->create_dh(lib->crypto, group);
+       this->dh = lib->crypto->create_ke(lib->crypto, group);
        if (!this->dh)
        {
                DBG1(DBG_TLS, "DH group %N not supported",
-                        diffie_hellman_group_names, group);
+                        key_exchange_method_names, group);
                this->alert->add(this->alert, TLS_FATAL, TLS_INTERNAL_ERROR);
                return NEED_MORE;
        }
-       if (!this->dh->get_my_public_value(this->dh, &chunk))
+       if (!this->dh->get_public_key(this->dh, &chunk))
        {
                this->alert->add(this->alert, TLS_FATAL, TLS_INTERNAL_ERROR);
                return NEED_MORE;
@@ -993,7 +993,7 @@ static status_t send_finished(private_tls_server_t *this,
 METHOD(tls_handshake_t, build, status_t,
        private_tls_server_t *this, tls_handshake_type_t *type, bio_writer_t *writer)
 {
-       diffie_hellman_group_t group;
+       key_exchange_method_t group;
 
        switch (this->state)
        {