proposals: try next if IKEv2 algorithm could not be mapped to IKEv1
authorMartin Willi <martin@revosec.ch>
Mon, 22 Apr 2013 10:33:52 +0000 (12:33 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 6 May 2013 13:54:32 +0000 (15:54 +0200)
src/libcharon/encoding/payloads/proposal_substructure.c

index ae0fce9..3cf22ae 100644 (file)
@@ -1224,7 +1224,7 @@ static void set_from_proposal_v1_ike(private_proposal_substructure_t *this,
                                                                                                number, IKEV1_TRANSID_KEY_IKE);
 
        enumerator = proposal->create_enumerator(proposal, ENCRYPTION_ALGORITHM);
-       if (enumerator->enumerate(enumerator, &alg, &key_size))
+       while (enumerator->enumerate(enumerator, &alg, &key_size))
        {
                alg = get_ikev1_from_alg(ENCRYPTION_ALGORITHM, alg);
                if (alg)
@@ -1238,13 +1238,14 @@ static void set_from_proposal_v1_ike(private_proposal_substructure_t *this,
                                        transform_attribute_create_value(TRANSFORM_ATTRIBUTE_V1,
                                                                                TATTR_PH1_KEY_LENGTH, key_size));
                        }
+                       break;
                }
        }
        enumerator->destroy(enumerator);
 
        /* encode the integrity algorithm as hash and assume use the same PRF */
        enumerator = proposal->create_enumerator(proposal, INTEGRITY_ALGORITHM);
-       if (enumerator->enumerate(enumerator, &alg, &key_size))
+       while (enumerator->enumerate(enumerator, &alg, &key_size))
        {
                alg = get_ikev1_from_alg(INTEGRITY_ALGORITHM, alg);
                if (alg)
@@ -1252,6 +1253,7 @@ static void set_from_proposal_v1_ike(private_proposal_substructure_t *this,
                        transform->add_transform_attribute(transform,
                                transform_attribute_create_value(TRANSFORM_ATTRIBUTE_V1,
                                                                        TATTR_PH1_HASH_ALGORITHM, alg));
+                       break;
                }
        }
        enumerator->destroy(enumerator);