]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
child-cfg: Generalize get_ke_method() method
authorTobias Brunner <tobias@strongswan.org>
Fri, 20 Jul 2018 09:11:00 +0000 (11:11 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 29 Jun 2022 08:28:50 +0000 (10:28 +0200)
src/libcharon/config/child_cfg.c
src/libcharon/config/child_cfg.h
src/libcharon/sa/ikev1/tasks/quick_mode.c
src/libcharon/sa/ikev2/tasks/child_create.c

index 986d6106bd555198f6c83b1f572fbf2af0d3f0ee..78d1f3c43b2ba8b981794c90933be142284bbba2 100644 (file)
@@ -484,24 +484,23 @@ METHOD(child_cfg_t, get_close_action, action_t,
        return this->close_action;
 }
 
-METHOD(child_cfg_t, get_ke_method, key_exchange_method_t,
-       private_child_cfg_t *this)
+METHOD(child_cfg_t, get_algorithm, uint16_t,
+       private_child_cfg_t *this, transform_type_t type)
 {
        enumerator_t *enumerator;
        proposal_t *proposal;
-       uint16_t method = KE_NONE;
+       uint16_t alg = 0;
 
        enumerator = this->proposals->create_enumerator(this->proposals);
        while (enumerator->enumerate(enumerator, &proposal))
        {
-               if (proposal->get_algorithm(proposal, KEY_EXCHANGE_METHOD, &method,
-                                                                       NULL))
+               if (proposal->get_algorithm(proposal, type, &alg, NULL))
                {
                        break;
                }
        }
        enumerator->destroy(enumerator);
-       return method;
+       return alg;
 }
 
 METHOD(child_cfg_t, get_inactivity, uint32_t,
@@ -759,7 +758,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_ke_method = _get_ke_method,
+                       .get_algorithm = _get_algorithm,
                        .get_inactivity = _get_inactivity,
                        .get_reqid = _get_reqid,
                        .get_if_id = _get_if_id,
index bed12c5f7372729604b96f756d108f4463131b14..9c44252758c7900ff9a6145cc783e2360f452627 100644 (file)
@@ -204,11 +204,16 @@ struct child_cfg_t {
        action_t (*get_close_action) (child_cfg_t *this);
 
        /**
-        * Get the key exchange method to use for CHILD_SA setup.
+        * Get the first algorithm of a certain transform type that's contained in
+        * any of the configured proposals.
         *
-        * @return                              key exchange method to use
+        * For instance, use with KEY_EXCHANGE_METHOD to get the KE method to use
+        * for the CHILD_SA initiation.
+        *
+        * @param type                  transform type to look for
+        * @return                              algorithm identifier (0 for none)
         */
-       key_exchange_method_t (*get_ke_method)(child_cfg_t *this);
+       uint16_t (*get_algorithm)(child_cfg_t *this, transform_type_t type);
 
        /**
         * Get the inactivity timeout value.
index 78cc46f1038bd5fa88444a14e6afe1814d2018e0..3d2e3efbe4e5ca0c4ddfbbf1b67d9c285d2cb71a 100644 (file)
@@ -866,7 +866,8 @@ METHOD(task_t, build_i, status_t,
                                return FAILED;
                        }
 
-                       group = this->config->get_ke_method(this->config);
+                       group = this->config->get_algorithm(this->config,
+                                                                                               KEY_EXCHANGE_METHOD);
                        if (group != KE_NONE)
                        {
                                proposal_t *proposal;
index 5230b30bd5f21f73ce16a3d0c51ffa317fbbee1b..7ac087cd2057576fee6e92af0e5c09781aa4b10f 100644 (file)
@@ -1160,7 +1160,8 @@ METHOD(task_t, build_i, status_t,
                        }
                        if (!this->retry && this->dh_group == KE_NONE)
                        {       /* during a rekeying the group might already be set */
-                               this->dh_group = this->config->get_ke_method(this->config);
+                               this->dh_group = this->config->get_algorithm(this->config,
+                                                                                                               KEY_EXCHANGE_METHOD);
                        }
                        break;
                case IKE_AUTH: