+
+
+ /* test with automatic created proposals */
+
+ generator = generator_create();
+ tester->assert_true(tester,(generator != NULL), "generator create check");
+
+
+ ike_proposal_count = 2;
+ ike_proposals = allocator_alloc(ike_proposal_count * (sizeof(ike_proposal_t)));
+
+ ike_proposals[0].encryption_algorithm = 1;
+ ike_proposals[0].encryption_algorithm_key_length = 20;
+ ike_proposals[0].pseudo_random_function = 2;
+ ike_proposals[0].pseudo_random_function_key_length = 22;
+ ike_proposals[0].integrity_algorithm = 3;
+ ike_proposals[0].integrity_algorithm_key_length = 24;
+ ike_proposals[0].diffie_hellman_group = 4;
+
+ ike_proposals[1].encryption_algorithm = 5;
+ ike_proposals[1].encryption_algorithm_key_length = 26;
+ ike_proposals[1].pseudo_random_function = 6;
+ ike_proposals[1].pseudo_random_function_key_length = 28;
+ ike_proposals[1].integrity_algorithm = 7;
+ ike_proposals[1].integrity_algorithm_key_length = 30;
+ ike_proposals[1].diffie_hellman_group = 8;
+
+ sa_payload = sa_payload_create_from_ike_proposals(ike_proposals,ike_proposal_count);
+ tester->assert_true(tester,(sa_payload != NULL), "sa_payload create check");
+
+ generator->generate_payload(generator,(payload_t *)sa_payload);
+ generator->write_to_chunk(generator,&generated_data);
+ logger->log_chunk(logger,RAW,"generated",&generated_data);
+
+ u_int8_t expected_generation2[] = {
+ 0x00,0x00,0x00,0x6C, /* payload header*/
+ 0x02,0x00,0x00,0x34, /* a proposal */
+ 0x01,0x01,0x00,0x04,
+ 0x03,0x00,0x00,0x0C, /* transform 1 */
+ 0x01,0x00,0x00,0x01,
+ 0x80,0x0E,0x00,0x14, /* keylength attribute with 20 bytes length */
+ 0x03,0x00,0x00,0x0C, /* transform 2 */
+ 0x02,0x00,0x00,0x02,
+ 0x80,0x0E,0x00,0x16, /* keylength attribute with 20 bytes length */
+ 0x03,0x00,0x00,0x0C, /* transform 3 */
+ 0x03,0x00,0x00,0x03,
+ 0x80,0x0E,0x00,0x18, /* keylength attribute with 20 bytes length */
+ 0x00,0x00,0x00,0x08, /* transform 4 */
+ 0x04,0x00,0x00,0x04,
+ 0x00,0x00,0x00,0x34, /* a proposal */
+ 0x02,0x01,0x00,0x04,
+ 0x03,0x00,0x00,0x0C, /* transform 1 */
+ 0x01,0x00,0x00,0x05,
+ 0x80,0x0E,0x00,0x1A, /* keylength attribute with 16 bytes length */
+ 0x03,0x00,0x00,0x0C, /* transform 2 */
+ 0x02,0x00,0x00,0x06,
+ 0x80,0x0E,0x00,0x1C, /* keylength attribute with 16 bytes length */
+ 0x03,0x00,0x00,0x0C, /* transform 3 */
+ 0x03,0x00,0x00,0x07,
+ 0x80,0x0E,0x00,0x1E, /* keylength attribute with 16 bytes length */
+ 0x00,0x00,0x00,0x08, /* transform 4 */
+ 0x04,0x00,0x00,0x08,
+
+ };
+
+ logger->log_bytes(logger,RAW,"expected",expected_generation2,sizeof(expected_generation2));
+
+ tester->assert_true(tester,(memcmp(expected_generation2,generated_data.ptr,sizeof(expected_generation2)) == 0), "compare generated data");
+
+ sa_payload->destroy(sa_payload);
+ allocator_free(ike_proposals);
+ allocator_free_chunk(&generated_data);
+ generator->destroy(generator);