1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
/**
* @file init_config.h
*
* @brief Interface of init_config_t.
*
*/
/*
* Copyright (C) 2005 Jan Hutter, Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#ifndef _INIT_CONFIG_H_
#define _INIT_CONFIG_H_
#include <types.h>
#include <network/host.h>
#include <utils/iterator.h>
#include <transforms/crypters/crypter.h>
#include <transforms/prfs/prf.h>
#include <transforms/signers/signer.h>
#include <transforms/diffie_hellman.h>
typedef struct ike_proposal_t ike_proposal_t;
/**
* Represents a Proposal used in IKE_SA_INIT phase.
*/
struct ike_proposal_t {
/**
* Encryption algorithm.
* */
encryption_algorithm_t encryption_algorithm;
/**
* Key length of encryption algorithm in bytes.
*/
u_int16_t encryption_algorithm_key_length;
/**
* Integrity algorithm.
*/
integrity_algorithm_t integrity_algorithm;
/**
* Key length of integrity algorithm
*/
u_int16_t integrity_algorithm_key_length;
/**
* Pseudo random function (prf).
*/
pseudo_random_function_t pseudo_random_function;
/**
* Key length of prf.
*/
u_int16_t pseudo_random_function_key_length;
/**
* Diffie hellman group.
*/
diffie_hellman_group_t diffie_hellman_group;
};
typedef struct init_config_t init_config_t;
/**
* Represents a configuration class holding all needed informations for IKE_SA_INIT phase.
*
* @ingroup config
*
*/
struct init_config_t {
/**
* Get my host information as host_t object.
*
* @warning Object is getting cloned and has to get destroyed by caller.
*
* @param this calling object
* @return host information as host_t object
*/
host_t * (*get_my_host) (init_config_t *this);
/**
* Get other host information as host_t object.
*
* @warning Object is getting cloned and has to get destroyed by caller.
*
* @param this calling object
* @return host information as host_t object
*/
host_t * (*get_other_host) (init_config_t *this);
/**
* Get the diffie hellman group to use as initiator with given priority.
*
*
* @param this calling object
* @param priority priority of dh group number (starting at 1)
* @return diffie hellman group number for given priority or
* MODP_UNDEFINED for not supported priorities
*/
diffie_hellman_group_t (*get_dh_group_number) (init_config_t *this,size_t priority);
/**
* Returns a list of all supported ike_proposals of type ike_proposal_t *.
*
* @warning array of ike_proposal_t has to get destroyed by the caller
*
* @param this calling object
* @param proposals first proposal in a array
* @return number of proposals in array
*/
size_t (*get_proposals) (init_config_t *this,ike_proposal_t **proposals);
/**
* Adds a proposal with given priority to the current stored proposals
*
* If allready a proposal with given priority is stored the other one is
* moved one priority back. If priority is higher then all other stored
* proposals, it is inserted as last one.
*
* @param this calling object
* @param priority priority of adding proposal
* @param proposal proposal to add
*/
void (*add_proposal) (init_config_t *this,size_t priority, ike_proposal_t proposal);
/**
* Select a proposed from suggested proposals.
*
*
* @param this calling object
* @param suggested_proposals first proposal in a array
* @param proposal_count number of suggested proposals in array
* @param selected_proposal the ike_proposal_t pointing to is set
* @return
* - SUCCESS if a proposal was selected
* - NOT_FOUND if none of suggested proposals is supported
*/
status_t (*select_proposal) (init_config_t *this, ike_proposal_t *proposals, size_t proposal_count, ike_proposal_t *selected_proposal);
/**
* Destroys a init_config_t object.
*
* @param this calling object
*/
void (*destroy) (init_config_t *this);
};
/**
* Creates a init_config_t object.
*
* @return pointer to created init_config_t object.
*
* @ingroup config
*/
init_config_t * init_config_create(char * my_ip, char *other_ip, u_int16_t my_port, u_int16_t other_port);
#endif //_INIT_CONFIG_H_
|