En- and decode DH group attribute in quick mode SA payloads
authorMartin Willi <martin@revosec.ch>
Wed, 7 Dec 2011 16:41:16 +0000 (17:41 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:31:14 +0000 (17:31 +0100)
src/libcharon/encoding/payloads/proposal_substructure.c

index ca36206..d5778fa 100755 (executable)
@@ -684,6 +684,10 @@ static void add_to_proposal_v1_esp(proposal_t *proposal,
                                proposal->add_algorithm(proposal, INTEGRITY_ALGORITHM,
                                                get_alg_from_ikev1(INTEGRITY_ALGORITHM, value), 0);
                                break;
+                       case TATTR_PH2_GROUP:
+                               proposal->add_algorithm(proposal, DIFFIE_HELLMAN_GROUP,
+                                               value, 0);
+                               break;
                        default:
                                /* TODO-IKEv1: lifetimes other attributes */
                                break;
@@ -1076,6 +1080,15 @@ static void set_from_proposal_v1_esp(private_proposal_substructure_t *this,
        }
        enumerator->destroy(enumerator);
 
+       enumerator = proposal->create_enumerator(proposal, DIFFIE_HELLMAN_GROUP);
+       if (enumerator->enumerate(enumerator, &alg, &key_size))
+       {
+               transform->add_transform_attribute(transform,
+                       transform_attribute_create_value(TRANSFORM_ATTRIBUTE_V1,
+                                                                       TATTR_PH2_GROUP, alg));
+       }
+       enumerator->destroy(enumerator);
+
        transform->add_transform_attribute(transform,
                transform_attribute_create_value(TRANSFORM_ATTRIBUTE_V1,
                                                        TATTR_PH2_ENCAP_MODE, get_ikev1_mode(mode, udp)));