]> git.ipfire.org Git - thirdparty/strongswan.git/blob - Source/testing/connection_test.c
6b12afc1dc8ad7506fa117f64daa85bcde3207d2
[thirdparty/strongswan.git] / Source / testing / connection_test.c
1 /**
2 * @file connection_test.c
3 *
4 * @brief Tests for the connection_t class.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #include "connection_test.h"
24
25 #include <config/connections/connection.h>
26 #include <crypto/prfs/prf.h>
27
28
29 /**
30 * Described in header.
31 */
32 void test_connection(protected_tester_t *tester)
33 {
34 host_t *alice = host_create(AF_INET, "192.168.0.1", 500);
35 host_t *bob = host_create(AF_INET, "192.168.0.2", 500);
36 identification_t *alice_id = identification_create_from_string("192.168.0.1");
37 identification_t *bob_id = identification_create_from_string("192.168.0.2");
38 connection_t *connection = connection_create(alice, bob, alice_id, bob_id, RSA_DIGITAL_SIGNATURE);
39 proposal_t *prop1, *prop2, *prop3, *prop4;
40 linked_list_t *list;
41
42 prop1 = proposal_create(1);
43 prop1->add_algorithm(prop1, PROTO_IKE, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 20);
44 prop1->add_algorithm(prop1, PROTO_IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
45 prop1->add_algorithm(prop1, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_SHA1, 20);
46 prop1->add_algorithm(prop1, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
47
48 prop2 = proposal_create(2);
49 prop2->add_algorithm(prop2, PROTO_IKE, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 20);
50 prop2->add_algorithm(prop2, PROTO_IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
51 prop2->add_algorithm(prop2, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_MD5, 20);
52 prop2->add_algorithm(prop2, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
53
54 prop3 = proposal_create(3);
55 prop3->add_algorithm(prop3, PROTO_IKE, ENCRYPTION_ALGORITHM, ENCR_DES, 20);
56 prop3->add_algorithm(prop3, PROTO_IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
57 prop3->add_algorithm(prop3, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_MD5, 20);
58 prop3->add_algorithm(prop3, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_768_BIT, 0);
59
60 prop4 = proposal_create(4);
61 prop4->add_algorithm(prop4, PROTO_IKE, ENCRYPTION_ALGORITHM, ENCR_3DES, 20);
62 prop4->add_algorithm(prop4, PROTO_IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 20);
63 prop4->add_algorithm(prop4, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_TIGER, 20);
64 prop4->add_algorithm(prop4, PROTO_IKE, DIFFIE_HELLMAN_GROUP, MODP_768_BIT, 0);
65
66 connection->add_proposal(connection, prop1);
67 connection->add_proposal(connection, prop2);
68 connection->add_proposal(connection, prop3);
69 connection->add_proposal(connection, prop4);
70
71 list = connection->get_proposals(connection);
72
73 tester->assert_true(tester,(list->get_count(list) == 4), "proposal count check ");
74
75
76 /* going to check proposals */
77 /* TODO test?*/
78
79 list->destroy(list);
80
81 connection->destroy(connection);
82 }