]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Set selected proposal on IKEv1 SA, don't pass it separately to Phase 1 helper
authorMartin Willi <martin@revosec.ch>
Wed, 18 Jan 2012 16:42:06 +0000 (17:42 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:31:37 +0000 (17:31 +0100)
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

index ed5fbe5c912b67fe0fc49e02a3ec4b7fc7025486..a5fa6ea1b57331b1c73880f2be370e5dd4acc412 100644 (file)
@@ -173,9 +173,10 @@ static shared_key_t *lookup_shared_key(private_phase1_t *this,
 }
 
 METHOD(phase1_t, create_hasher, bool,
-       private_phase1_t *this, proposal_t *proposal)
+       private_phase1_t *this)
 {
-       return this->keymat->create_hasher(this->keymat, proposal);
+       return this->keymat->create_hasher(this->keymat,
+                                                       this->ike_sa->get_proposal(this->ike_sa));
 }
 
 METHOD(phase1_t, create_dh, bool,
@@ -186,8 +187,7 @@ METHOD(phase1_t, create_dh, bool,
 }
 
 METHOD(phase1_t, derive_keys, bool,
-       private_phase1_t *this, peer_cfg_t *peer_cfg, auth_method_t method,
-       proposal_t *proposal)
+       private_phase1_t *this, peer_cfg_t *peer_cfg, auth_method_t method)
 {
        shared_key_t *shared_key = NULL;
 
@@ -206,7 +206,8 @@ METHOD(phase1_t, derive_keys, bool,
                        break;
        }
 
-       if (!this->keymat->derive_ike_keys(this->keymat, proposal,
+       if (!this->keymat->derive_ike_keys(this->keymat,
+                                               this->ike_sa->get_proposal(this->ike_sa),
                                                this->dh, this->dh_value, this->nonce_i, this->nonce_r,
                                                this->ike_sa->get_id(this->ike_sa), method, shared_key))
        {
index 994c85be7e49923117b0c11a9e116f4acc83cf00..91210c31f2c1363e9a12abcb9517e76e0eb09baf 100644 (file)
@@ -34,10 +34,9 @@ struct phase1_t {
        /**
         * Create keymat hasher.
         *
-        * @param proposal              negotiated proposal
         * @return                              TRUE if hasher created
         */
-       bool (*create_hasher)(phase1_t *this, proposal_t *proposal);
+       bool (*create_hasher)(phase1_t *this);
 
        /**
         * Create DH object using SA keymat.
@@ -52,11 +51,10 @@ struct phase1_t {
         *
         * @param peer_cfg              peer config to look up shared key for, or NULL
         * @param method                negotiated authenticated method
-        * @param proposal              selected IKE proposal
         * @return                              TRUE if successful
         */
        bool (*derive_keys)(phase1_t *this, peer_cfg_t *peer_cfg,
-                                               auth_method_t method, proposal_t *proposal);
+                                               auth_method_t method);
        /**
         * Verify a HASH or SIG payload in message.
         *
index b89b71b4cbde634e580f9484d022db6a5765cca8..9621e7099079d900b6a7e164ee69d84cf8510a2e 100755 (executable)
@@ -360,6 +360,7 @@ METHOD(task_t, process_r, status_t,
                                DBG1(DBG_IKE, "no proposal found");
                                return send_notify(this, NO_PROPOSAL_CHOSEN);
                        }
+                       this->ike_sa->set_proposal(this->ike_sa, this->proposal);
 
                        this->method = sa_payload->get_auth_method(sa_payload);
                        this->lifetime = sa_payload->get_lifetime(sa_payload);
@@ -469,12 +470,11 @@ METHOD(task_t, build_r, status_t,
                {
                        return send_notify(this, INVALID_KEY_INFORMATION);
                }
-               if (!this->ph1->create_hasher(this->ph1, this->proposal))
+               if (!this->ph1->create_hasher(this->ph1))
                {
                        return send_notify(this, NO_PROPOSAL_CHOSEN);
                }
-               if (!this->ph1->derive_keys(this->ph1, this->peer_cfg, this->method,
-                                                                       this->proposal))
+               if (!this->ph1->derive_keys(this->ph1, this->peer_cfg, this->method))
                {
                        return send_notify(this, INVALID_KEY_INFORMATION);
                }
@@ -528,6 +528,7 @@ METHOD(task_t, process_i, status_t,
                        DBG1(DBG_IKE, "no proposal found");
                        return send_notify(this, NO_PROPOSAL_CHOSEN);
                }
+               this->ike_sa->set_proposal(this->ike_sa, this->proposal);
 
                lifetime = sa_payload->get_lifetime(sa_payload);
                if (lifetime != this->lifetime)
@@ -547,12 +548,11 @@ METHOD(task_t, process_i, status_t,
                {
                        return send_notify(this, INVALID_PAYLOAD_TYPE);
                }
-               if (!this->ph1->create_hasher(this->ph1, this->proposal))
+               if (!this->ph1->create_hasher(this->ph1))
                {
                        return send_notify(this, NO_PROPOSAL_CHOSEN);
                }
-               if (!this->ph1->derive_keys(this->ph1, this->peer_cfg, this->method,
-                                                                       this->proposal))
+               if (!this->ph1->derive_keys(this->ph1, this->peer_cfg, this->method))
                {
                        return send_notify(this, INVALID_KEY_INFORMATION);
                }
index c1a61cede11835737761903b80d8427dbf0c0ced..a7be22916e7534a359009083811c273257cefb75 100755 (executable)
@@ -262,7 +262,7 @@ METHOD(task_t, build_i, status_t,
                {
                        u_int16_t group;
 
-                       if (!this->ph1->create_hasher(this->ph1, this->proposal))
+                       if (!this->ph1->create_hasher(this->ph1))
                        {
                                return send_notify(this, NO_PROPOSAL_CHOSEN);
                        }
@@ -353,6 +353,7 @@ METHOD(task_t, process_r, status_t,
                                DBG1(DBG_IKE, "no proposal found");
                                return send_notify(this, NO_PROPOSAL_CHOSEN);
                        }
+                       this->ike_sa->set_proposal(this->ike_sa, this->proposal);
 
                        this->method = sa_payload->get_auth_method(sa_payload);
                        this->lifetime = sa_payload->get_lifetime(sa_payload);
@@ -364,7 +365,7 @@ METHOD(task_t, process_r, status_t,
                {
                        u_int16_t group;
 
-                       if (!this->ph1->create_hasher(this->ph1, this->proposal))
+                       if (!this->ph1->create_hasher(this->ph1))
                        {
                                return send_notify(this, INVALID_KEY_INFORMATION);
                        }
@@ -454,8 +455,7 @@ METHOD(task_t, build_r, status_t,
                        {
                                return send_notify(this, INVALID_KEY_INFORMATION);
                        }
-                       if (!this->ph1->derive_keys(this->ph1, this->peer_cfg, this->method,
-                                                                               this->proposal))
+                       if (!this->ph1->derive_keys(this->ph1, this->peer_cfg, this->method))
                        {
                                return send_notify(this, INVALID_KEY_INFORMATION);
                        }
@@ -540,6 +540,7 @@ METHOD(task_t, process_i, status_t,
                                DBG1(DBG_IKE, "no proposal found");
                                return send_notify(this, NO_PROPOSAL_CHOSEN);
                        }
+                       this->ike_sa->set_proposal(this->ike_sa, this->proposal);
 
                        lifetime = sa_payload->get_lifetime(sa_payload);
                        if (lifetime != this->lifetime)
@@ -563,8 +564,7 @@ METHOD(task_t, process_i, status_t,
                        {
                                return send_notify(this, INVALID_PAYLOAD_TYPE);
                        }
-                       if (!this->ph1->derive_keys(this->ph1, this->peer_cfg,
-                                                                               this->method, this->proposal))
+                       if (!this->ph1->derive_keys(this->ph1, this->peer_cfg, this->method))
                        {
                                return send_notify(this, INVALID_KEY_INFORMATION);
                        }