]> git.ipfire.org Git - people/ms/strongswan.git/blame - Source/charon/config/configuration_manager.c
- fixed socket code, so we know on which address we receive traffic
[people/ms/strongswan.git] / Source / charon / config / configuration_manager.c
CommitLineData
ea27eadf 1/**
b66cb987 2 * @file configuration_manager.c
ea27eadf 3 *
b66cb987 4 * @brief Implementation of configuration_manager_t.
ea27eadf
MW
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 <stdlib.h>
24
25#include "configuration_manager.h"
26
27#include <types.h>
0e96f7d8 28#include <daemon.h>
ea27eadf 29#include <utils/allocator.h>
ea27eadf 30
aebb38a0
JH
31
32typedef struct preshared_secret_entry_t preshared_secret_entry_t;
33
34/**
b66cb987 35 * A preshared secret entry combines an identifier and a
aebb38a0
JH
36 * preshared secret.
37 */
38struct preshared_secret_entry_t {
39
40 /**
41 * Identification.
42 */
43 identification_t *identification;
44
45 /**
b66cb987 46 * Preshared secret as chunk_t. The NULL termination is not included.
aebb38a0
JH
47 */
48 chunk_t preshared_secret;
49};
50
8ff8c33d
MW
51
52typedef struct rsa_private_key_entry_t rsa_private_key_entry_t;
53
54/**
55 * Entry for a rsa private key.
56 */
57struct rsa_private_key_entry_t {
58
59 /**
60 * Identification.
61 */
62 identification_t *identification;
63
64 /**
b66cb987 65 * Private key.
8ff8c33d
MW
66 */
67 rsa_private_key_t* private_key;
68};
69
70typedef struct rsa_public_key_entry_t rsa_public_key_entry_t;
71
72/**
73 * Entry for a rsa private key.
74 */
75struct rsa_public_key_entry_t {
76
77 /**
78 * Identification.
79 */
80 identification_t *identification;
81
82 /**
b66cb987 83 * Private key.
8ff8c33d
MW
84 */
85 rsa_public_key_t* public_key;
86};
87
a9428251 88typedef struct configuration_entry_t configuration_entry_t;
95c61cb9 89
a9428251
JH
90/* A configuration entry combines a configuration name with a init and sa
91 * configuration represented as init_config_t and sa_config_t objects.
b66cb987
JH
92 *
93 * @b Constructors:
94 * - configuration_entry_create()
ea27eadf 95 */
a9428251
JH
96struct configuration_entry_t {
97
ea27eadf 98 /**
a9428251
JH
99 * Configuration name.
100 *
ea27eadf 101 */
a9428251
JH
102 char *name;
103
104 /**
105 * Configuration for IKE_SA_INIT exchange.
106 */
107 init_config_t *init_config;
ea27eadf
MW
108
109 /**
a9428251 110 * Configuration for all phases after IKE_SA_INIT exchange.
ea27eadf 111 */
a9428251
JH
112 sa_config_t *sa_config;
113
114 /**
115 * Destroys a configuration_entry_t
116 *
a9428251
JH
117 * @param this calling object
118 */
119 void (*destroy) (configuration_entry_t *this);
ea27eadf
MW
120};
121
b66cb987
JH
122/**
123 * Implementation of configuration_entry_t.destroy.
124 */
a9428251
JH
125static void configuration_entry_destroy (configuration_entry_t *this)
126{
127 allocator_free(this->name);
128 allocator_free(this);
129}
130
ea27eadf 131/**
b66cb987 132 * @brief Creates a configuration_entry_t object.
a9428251
JH
133 *
134 * @param name name of the configuration entry (gets copied)
135 * @param init_config object of type init_config_t
136 * @param sa_config object of type sa_config_t
ea27eadf 137 */
a9428251 138configuration_entry_t * configuration_entry_create(char * name, init_config_t * init_config, sa_config_t * sa_config)
ea27eadf 139{
a9428251 140 configuration_entry_t *entry = allocator_alloc_thing(configuration_entry_t);
ea27eadf 141
a9428251
JH
142 /* functions */
143 entry->destroy = configuration_entry_destroy;
ea27eadf 144
a9428251
JH
145 /* private data */
146 entry->init_config = init_config;
147 entry->sa_config = sa_config;
148 entry->name = allocator_alloc(strlen(name) + 1);
149 strcpy(entry->name,name);
150 return entry;
ea27eadf
MW
151}
152
a9428251
JH
153typedef struct private_configuration_manager_t private_configuration_manager_t;
154
ea27eadf 155/**
b66cb987 156 * Private data of an configuration_manager_t object.
ea27eadf 157 */
a9428251
JH
158struct private_configuration_manager_t {
159
160 /**
b66cb987 161 * Public part of configuration_manager_t object.
a9428251
JH
162 */
163 configuration_manager_t public;
164
165 /**
166 * Holding all configurations.
167 */
168 linked_list_t *configurations;
169
170 /**
b66cb987 171 * Holding all managed init_configs.
a9428251
JH
172 */
173 linked_list_t *init_configs;
174
175 /**
b66cb987 176 * Holding all managed init_configs.
a9428251
JH
177 */
178 linked_list_t *sa_configs;
aebb38a0
JH
179
180 /**
b66cb987 181 * Holding all managed preshared secrets.
aebb38a0
JH
182 */
183 linked_list_t *preshared_secrets;
8ff8c33d
MW
184
185 /**
b66cb987 186 * Holding all managed private secrets.
8ff8c33d
MW
187 */
188 linked_list_t *rsa_private_keys;
189
190 /**
b66cb987 191 * Holding all managed public secrets.
8ff8c33d
MW
192 */
193 linked_list_t *rsa_public_keys;
a9428251
JH
194
195 /**
b66cb987 196 * Assigned logger_t object.
a9428251
JH
197 */
198 logger_t *logger;
0df63d6b 199
0df63d6b 200 /**
b66cb987
JH
201 * Max number of requests to be retransmitted.
202 * 0 for infinite.
0df63d6b
JH
203 */
204 u_int32_t max_retransmit_count;
205
206 /**
207 * First retransmit timeout in ms.
208 */
209 u_int32_t first_retransmit_timeout;
e314700c
JH
210
211 /**
212 * Timeout in ms after that time a IKE_SA gets deleted.
213 */
214 u_int32_t half_open_ike_sa_timeout;
a9428251
JH
215
216 /**
b66cb987 217 * Adds a new IKE_SA configuration.
ea27eadf 218 *
a9428251
JH
219 * @param this calling object
220 * @param name name for the configuration
221 * @param init_config init_config_t object
222 * @param sa_config sa_config_t object
ea27eadf 223 */
a9428251
JH
224 void (*add_new_configuration) (private_configuration_manager_t *this, char *name, init_config_t *init_config, sa_config_t *sa_config);
225
aebb38a0 226 /**
b66cb987 227 * Adds a new preshared secret.
aebb38a0 228 *
aebb38a0
JH
229 * @param this calling object
230 * @param type type of identification
231 * @param id_string identification as string
232 * @param preshared_secret preshared secret as string
233 */
234 void (*add_new_preshared_secret) (private_configuration_manager_t *this,id_type_t type, char *id_string, char *preshared_secret);
235
8ff8c33d 236 /**
b66cb987 237 * Adds a new rsa private key.
8ff8c33d 238 *
8ff8c33d
MW
239 * @param this calling object
240 * @param type type of identification
241 * @param id_string identification as string
b66cb987
JH
242 * @param key_pos location of key
243 * @param key_len length of key
8ff8c33d
MW
244 */
245 void (*add_new_rsa_private_key) (private_configuration_manager_t *this,id_type_t type, char *id_string, u_int8_t *key_pos, size_t key_len);
246
247 /**
b66cb987 248 * Adds a new rsa public key.
8ff8c33d 249 *
8ff8c33d
MW
250 * @param this calling object
251 * @param type type of identification
252 * @param id_string identification as string
b66cb987
JH
253 * @param key_pos location of key
254 * @param key_len length of key
8ff8c33d
MW
255 */
256 void (*add_new_rsa_public_key) (private_configuration_manager_t *this,id_type_t type, char *id_string, u_int8_t *key_pos, size_t key_len);
257
a9428251 258 /**
b66cb987 259 * Load default configuration.
a9428251
JH
260 *
261 * @param this calling object
262 */
263 void (*load_default_config) (private_configuration_manager_t *this);
264};
ea27eadf 265
b66cb987 266
8ff8c33d
MW
267u_int8_t public_key_1[];
268u_int8_t private_key_1[];
269u_int8_t public_key_2[];
270u_int8_t private_key_2[];
271
ea27eadf 272/**
a9428251 273 * Implementation of private_configuration_manager_t.load_default_config.
ea27eadf 274 */
a9428251 275static void load_default_config (private_configuration_manager_t *this)
ea27eadf 276{
409d0101 277 init_config_t *init_config_a, *init_config_b;
ce461bbd 278 proposal_t *proposal;
409d0101 279 sa_config_t *sa_config_a, *sa_config_b;
1b3f92d2 280 traffic_selector_t *ts;
ea27eadf 281
0a373aec
MW
282 init_config_a = init_config_create("192.168.0.2","192.168.0.3",IKEV2_UDP_PORT,IKEV2_UDP_PORT);
283 init_config_b = init_config_create("192.168.0.3","192.168.0.2",IKEV2_UDP_PORT,IKEV2_UDP_PORT);
a9428251 284
ce461bbd
MW
285 /* IKE proposals for alice */
286 proposal = proposal_create(1);
287 proposal->add_algorithm(proposal, IKE, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
30b5b412 288 proposal->add_algorithm(proposal, IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 0);
0a373aec 289 proposal->add_algorithm(proposal, IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 0);
30b5b412 290 proposal->add_algorithm(proposal, IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_MD5, 0);
ce461bbd
MW
291 proposal->add_algorithm(proposal, IKE, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
292 proposal->add_algorithm(proposal, IKE, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
293 init_config_a->add_proposal(init_config_a, proposal);
a9428251 294
ce461bbd
MW
295 /* IKE proposals for bob */
296 proposal = proposal_create(1);
297 proposal->add_algorithm(proposal, IKE, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
0a373aec
MW
298 proposal->add_algorithm(proposal, IKE, ENCRYPTION_ALGORITHM, ENCR_3DES, 0);
299 proposal->add_algorithm(proposal, IKE, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 0);
30b5b412 300 proposal->add_algorithm(proposal, IKE, PSEUDO_RANDOM_FUNCTION, PRF_HMAC_MD5, 0);
ce461bbd
MW
301 proposal->add_algorithm(proposal, IKE, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
302 init_config_b->add_proposal(init_config_b, proposal);
303
409d0101
MW
304 sa_config_a = sa_config_create(ID_IPV4_ADDR, "192.168.0.2",
305 ID_IPV4_ADDR, "192.168.0.3",
306 RSA_DIGITAL_SIGNATURE,
307 30000);
1b3f92d2 308
409d0101
MW
309 sa_config_b = sa_config_create(ID_IPV4_ADDR, "192.168.0.3",
310 ID_IPV4_ADDR, "192.168.0.2",
c06dbbab
MW
311 RSA_DIGITAL_SIGNATURE,
312 30000);
ce461bbd
MW
313
314 /* traffic selectors */
315 ts = traffic_selector_create_from_string(1, TS_IPV4_ADDR_RANGE, "0.0.0.0", 0, "255.255.255.255", 65535);
409d0101
MW
316 sa_config_a->add_traffic_selector_initiator(sa_config_a,ts);
317 sa_config_a->add_traffic_selector_responder(sa_config_a,ts);
409d0101
MW
318 sa_config_b->add_traffic_selector_initiator(sa_config_b,ts);
319 sa_config_b->add_traffic_selector_responder(sa_config_b,ts);
1b3f92d2
JH
320 ts->destroy(ts);
321
409d0101 322 /* child proposal for alice */
ce461bbd 323 proposal = proposal_create(1);
c06dbbab 324
30b5b412
MW
325// proposal->add_algorithm(proposal, AH, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 0);
326// proposal->add_algorithm(proposal, AH, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 0);
327// proposal->add_algorithm(proposal, AH, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
328// proposal->add_algorithm(proposal, AH, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
329// proposal->add_algorithm(proposal, AH, EXTENDED_SEQUENCE_NUMBERS, NO_EXT_SEQ_NUMBERS, 0);
ce461bbd
MW
330
331 proposal->add_algorithm(proposal, ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
30b5b412
MW
332 proposal->add_algorithm(proposal, ESP, ENCRYPTION_ALGORITHM, ENCR_3DES, 0);
333 proposal->add_algorithm(proposal, ESP, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 0);
334 proposal->add_algorithm(proposal, ESP, INTEGRITY_ALGORITHM, AUTH_HMAC_MD5_96, 0);
335 proposal->add_algorithm(proposal, ESP, DIFFIE_HELLMAN_GROUP, MODP_2048_BIT, 0);
ce461bbd
MW
336 proposal->add_algorithm(proposal, ESP, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
337 proposal->add_algorithm(proposal, ESP, EXTENDED_SEQUENCE_NUMBERS, NO_EXT_SEQ_NUMBERS, 0);
1b3f92d2 338
ce461bbd 339 sa_config_a->add_proposal(sa_config_a, proposal);
409d0101
MW
340
341 /* child proposal for bob */
ce461bbd 342 proposal = proposal_create(1);
409d0101 343
30b5b412
MW
344// proposal->add_algorithm(proposal, AH, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 0);
345// proposal->add_algorithm(proposal, AH, INTEGRITY_ALGORITHM, AUTH_AES_XCBC_96, 0);
346// proposal->add_algorithm(proposal, AH, INTEGRITY_ALGORITHM, AUTH_DES_MAC, 0);
347// proposal->add_algorithm(proposal, AH, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
348// proposal->add_algorithm(proposal, AH, EXTENDED_SEQUENCE_NUMBERS, NO_EXT_SEQ_NUMBERS, 0);
ce461bbd
MW
349
350 proposal->add_algorithm(proposal, ESP, ENCRYPTION_ALGORITHM, ENCR_AES_CBC, 16);
0a373aec 351 proposal->add_algorithm(proposal, ESP, INTEGRITY_ALGORITHM, AUTH_HMAC_SHA1_96, 0);
ce461bbd
MW
352 proposal->add_algorithm(proposal, ESP, DIFFIE_HELLMAN_GROUP, MODP_1024_BIT, 0);
353 proposal->add_algorithm(proposal, ESP, EXTENDED_SEQUENCE_NUMBERS, NO_EXT_SEQ_NUMBERS, 0);
409d0101 354
ce461bbd 355 sa_config_b->add_proposal(sa_config_b, proposal);
409d0101
MW
356
357
358
c06dbbab 359
409d0101
MW
360 this->add_new_configuration(this,"bob",init_config_a,sa_config_a);
361 this->add_new_configuration(this,"alice",init_config_b,sa_config_b);
6db4e80b 362
a9428251 363
c06dbbab 364 //this->add_new_preshared_secret(this,ID_IPV4_ADDR, "192.168.1.2","verschluesselt");
8ff8c33d 365
409d0101
MW
366 this->add_new_rsa_public_key(this,ID_IPV4_ADDR, "192.168.0.2", public_key_1, 256);
367 this->add_new_rsa_public_key(this,ID_IPV4_ADDR, "192.168.0.3", public_key_2, 256);
368 this->add_new_rsa_private_key(this,ID_IPV4_ADDR, "192.168.0.2", private_key_1, 1024);
369 this->add_new_rsa_private_key(this,ID_IPV4_ADDR, "192.168.0.3", private_key_2, 1024);
ea27eadf
MW
370}
371
372/**
a9428251 373 * Implementation of configuration_manager_t.get_init_config_for_host.
ea27eadf 374 */
a9428251 375static status_t get_init_config_for_host (private_configuration_manager_t *this, host_t *my_host, host_t *other_host,init_config_t **init_config)
ea27eadf 376{
a9428251
JH
377 iterator_t *iterator;
378 status_t status = NOT_FOUND;
ea27eadf 379
a9428251 380 iterator = this->configurations->create_iterator(this->configurations,TRUE);
ea27eadf 381
aee3eb52 382 this->logger->log(this->logger, CONTROL|LEVEL1, "getting config for hosts %s - %s",
01de2f3c
MW
383 my_host->get_address(my_host), other_host->get_address(other_host));
384
a9428251
JH
385 while (iterator->has_next(iterator))
386 {
387 configuration_entry_t *entry;
388 host_t *config_my_host;
389 host_t *config_other_host;
390
391 iterator->current(iterator,(void **) &entry);
392
393 config_my_host = entry->init_config->get_my_host(entry->init_config);
394 config_other_host = entry->init_config->get_other_host(entry->init_config);
395
396 /* first check if ip is equal */
397 if(config_other_host->ip_is_equal(config_other_host,other_host))
398 {
aee3eb52 399 this->logger->log(this->logger, CONTROL|LEVEL2, "config entry with remote host %s",
01de2f3c 400 config_other_host->get_address(config_other_host));
a9428251
JH
401 /* could be right one, check my_host for default route*/
402 if (config_my_host->is_default_route(config_my_host))
403 {
404 *init_config = entry->init_config;
405 status = SUCCESS;
406 break;
407 }
408 /* check now if host informations are the same */
409 else if (config_my_host->ip_is_equal(config_my_host,my_host))
410 {
411 *init_config = entry->init_config;
412 status = SUCCESS;
413 break;
414 }
415
416 }
417 /* Then check for wildcard hosts!
418 * TODO
419 * actually its only checked if other host with default route can be found! */
420 else if (config_other_host->is_default_route(config_other_host))
421 {
422 /* could be right one, check my_host for default route*/
423 if (config_my_host->is_default_route(config_my_host))
424 {
425 *init_config = entry->init_config;
426 status = SUCCESS;
427 break;
428 }
429 /* check now if host informations are the same */
430 else if (config_my_host->ip_is_equal(config_my_host,my_host))
431 {
432 *init_config = entry->init_config;
433 status = SUCCESS;
434 break;
435 }
436 }
437 }
ea27eadf 438
a9428251 439 iterator->destroy(iterator);
ea27eadf 440
a9428251
JH
441 return status;
442}
5e99853c 443
a9428251
JH
444/**
445 * Implementation of configuration_manager_t.get_init_config_for_name.
446 */
447static status_t get_init_config_for_name (private_configuration_manager_t *this, char *name, init_config_t **init_config)
448{
449 iterator_t *iterator;
450 status_t status = NOT_FOUND;
ea27eadf 451
a9428251 452 iterator = this->configurations->create_iterator(this->configurations,TRUE);
ea27eadf 453
a9428251
JH
454 while (iterator->has_next(iterator))
455 {
456 configuration_entry_t *entry;
457 iterator->current(iterator,(void **) &entry);
5e99853c 458
a9428251
JH
459 if (strcmp(entry->name,name) == 0)
460 {
5e99853c 461
a9428251
JH
462 /* found configuration */
463 *init_config = entry->init_config;
464 status = SUCCESS;
465 break;
466 }
467 }
ea27eadf 468
a9428251 469 iterator->destroy(iterator);
ea27eadf 470
a9428251 471 return status;
ea27eadf
MW
472}
473
474/**
a9428251 475 * Implementation of configuration_manager_t.get_sa_config_for_name.
ea27eadf 476 */
a9428251 477static status_t get_sa_config_for_name (private_configuration_manager_t *this, char *name, sa_config_t **sa_config)
ea27eadf 478{
a9428251
JH
479 iterator_t *iterator;
480 status_t status = NOT_FOUND;
481
482 iterator = this->configurations->create_iterator(this->configurations,TRUE);
ea27eadf 483
a9428251 484 while (iterator->has_next(iterator))
ea27eadf 485 {
a9428251
JH
486 configuration_entry_t *entry;
487 iterator->current(iterator,(void **) &entry);
488
489 if (strcmp(entry->name,name) == 0)
490 {
491 /* found configuration */
492 *sa_config = entry->sa_config;
493 status = SUCCESS;
494 break;
495 }
ea27eadf
MW
496 }
497
a9428251 498 iterator->destroy(iterator);
ea27eadf 499
a9428251 500 return status;
ea27eadf
MW
501}
502
503/**
a9428251 504 * Implementation of configuration_manager_t.get_sa_config_for_init_config_and_id.
ea27eadf 505 */
a9428251
JH
506static status_t get_sa_config_for_init_config_and_id (private_configuration_manager_t *this, init_config_t *init_config, identification_t *other_id, identification_t *my_id,sa_config_t **sa_config)
507{
508 iterator_t *iterator;
509 status_t status = NOT_FOUND;
510
511 iterator = this->configurations->create_iterator(this->configurations,TRUE);
512
513 while (iterator->has_next(iterator))
514 {
515 configuration_entry_t *entry;
516 iterator->current(iterator,(void **) &entry);
517
518 if (entry->init_config == init_config)
519 {
520 identification_t *config_my_id = entry->sa_config->get_my_id(entry->sa_config);
521 identification_t *config_other_id = entry->sa_config->get_other_id(entry->sa_config);
522
523 /* host informations seem to be the same */
524 if (config_other_id->equals(config_other_id,other_id))
525 {
526 /* other ids seems to match */
527
528 if (my_id == NULL)
529 {
530 /* first matching one is selected */
531
532 /* TODO priorize found entries */
533 *sa_config = entry->sa_config;
534 status = SUCCESS;
535 break;
536 }
537
538 if (config_my_id->equals(config_my_id,my_id))
539 {
540 *sa_config = entry->sa_config;
541 status = SUCCESS;
542 break;
543 }
544
545 }
546 }
547 }
548
549 iterator->destroy(iterator);
550
551 return status;
ea27eadf
MW
552}
553
554/**
a9428251 555 * Implementation of private_configuration_manager_t.add_new_configuration.
ea27eadf 556 */
a9428251 557static void add_new_configuration (private_configuration_manager_t *this, char *name, init_config_t *init_config, sa_config_t *sa_config)
ea27eadf 558{
a9428251
JH
559 iterator_t *iterator;
560 bool found;
ea27eadf 561
a9428251
JH
562 iterator = this->init_configs->create_iterator(this->init_configs,TRUE);
563 found = FALSE;
564 while (iterator->has_next(iterator))
565 {
566 init_config_t *found_init_config;
567 iterator->current(iterator,(void **) &found_init_config);
568 if (init_config == found_init_config)
569 {
570 found = TRUE;
571 break;
572 }
573 }
574 iterator->destroy(iterator);
575 if (!found)
ea27eadf 576 {
a9428251 577 this->init_configs->insert_first(this->init_configs,init_config);
ea27eadf 578 }
ea27eadf 579
a9428251
JH
580 iterator = this->sa_configs->create_iterator(this->sa_configs,TRUE);
581 found = FALSE;
582 while (iterator->has_next(iterator))
583 {
584 sa_config_t *found_sa_config;
585 iterator->current(iterator,(void **) &found_sa_config);
586 if (sa_config == found_sa_config)
587 {
588 found = TRUE;
589 break;
590 }
591 }
592 iterator->destroy(iterator);
593 if (!found)
594 {
595 this->sa_configs->insert_first(this->sa_configs,sa_config);
596 }
ea27eadf 597
6db4e80b 598 this->configurations->insert_last(this->configurations,configuration_entry_create(name,init_config,sa_config));
a9428251 599}
ea27eadf 600
aebb38a0
JH
601/**
602 * Implementation of private_configuration_manager_t.add_new_preshared_secret.
603 */
604static void add_new_preshared_secret (private_configuration_manager_t *this,id_type_t type, char *id_string, char *preshared_secret)
605{
606 preshared_secret_entry_t *entry = allocator_alloc_thing(preshared_secret_entry_t);
607
608 entry->identification = identification_create_from_string(type,id_string);
f6ba78c3 609 entry->preshared_secret.len = strlen(preshared_secret) + 1;
aebb38a0
JH
610 entry->preshared_secret.ptr = allocator_alloc(entry->preshared_secret.len);
611 memcpy(entry->preshared_secret.ptr,preshared_secret,entry->preshared_secret.len);
612
613 this->preshared_secrets->insert_last(this->preshared_secrets,entry);
614}
615
8ff8c33d
MW
616/**
617 * Implementation of private_configuration_manager_t.add_new_preshared_secret.
618 */
619static void add_new_rsa_public_key (private_configuration_manager_t *this, id_type_t type, char *id_string, u_int8_t* key_pos, size_t key_len)
620{
621 chunk_t key;
622 key.ptr = key_pos;
623 key.len = key_len;
624
625 rsa_public_key_entry_t *entry = allocator_alloc_thing(rsa_public_key_entry_t);
626
627 entry->identification = identification_create_from_string(type,id_string);
628 entry->public_key = rsa_public_key_create();
629 entry->public_key->set_key(entry->public_key, key);
630
631 this->rsa_public_keys->insert_last(this->rsa_public_keys, entry);
632}
633
634/**
635 * Implementation of private_configuration_manager_t.add_new_preshared_secret.
636 */
637static void add_new_rsa_private_key (private_configuration_manager_t *this, id_type_t type, char *id_string, u_int8_t* key_pos, size_t key_len)
638{
639 chunk_t key;
640 key.ptr = key_pos;
641 key.len = key_len;
642
643 rsa_private_key_entry_t *entry = allocator_alloc_thing(rsa_private_key_entry_t);
644
645 entry->identification = identification_create_from_string(type,id_string);
646 entry->private_key = rsa_private_key_create();
647 entry->private_key->set_key(entry->private_key, key);
648
649 this->rsa_private_keys->insert_last(this->rsa_private_keys, entry);
650}
aebb38a0
JH
651
652/**
653 * Implementation of configuration_manager_t.get_shared_secret.
654 */
655static status_t get_shared_secret(private_configuration_manager_t *this, identification_t *identification, chunk_t *preshared_secret)
656{
657 iterator_t *iterator;
658
659 iterator = this->preshared_secrets->create_iterator(this->preshared_secrets,TRUE);
660 while (iterator->has_next(iterator))
661 {
662 preshared_secret_entry_t *entry;
663 iterator->current(iterator,(void **) &entry);
664 if (entry->identification->equals(entry->identification,identification))
665 {
666 *preshared_secret = entry->preshared_secret;
667 iterator->destroy(iterator);
668 return SUCCESS;
669 }
670 }
671 iterator->destroy(iterator);
672 return NOT_FOUND;
673}
674
8ff8c33d
MW
675/**
676 * Implementation of configuration_manager_t.get_shared_secret.
677 */
678static status_t get_rsa_public_key(private_configuration_manager_t *this, identification_t *identification, rsa_public_key_t **public_key)
679{
680 iterator_t *iterator;
681
682 iterator = this->rsa_public_keys->create_iterator(this->rsa_public_keys,TRUE);
683 while (iterator->has_next(iterator))
684 {
685 rsa_public_key_entry_t *entry;
686 iterator->current(iterator,(void **) &entry);
687 if (entry->identification->equals(entry->identification,identification))
688 {
689 *public_key = entry->public_key;
690 iterator->destroy(iterator);
691 return SUCCESS;
692 }
693 }
694 iterator->destroy(iterator);
695 return NOT_FOUND;
696}
697
698/**
699 * Implementation of configuration_manager_t.get_shared_secret.
700 */
701static status_t get_rsa_private_key(private_configuration_manager_t *this, identification_t *identification, rsa_private_key_t **private_key)
702{
703 iterator_t *iterator;
704
705 iterator = this->rsa_private_keys->create_iterator(this->rsa_private_keys,TRUE);
706 while (iterator->has_next(iterator))
707 {
708 rsa_private_key_entry_t *entry;
709 iterator->current(iterator,(void **) &entry);
710 if (entry->identification->equals(entry->identification,identification))
711 {
712 *private_key = entry->private_key;
713 iterator->destroy(iterator);
714 return SUCCESS;
715 }
716 }
717 iterator->destroy(iterator);
718 return NOT_FOUND;
719}
720
aebb38a0 721/**
e314700c 722 * Implementation of configuration_manager_t.get_retransmit_timeout.
aebb38a0 723 */
0df63d6b
JH
724static status_t get_retransmit_timeout (private_configuration_manager_t *this, u_int32_t retransmit_count, u_int32_t *timeout)
725{
e9c0ca15 726 int new_timeout = this->first_retransmit_timeout, i;
0df63d6b
JH
727 if ((retransmit_count > this->max_retransmit_count) && (this->max_retransmit_count != 0))
728 {
729 return FAILED;
730 }
731
e9c0ca15
JH
732
733 for (i = 0; i < retransmit_count; i++)
734 {
735 new_timeout *= 2;
736 }
737
738 *timeout = new_timeout;
0df63d6b
JH
739
740 return SUCCESS;
741}
742
e314700c
JH
743/**
744 * Implementation of configuration_manager_t.get_half_open_ike_sa_timeout.
745 */
746static u_int32_t get_half_open_ike_sa_timeout (private_configuration_manager_t *this)
747{
748 return this->half_open_ike_sa_timeout;
749}
750
ea27eadf 751/**
a9428251 752 * Implementation of configuration_manager_t.destroy.
ea27eadf 753 */
a9428251 754static void destroy(private_configuration_manager_t *this)
ea27eadf 755{
aee3eb52 756 this->logger->log(this->logger,CONTROL | LEVEL1, "Going to destroy configuration manager ");
a9428251 757
aee3eb52 758 this->logger->log(this->logger,CONTROL | LEVEL2, "Destroy configuration entries");
a9428251
JH
759 while (this->configurations->get_count(this->configurations) > 0)
760 {
761 configuration_entry_t *entry;
762 this->configurations->remove_first(this->configurations,(void **) &entry);
763 entry->destroy(entry);
764 }
a9428251 765 this->configurations->destroy(this->configurations);
b66cb987 766
aee3eb52 767 this->logger->log(this->logger,CONTROL | LEVEL2, "Destroy sa_config_t objects");
a9428251
JH
768 while (this->sa_configs->get_count(this->sa_configs) > 0)
769 {
770 sa_config_t *sa_config;
771 this->sa_configs->remove_first(this->sa_configs,(void **) &sa_config);
1b3f92d2 772 sa_config->destroy(sa_config);
a9428251
JH
773 }
774
775 this->sa_configs->destroy(this->sa_configs);
776
aee3eb52 777 this->logger->log(this->logger,CONTROL | LEVEL2, "Destroy init_config_t objects");
a9428251
JH
778 while (this->init_configs->get_count(this->init_configs) > 0)
779 {
780 init_config_t *init_config;
781 this->init_configs->remove_first(this->init_configs,(void **) &init_config);
782 init_config->destroy(init_config);
783 }
784 this->init_configs->destroy(this->init_configs);
ea27eadf 785
aebb38a0
JH
786 while (this->preshared_secrets->get_count(this->preshared_secrets) > 0)
787 {
788 preshared_secret_entry_t *entry;
789 this->preshared_secrets->remove_first(this->preshared_secrets,(void **) &entry);
790 entry->identification->destroy(entry->identification);
791 allocator_free_chunk(&(entry->preshared_secret));
792 allocator_free(entry);
793 }
794 this->preshared_secrets->destroy(this->preshared_secrets);
b66cb987 795
aee3eb52 796 this->logger->log(this->logger,CONTROL | LEVEL2, "Destroy rsa private keys");
8ff8c33d
MW
797 while (this->rsa_private_keys->get_count(this->rsa_private_keys) > 0)
798 {
799 rsa_private_key_entry_t *entry;
800 this->rsa_private_keys->remove_first(this->rsa_private_keys,(void **) &entry);
801 entry->identification->destroy(entry->identification);
802 entry->private_key->destroy(entry->private_key);
803 allocator_free(entry);
804 }
805 this->rsa_private_keys->destroy(this->rsa_private_keys);
b66cb987 806
aee3eb52 807 this->logger->log(this->logger,CONTROL | LEVEL2, "Destroy rsa public keys");
8ff8c33d
MW
808 while (this->rsa_public_keys->get_count(this->rsa_public_keys) > 0)
809 {
810 rsa_public_key_entry_t *entry;
811 this->rsa_public_keys->remove_first(this->rsa_public_keys,(void **) &entry);
812 entry->identification->destroy(entry->identification);
813 entry->public_key->destroy(entry->public_key);
814 allocator_free(entry);
815 }
816 this->rsa_public_keys->destroy(this->rsa_public_keys);
aebb38a0 817
aee3eb52 818 this->logger->log(this->logger,CONTROL | LEVEL2, "Destroy assigned logger");
0e96f7d8 819 charon->logger_manager->destroy_logger(charon->logger_manager,this->logger);
ea27eadf 820 allocator_free(this);
ea27eadf
MW
821}
822
823/*
824 * Described in header-file
825 */
e314700c 826configuration_manager_t *configuration_manager_create(u_int32_t first_retransmit_timeout,u_int32_t max_retransmit_count, u_int32_t half_open_ike_sa_timeout)
ea27eadf
MW
827{
828 private_configuration_manager_t *this = allocator_alloc_thing(private_configuration_manager_t);
ea27eadf
MW
829
830 /* public functions */
a9428251
JH
831 this->public.destroy = (void(*)(configuration_manager_t*))destroy;
832 this->public.get_init_config_for_name = (status_t (*) (configuration_manager_t *, char *, init_config_t **)) get_init_config_for_name;
833 this->public.get_init_config_for_host = (status_t (*) (configuration_manager_t *, host_t *, host_t *,init_config_t **)) get_init_config_for_host;
834 this->public.get_sa_config_for_name =(status_t (*) (configuration_manager_t *, char *, sa_config_t **)) get_sa_config_for_name;
835 this->public.get_sa_config_for_init_config_and_id =(status_t (*) (configuration_manager_t *, init_config_t *, identification_t *, identification_t *,sa_config_t **)) get_sa_config_for_init_config_and_id;
0df63d6b 836 this->public.get_retransmit_timeout = (status_t (*) (configuration_manager_t *, u_int32_t retransmit_count, u_int32_t *timeout))get_retransmit_timeout;
e314700c 837 this->public.get_half_open_ike_sa_timeout = (u_int32_t (*) (configuration_manager_t *)) get_half_open_ike_sa_timeout;
aebb38a0 838 this->public.get_shared_secret = (status_t (*) (configuration_manager_t *, identification_t *, chunk_t *))get_shared_secret;
8ff8c33d
MW
839 this->public.get_rsa_private_key = (status_t (*) (configuration_manager_t *, identification_t *, rsa_private_key_t**))get_rsa_private_key;
840 this->public.get_rsa_public_key = (status_t (*) (configuration_manager_t *, identification_t *, rsa_public_key_t**))get_rsa_public_key;
a9428251
JH
841
842 /* private functions */
843 this->load_default_config = load_default_config;
844 this->add_new_configuration = add_new_configuration;
aebb38a0 845 this->add_new_preshared_secret = add_new_preshared_secret;
8ff8c33d
MW
846 this->add_new_rsa_public_key = add_new_rsa_public_key;
847 this->add_new_rsa_private_key = add_new_rsa_private_key;
a9428251 848
ea27eadf 849 /* private variables */
0e96f7d8 850 this->logger = charon->logger_manager->create_logger(charon->logger_manager,CONFIGURATION_MANAGER,NULL);
a9428251
JH
851 this->configurations = linked_list_create();
852 this->sa_configs = linked_list_create();
853 this->init_configs = linked_list_create();
aebb38a0 854 this->preshared_secrets = linked_list_create();
8ff8c33d
MW
855 this->rsa_private_keys = linked_list_create();
856 this->rsa_public_keys = linked_list_create();
0df63d6b
JH
857 this->max_retransmit_count = max_retransmit_count;
858 this->first_retransmit_timeout = first_retransmit_timeout;
e314700c 859 this->half_open_ike_sa_timeout = half_open_ike_sa_timeout;
a9428251
JH
860
861 this->load_default_config(this);
ea27eadf 862
ea27eadf
MW
863 return (&this->public);
864}
8ff8c33d
MW
865
866
8ff8c33d
MW
867u_int8_t public_key_1[] = {
868 0xD4,0x8D,0x40,0x8E,0xBD,0xFC,0x6D,0xE9,0xDB,0x1C,0xD2,0x21,0x19,0x37,0x6B,0xE2,
869 0xDC,0xCE,0x74,0xA2,0x63,0xF6,0xD8,0x8D,0xAF,0x1C,0xC0,0xFF,0x07,0x3F,0xFB,0x52,
870 0x59,0x45,0x01,0x10,0x35,0xA9,0xB8,0x16,0x69,0x31,0x19,0x4F,0xDD,0x66,0xAD,0xAC,
871 0x80,0x11,0x33,0x38,0x5A,0x11,0xF9,0x33,0x3F,0xD2,0x41,0x4A,0x21,0x9B,0x54,0x44,
872 0x00,0xB6,0x07,0x33,0x4A,0x5B,0x4E,0x09,0x7C,0x9D,0xB8,0xDE,0x6B,0xA2,0xB2,0x78,
873 0x23,0x3D,0xF0,0xB7,0x37,0x2B,0x7A,0x71,0x50,0x6E,0xEA,0x93,0x3E,0xB5,0x2C,0xBD,
874 0xD6,0x08,0x43,0x12,0x0A,0xE8,0x8D,0xE6,0x6C,0x24,0xCC,0x3F,0xF7,0x18,0x7E,0x87,
875 0x59,0x0C,0xA9,0x5D,0x85,0xF8,0x6E,0x83,0xD8,0x18,0x77,0x07,0xB6,0x44,0x3C,0x8D,
876 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
877 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
878 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
879 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
880 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
881 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
882 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
883 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01
884};
885
886u_int8_t private_key_1[] = {
887 0xD4,0x8D,0x40,0x8E,0xBD,0xFC,0x6D,0xE9,0xDB,0x1C,0xD2,0x21,0x19,0x37,0x6B,0xE2,
888 0xDC,0xCE,0x74,0xA2,0x63,0xF6,0xD8,0x8D,0xAF,0x1C,0xC0,0xFF,0x07,0x3F,0xFB,0x52,
889 0x59,0x45,0x01,0x10,0x35,0xA9,0xB8,0x16,0x69,0x31,0x19,0x4F,0xDD,0x66,0xAD,0xAC,
890 0x80,0x11,0x33,0x38,0x5A,0x11,0xF9,0x33,0x3F,0xD2,0x41,0x4A,0x21,0x9B,0x54,0x44,
891 0x00,0xB6,0x07,0x33,0x4A,0x5B,0x4E,0x09,0x7C,0x9D,0xB8,0xDE,0x6B,0xA2,0xB2,0x78,
892 0x23,0x3D,0xF0,0xB7,0x37,0x2B,0x7A,0x71,0x50,0x6E,0xEA,0x93,0x3E,0xB5,0x2C,0xBD,
893 0xD6,0x08,0x43,0x12,0x0A,0xE8,0x8D,0xE6,0x6C,0x24,0xCC,0x3F,0xF7,0x18,0x7E,0x87,
894 0x59,0x0C,0xA9,0x5D,0x85,0xF8,0x6E,0x83,0xD8,0x18,0x77,0x07,0xB6,0x44,0x3C,0x8D,
895 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
896 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
897 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
898 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
899 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
900 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
901 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
902 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,
903 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
904 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
905 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
906 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
907 0xEE,0xF2,0x37,0xF2,0x98,0xEB,0x33,0xC6,0x84,0xE8,0xB9,0xD1,0x18,0xB5,0x29,0x00,
908 0xAC,0x6B,0x78,0xBC,0x9E,0xB6,0x01,0x21,0x29,0xEE,0x4A,0x99,0xFB,0x3D,0x07,0x23,
909 0x77,0x84,0x93,0x4B,0x53,0x49,0xB0,0xA4,0x6F,0xB0,0xF5,0x50,0xDB,0x35,0xDD,0xDF,
910 0x41,0x6F,0x7B,0xA9,0x88,0x3D,0x0B,0x1C,0x2E,0x2B,0x44,0x35,0x24,0x72,0x66,0xC1,
911 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
912 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
913 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
914 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
915 0xE3,0xB8,0xC8,0x30,0x67,0xD0,0x5D,0xF1,0x32,0x64,0xDC,0x4B,0xB3,0x7E,0xE3,0x1A,
916 0xC5,0xBC,0xAC,0xC9,0x95,0x5C,0x96,0x0D,0x5A,0x52,0x90,0xE0,0x08,0x3F,0xA6,0x71,
917 0xC7,0x18,0xC5,0x64,0xA2,0xE4,0xB8,0x43,0x5A,0x8A,0x7A,0x9B,0xDF,0xDA,0x81,0x85,
918 0x6C,0x0F,0xA4,0xC9,0xAC,0x25,0x19,0x54,0xFE,0x75,0xAA,0x1D,0x22,0xB8,0xF4,0xCD,
919 0x1A,0x91,0xC2,0xA3,0x65,0x3F,0xD7,0xFC,0x7E,0xE1,0x92,0x29,0xC5,0x85,0x6E,0x44,
920 0xC8,0x4D,0xBD,0x7A,0x2C,0x2D,0x47,0xE2,0x24,0x24,0xDF,0xC2,0x31,0x65,0x8F,0xD4,
921 0xBA,0x28,0x7C,0x4A,0xCA,0xAE,0x79,0xBE,0xC1,0x6C,0xFC,0x09,0x45,0xF7,0x87,0x17,
922 0xB4,0x55,0x92,0x15,0xC5,0xFA,0x8F,0xB0,0x56,0x96,0xC1,0x87,0x12,0xFE,0xDF,0xF0,
923 0x3A,0xE1,0xB1,0x83,0x19,0x74,0xF0,0x7D,0x37,0x41,0x3E,0x6A,0xFE,0x33,0x3E,0x74,
924 0x01,0x45,0xE4,0x65,0xAE,0xC9,0xAE,0x64,0xE3,0xF1,0x90,0xFD,0x1A,0x30,0x44,0x82,
925 0xEE,0x34,0x94,0xF2,0x68,0x3D,0x61,0x90,0xFB,0xEB,0xD8,0x18,0xE6,0x7C,0xEC,0x69,
926 0x70,0xD0,0xEB,0x2F,0xC1,0x3D,0x9C,0x6A,0x4B,0x89,0x50,0x6B,0x3F,0xA5,0x38,0x41,
927 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
928 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
929 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
930 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
931 0x65,0xEE,0x34,0x09,0xAC,0x4C,0x21,0x71,0x1D,0x3F,0x7E,0x0D,0x01,0xC2,0x3E,0x34,
932 0x88,0x58,0xEC,0x4F,0x62,0x50,0xF7,0xD8,0x62,0xDF,0xC1,0x39,0x40,0xA0,0xBF,0x0B,
933 0xD5,0x2F,0x5B,0xFA,0x35,0x14,0x69,0x63,0x2C,0x36,0x4B,0xDF,0xEB,0x33,0x66,0x6B,
934 0x97,0xA9,0x6C,0x12,0x5D,0x08,0xD5,0x55,0x77,0x28,0x83,0xD7,0x3B,0xAE,0x05,0xC1,
935 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
936 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
937 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
938 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
939 0x9F,0x96,0x17,0x75,0x14,0xCB,0xC9,0x8A,0x06,0xAE,0xF8,0x53,0x74,0xEF,0x2F,0x68,
940 0xCB,0xBA,0x75,0xBC,0xAF,0x97,0xBA,0xF0,0x90,0xA3,0xDC,0x33,0xA4,0x94,0x36,0xA8,
941 0xF5,0xC6,0x3E,0x4F,0x50,0x78,0xC9,0x49,0x2A,0x62,0x71,0x9A,0x5B,0x3E,0x5E,0x16,
942 0x8A,0xAC,0x4B,0xE7,0xA9,0x64,0x36,0x64,0x82,0x0F,0x23,0xB0,0x57,0x6D,0x16,0xE1,
943 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
944 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
945 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
946 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
947 0x25,0xF1,0x40,0x05,0x58,0x19,0x37,0x61,0x34,0x98,0xBB,0x29,0x1B,0x44,0x08,0x1A,
948 0xD3,0x66,0x62,0x4C,0x9C,0x47,0xD2,0x91,0x60,0x46,0x6F,0x8E,0xA6,0xE7,0x80,0x7B,
949 0x17,0x77,0x9A,0xB5,0x18,0x8A,0x15,0x8F,0x77,0xA1,0x55,0x3E,0x96,0x66,0x86,0x57,
950 0x75,0x73,0xF5,0x57,0x50,0x28,0xEA,0x83,0x14,0xB1,0x55,0xA3,0x82,0xCD,0x36,0xF8
951};
952u_int8_t public_key_2[] = {
953 0x88,0x3E,0xE2,0x2E,0x5D,0x01,0x13,0xDF,0x1D,0x8B,0xF4,0x39,0xCA,0xE6,0x3C,0xE1,
954 0x46,0x8E,0xD4,0xF1,0x06,0x56,0x12,0x8D,0xCD,0x51,0xBD,0x32,0xF5,0x18,0x15,0x4D,
955 0x0F,0x98,0xDF,0xFF,0xA5,0xA3,0xAB,0x39,0x43,0xC4,0xF6,0xAC,0x98,0x5C,0x84,0x63,
956 0x8C,0x46,0x33,0xA2,0x23,0x8C,0xF0,0x4D,0xFE,0xE7,0xF3,0x38,0xC4,0x19,0x39,0xC4,
957 0x90,0xF4,0xC8,0x0D,0xB0,0xFE,0x65,0x11,0x0B,0x41,0x73,0xBB,0x05,0xA6,0x4B,0xC5,
958 0x27,0xA4,0x48,0x21,0xC5,0xAE,0x91,0x9C,0xD8,0x62,0x27,0xBE,0xDF,0xDA,0xC6,0x4E,
959 0xC1,0x6E,0x5B,0x61,0x51,0xAA,0xC9,0x53,0xCD,0x02,0x5B,0xC5,0xEE,0xE9,0xC7,0x7B,
960 0xB1,0x7E,0xD2,0xC2,0xFE,0x5F,0xD7,0x0F,0x75,0x2B,0xB9,0x49,0x5F,0x35,0xF1,0x83,
961 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
962 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
963 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
964 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
965 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
966 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
967 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
968 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01
969};
970u_int8_t private_key_2[] = {
971 0x88,0x3E,0xE2,0x2E,0x5D,0x01,0x13,0xDF,0x1D,0x8B,0xF4,0x39,0xCA,0xE6,0x3C,0xE1,
972 0x46,0x8E,0xD4,0xF1,0x06,0x56,0x12,0x8D,0xCD,0x51,0xBD,0x32,0xF5,0x18,0x15,0x4D,
973 0x0F,0x98,0xDF,0xFF,0xA5,0xA3,0xAB,0x39,0x43,0xC4,0xF6,0xAC,0x98,0x5C,0x84,0x63,
974 0x8C,0x46,0x33,0xA2,0x23,0x8C,0xF0,0x4D,0xFE,0xE7,0xF3,0x38,0xC4,0x19,0x39,0xC4,
975 0x90,0xF4,0xC8,0x0D,0xB0,0xFE,0x65,0x11,0x0B,0x41,0x73,0xBB,0x05,0xA6,0x4B,0xC5,
976 0x27,0xA4,0x48,0x21,0xC5,0xAE,0x91,0x9C,0xD8,0x62,0x27,0xBE,0xDF,0xDA,0xC6,0x4E,
977 0xC1,0x6E,0x5B,0x61,0x51,0xAA,0xC9,0x53,0xCD,0x02,0x5B,0xC5,0xEE,0xE9,0xC7,0x7B,
978 0xB1,0x7E,0xD2,0xC2,0xFE,0x5F,0xD7,0x0F,0x75,0x2B,0xB9,0x49,0x5F,0x35,0xF1,0x83,
979 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
980 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
981 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
982 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
983 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
984 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
985 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
986 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,
987 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
988 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
989 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
990 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
991 0xE8,0x37,0xB6,0x08,0xD8,0x9C,0x72,0xC5,0x34,0xDB,0x3A,0xA2,0xF9,0x24,0xE1,0x44,
992 0x23,0x3B,0x72,0x70,0x5D,0xCC,0xC3,0xBA,0x3D,0xCE,0x82,0xAC,0x6A,0x71,0x72,0x90,
993 0xC7,0x94,0xB3,0x8B,0x85,0xE0,0xEF,0x39,0xF0,0xE4,0x08,0x31,0xEA,0xE6,0x3B,0x7D,
994 0xB0,0x36,0xFA,0x71,0x6E,0xA3,0xF9,0x4C,0x39,0x05,0x8C,0xB7,0x8C,0x99,0x94,0x85,
995 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
996 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
997 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
998 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
999 0x96,0x32,0xF9,0xD9,0xA8,0xC0,0x84,0xFD,0xE5,0x6B,0xA6,0xC2,0x85,0x85,0x68,0x17,
1000 0x7E,0x98,0xD0,0x6A,0xDC,0xD8,0x4C,0x46,0xCB,0x6D,0x4C,0x25,0xE5,0xF9,0x58,0xB2,
1001 0x17,0xE4,0x20,0x8A,0x87,0x0D,0xD7,0x4C,0x79,0xA3,0xB3,0x69,0x98,0x7F,0x5D,0x08,
1002 0x33,0x5B,0xAD,0xA3,0x34,0xE8,0x55,0x5E,0x09,0x60,0x70,0xA8,0x11,0xFD,0x70,0x67,
1003 0x00,0xE1,0xA7,0x44,0xF5,0x85,0x14,0x43,0xD5,0x45,0x1A,0x87,0x65,0x30,0xA8,0x24,
1004 0x2C,0xF8,0xAF,0x97,0xFF,0x9A,0x7E,0xF4,0x3B,0xE7,0xD3,0x79,0x88,0xEC,0x66,0xF6,
1005 0xE0,0xAA,0xF4,0x88,0x0A,0xE2,0x4C,0x31,0x4A,0xA6,0xF3,0x91,0x9A,0x4A,0xBE,0xF0,
1006 0x85,0xEF,0xCE,0x55,0xB6,0x35,0x2B,0x38,0xD5,0xF5,0x5A,0x35,0x7B,0xCF,0x4D,0xF8,
1007 0x5D,0x1E,0x57,0x99,0xAF,0xED,0x33,0x6F,0xD5,0xA7,0x49,0x5B,0x14,0x4C,0x7D,0x17,
1008 0x81,0xAE,0x1E,0xDA,0x9D,0xFB,0xA9,0xC3,0x00,0x4C,0x17,0x37,0x30,0x96,0x60,0xE1,
1009 0x6A,0xCC,0xD3,0xDB,0x40,0xCE,0x96,0x96,0x0D,0x95,0x0D,0x84,0x38,0xBD,0xDA,0x2F,
1010 0xEC,0xED,0x22,0x39,0x8E,0x8C,0xDF,0xCD,0x07,0xCF,0x0F,0xB0,0x2B,0x76,0xDB,0xC1,
1011 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1012 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1013 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1014 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1015 0xA5,0x37,0x9E,0x08,0x45,0x35,0x6A,0x62,0xEC,0xEC,0x5D,0x97,0xBE,0x73,0x82,0xE2,
1016 0x9B,0xBE,0x9B,0xF9,0x5E,0x83,0x65,0x6E,0x88,0xB2,0xF9,0x3D,0xFA,0xAD,0xA4,0xB9,
1017 0x65,0x86,0x63,0x08,0x0D,0xC4,0xAF,0xF0,0x25,0x77,0xD8,0x6C,0xCB,0x97,0xEB,0x13,
1018 0xCD,0xE0,0x0F,0xE7,0xCC,0xB4,0x55,0x96,0xE9,0xAB,0x0D,0x27,0x3A,0x9D,0xBA,0x91,
1019 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1020 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1021 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1022 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1023 0x44,0xA3,0x44,0xF4,0x47,0x9E,0xBA,0xE7,0xBF,0xF8,0xC2,0xFB,0x2F,0xC3,0x38,0x3F,
1024 0x4C,0x56,0x0F,0x20,0x56,0x8D,0xED,0xC5,0x88,0x5F,0x09,0x26,0x64,0x82,0xDF,0x1A,
1025 0x7B,0xBA,0x7F,0x78,0x6E,0xA1,0x4F,0x9B,0x1E,0x17,0x45,0xFC,0xE2,0x78,0x89,0x8E,
1026 0x1E,0xD2,0x2D,0x76,0x60,0xCE,0x2F,0x7C,0xCA,0xB2,0x2C,0xA9,0x51,0x97,0x4C,0xCF,
1027 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1028 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1029 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1030 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1031 0x01,0x40,0x4B,0x7D,0xAB,0x8A,0xB9,0x5E,0xEE,0xA1,0x81,0xED,0x27,0x89,0xF6,0x4C,
1032 0x59,0x8C,0x23,0x14,0x3B,0x1B,0xBA,0xC3,0xB2,0x00,0x9A,0x9E,0xDF,0x54,0x82,0xA7,
1033 0x3E,0xC9,0x23,0x85,0x4D,0xD3,0x80,0xA7,0x89,0x11,0xBA,0x76,0xF5,0xC1,0x55,0x37,
1034 0x0A,0x0D,0x8C,0x07,0x0A,0xC8,0xC5,0x11,0x74,0x9C,0xB6,0x80,0x3B,0x0A,0x9A,0xA2
1035};