8c56672363bb95f0a457df37755ff2cfc79b1bfe
[strongswan.git] / Source / charon / ike_sa.c
1 /**
2 * @file ike_sa.c
3 *
4 * @brief Class ike_sa_t. An object of this type is managed by an
5 * ike_sa_manager_t object and represents an IKE_SA
6 *
7 */
8
9 /*
10 * Copyright (C) 2005 Jan Hutter, Martin Willi
11 * Hochschule fuer Technik Rapperswil
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 */
23
24 #include "ike_sa.h"
25
26 #include "types.h"
27 #include "globals.h"
28 #include "definitions.h"
29 #include "utils/allocator.h"
30 #include "utils/linked_list.h"
31 #include "utils/logger_manager.h"
32 #include "utils/randomizer.h"
33 #include "transforms/diffie_hellman.h"
34 #include "payloads/sa_payload.h"
35 #include "payloads/nonce_payload.h"
36 #include "payloads/ke_payload.h"
37 #include "payloads/transform_substructure.h"
38 #include "payloads/transform_attribute.h"
39
40
41 /**
42 *
43 * This implementation supports only window size 1
44 */
45 #define WINDOW_SIZE 1
46
47 /**
48 * States in which a IKE_SA can actually be
49 */
50 typedef enum ike_sa_state_e ike_sa_state_t;
51
52 enum ike_sa_state_e {
53
54 /**
55 * IKE_SA is is not in a state
56 */
57 NO_STATE = 1,
58
59 /**
60 * A IKE_SA_INIT-message was sent: role initiator
61 */
62 IKE_SA_INIT_REQUESTED = 2,
63
64 /**
65 * A IKE_SA_INIT-message was replied: role responder
66 */
67 IKE_SA_INIT_RESPONDED = 3,
68
69 /**
70 * An IKE_AUTH-message was sent after a successful
71 * IKE_SA_INIT-exchange: role initiator
72 */
73 IKE_AUTH_REQUESTED = 4,
74
75 /**
76 * An IKE_AUTH-message was replied: role responder.
77 * In this state, all the informations for an IKE_SA
78 * and one CHILD_SA are known.
79 */
80 IKE_SA_INITIALIZED = 5
81 };
82
83 /**
84 * string mappings for ike_sa_state
85 */
86 mapping_t ike_sa_state_m[] = {
87 {NO_STATE, "NO_STATE"},
88 {IKE_SA_INIT_REQUESTED, "IKE_SA_INIT_REQUESTED"},
89 {IKE_SA_INIT_RESPONDED, "IKE_SA_INIT_RESPONDED"},
90 {IKE_AUTH_REQUESTED, "IKE_AUTH_REQUESTED"},
91 {IKE_SA_INITIALIZED, "IKE_SA_INITIALIZED"},
92 {MAPPING_END, NULL}
93 };
94
95
96 /**
97 * Private data of an message_t object
98 */
99 typedef struct private_ike_sa_s private_ike_sa_t;
100
101 struct private_ike_sa_s {
102
103 /**
104 * Public part of a ike_sa_t object
105 */
106 ike_sa_t public;
107
108 status_t (*build_sa_payload) (private_ike_sa_t *this, sa_payload_t **payload);
109 status_t (*build_ke_payload) (private_ike_sa_t *this, ke_payload_t **payload);
110 status_t (*build_nonce_payload) (private_ike_sa_t *this, nonce_payload_t **payload);
111
112 status_t (*build_message) (private_ike_sa_t *this, exchange_type_t type, bool request, message_t **message);
113
114
115 status_t (*transto_ike_sa_init_requested) (private_ike_sa_t *this, char *name);
116 status_t (*transto_ike_sa_init_responded) (private_ike_sa_t *this, message_t *message);
117 status_t (*transto_ike_auth_requested) (private_ike_sa_t *this, message_t *message);
118
119 /* Private values */
120 /**
121 * Identifier for the current IKE_SA
122 */
123 ike_sa_id_t *ike_sa_id;
124
125 /**
126 * Linked List containing the child sa's of the current IKE_SA
127 */
128 linked_list_t *child_sas;
129
130 /**
131 * Current state of the IKE_SA
132 */
133 ike_sa_state_t state;
134
135 /**
136 * this SA's source for random data
137 */
138 randomizer_t *randomizer;
139
140 /**
141 * contains the last X responded messages
142 *
143 * X is windows size (here 1)
144 */
145 linked_list_t *responded_messages;
146
147 /**
148 * contains the last X requested messages
149 *
150 * X is windows size (here 1)
151 */
152 linked_list_t *requested_messages;
153
154 struct {
155 host_t *host;
156 } me;
157
158 struct {
159 host_t *host;
160 } other;
161
162
163 struct {
164 /**
165 * Diffie Hellman object used to compute shared secret
166 */
167 diffie_hellman_t *diffie_hellman;
168 /**
169 * Diffie Hellman group number
170 */
171 u_int16_t dh_group_number;
172
173 /**
174 * Priority used get matching dh_group number
175 */
176 u_int16_t dh_group_priority;
177 /**
178 *
179 */
180 chunk_t sent_nonce;
181 /**
182 *
183 */
184 chunk_t received_nonce;
185 } ike_sa_init_data;
186
187
188 /**
189 * next message id to receive
190 */
191 u_int32_t message_id_in;
192
193 /**
194 * next message id to send
195 */
196 u_int32_t message_id_out;
197
198 /**
199 * a logger for this IKE_SA
200 */
201 logger_t *logger;
202 };
203
204 /**
205 * @brief implements function process_message of private_ike_sa_t
206 */
207 static status_t process_message (private_ike_sa_t *this, message_t *message)
208 {
209 u_int32_t message_id;
210 bool is_request;
211 is_request = message->get_request(message);
212 this->logger->log(this->logger, CONTROL|MORE, "Process %s message of exchange type %s",(is_request) ? "REQUEST" : "RESPONSE",
213 mapping_find(exchange_type_m,message->get_exchange_type(message)));
214
215
216 //message->get_exchange_type(message);
217
218
219 switch (message->get_exchange_type(message))
220 {
221 case IKE_SA_INIT:
222 {
223 if (message->get_request(message)) {
224 if (this->state == NO_STATE)
225 {
226 /* state transission NO_STATE => IKE_SA_INIT_RESPONDED */
227 return this->transto_ike_sa_init_responded(this, message);
228 }
229 }
230 else
231 {
232 if (this->state == IKE_SA_INIT_REQUESTED)
233 {
234 /* state transission IKE_SA_INIT_REQUESTED => IKE_AUTH_REQUESTED*/
235 return this->transto_ike_auth_requested(this, message);
236 }
237 }
238 break;
239 }
240 case IKE_AUTH:
241 {
242 /* break; */
243 }
244 case CREATE_CHILD_SA:
245 {
246 /* break; */
247 }
248 case INFORMATIONAL:
249 {
250 /* break; */
251 }
252 default:
253 {
254 this->logger->log(this->logger, ERROR, "processing %s-message not supported.",
255 mapping_find(exchange_type_m,message->get_exchange_type(message)));
256 return NOT_SUPPORTED;
257 }
258 }
259 this->logger->log(this->logger, ERROR, "received %s-message in state %s, rejected.",
260 mapping_find(exchange_type_m, message->get_exchange_type(message)),
261 mapping_find(ike_sa_state_m, this->state));
262 return INVALID_STATE;
263 }
264
265
266 static status_t build_message(private_ike_sa_t *this, exchange_type_t type, bool request, message_t **message)
267 {
268 status_t status;
269 message_t *new_message;
270 host_t *source, *destination;
271
272 new_message = message_create();
273 if (new_message == NULL)
274 {
275 return OUT_OF_RES;
276 }
277
278 status = this->me.host->clone(this->me.host, &source);
279 status |= this->other.host->clone(this->other.host, &destination);
280 if (status != SUCCESS)
281 {
282 new_message->destroy(new_message);
283 return status;
284 }
285 new_message->set_source(new_message, source);
286 new_message->set_destination(new_message, destination);
287
288 new_message->set_exchange_type(new_message, type);
289 new_message->set_request(new_message, request);
290
291 if (request)
292 {
293 new_message->set_message_id(new_message, this->message_id_out);
294 }else
295 {
296 new_message->set_message_id(new_message, this->message_id_in);
297 }
298
299 new_message->set_ike_sa_id(new_message, this->ike_sa_id);
300
301 *message = new_message;
302
303 return SUCCESS;
304 }
305
306
307 static status_t transto_ike_sa_init_requested(private_ike_sa_t *this, char *name)
308 {
309 message_t *message;
310 payload_t *payload;
311 packet_t *packet;
312 status_t status;
313
314 this->logger->log(this->logger, CONTROL, "initializing connection");
315
316 status = global_configuration_manager->get_local_host(global_configuration_manager, name, &(this->me.host));
317 if (status != SUCCESS)
318 {
319 return INVALID_ARG;
320 }
321
322 status = global_configuration_manager->get_remote_host(global_configuration_manager, name, &(this->other.host));
323 if (status != SUCCESS)
324 {
325 return INVALID_ARG;
326 }
327
328 status = global_configuration_manager->get_dh_group_number(global_configuration_manager, name, &(this->ike_sa_init_data.dh_group_number), this->ike_sa_init_data.dh_group_priority);
329 if (status != SUCCESS)
330 {
331 return INVALID_ARG;
332 }
333
334 this ->logger->log(this->logger, CONTROL|MORE, "create diffie hellman object");
335 if (this->ike_sa_init_data.diffie_hellman != NULL)
336 {
337 this->logger->log(this->logger, ERROR, "Object of type diffie_hellman_t already existing!");
338 return FAILED;
339 }
340 this->ike_sa_init_data.diffie_hellman = diffie_hellman_create(this->ike_sa_init_data.dh_group_number);
341 if (this->ike_sa_init_data.diffie_hellman == NULL)
342 {
343 this->logger->log(this->logger, ERROR, "Object of type diffie_hellman_t could not be created!");
344 return FAILED;
345 }
346
347 if (this->ike_sa_init_data.sent_nonce.ptr != NULL)
348 {
349 this->logger->log(this->logger, ERROR, "Nonce for IKE_SA_INIT phase already existing!");
350 return FAILED;
351 }
352
353 if (this->randomizer->allocate_pseudo_random_bytes(this->randomizer, 16, &(this->ike_sa_init_data.sent_nonce)) != SUCCESS)
354 {
355 this->logger->log(this->logger, ERROR, "Could not create nonce!");
356 return OUT_OF_RES;
357 }
358
359
360 /* going to build message */
361
362 status = this->build_message(this, IKE_SA_INIT, TRUE, &message);
363 if (status != SUCCESS)
364 {
365 this->logger->log(this->logger, ERROR, "Could not build message");
366 return status;
367 }
368
369 /* build SA payload */
370 status = this->build_sa_payload(this, (sa_payload_t**)&payload);
371 if (status != SUCCESS)
372 {
373 this->logger->log(this->logger, ERROR, "Could not build SA payload");
374 message->destroy(message);
375 return status;
376 }
377 message->add_payload(message, payload);
378
379 /* build KE payload */
380 status = this->build_ke_payload(this,(ke_payload_t **) &payload);
381 if (status != SUCCESS)
382 {
383 this->logger->log(this->logger, ERROR, "Could not build KE payload");
384 message->destroy(message);
385 return status;
386 }
387 message->add_payload(message, payload);
388
389 /* build Nonce payload */
390 status = this->build_nonce_payload(this, (nonce_payload_t**)&payload);
391 if (status != SUCCESS)
392 {
393 this->logger->log(this->logger, ERROR, "Could not build NONCE payload");
394 message->destroy(message);
395 return status;
396 }
397 message->add_payload(message, payload);
398
399
400 status = message->generate(message, &packet);
401 if (status != SUCCESS)
402 {
403 this->logger->log(this->logger, ERROR, "Could not generate message");
404 message->destroy(message);
405 return status;
406 }
407
408 status = global_send_queue->add(global_send_queue, packet);
409 if (status != SUCCESS)
410 {
411 this->logger->log(this->logger, ERROR, "Could not add packet to send queue");
412 message->destroy(message);
413 return status;
414 }
415
416 if ( this->requested_messages->get_count(this->requested_messages) >= WINDOW_SIZE)
417 {
418 message_t *removed_message;
419 /* destroy message */
420 this->requested_messages->remove_last(this->requested_messages,(void **)&removed_message);
421 removed_message->destroy(removed_message);
422 }
423
424 status = this->requested_messages->insert_first(this->requested_messages,(void *) message);
425 if (status != SUCCESS)
426 {
427 this->logger->log(this->logger, ERROR, "Could not store last received message");
428 message->destroy(message);
429 return status;
430 }
431
432 /* message counter can now be increased */
433 this->message_id_out++;
434
435 /* states has NOW changed :-) */
436 this->state = IKE_SA_INIT_REQUESTED;
437
438 return SUCCESS;
439 }
440
441 static status_t transto_ike_sa_init_responded(private_ike_sa_t *this, message_t *message)
442 {
443 status_t status;
444 linked_list_iterator_t *payloads;
445 message_t *respond;
446
447 status = message->parse_body(message);
448 if (status != SUCCESS)
449 {
450 return status;
451 }
452
453
454
455
456
457 status = message->get_payload_iterator(message, &payloads);
458 if (status != SUCCESS)
459 {
460 respond->destroy(respond);
461 return status;
462 }
463 while (payloads->has_next(payloads))
464 {
465 payload_t *payload;
466 payloads->current(payloads, (void**)payload);
467 switch (payload->get_type(payload))
468 {
469 case SECURITY_ASSOCIATION:
470 {
471 sa_payload_t *sa_payload;
472 linked_list_iterator_t *proposals;
473
474 sa_payload = (sa_payload_t*)payload;
475 status = sa_payload->create_proposal_substructure_iterator(sa_payload, &proposals, TRUE);
476 if (status != SUCCESS)
477 {
478 payloads->destroy(payloads);
479 return status;
480 }
481 //global_configuration_manager->select_proposals_for_host
482
483 break;
484 }
485 case KEY_EXCHANGE:
486 {
487 break;
488 }
489 case NONCE:
490 {
491 break;
492 }
493 default:
494 {
495
496 }
497
498 }
499
500 }
501
502
503
504
505
506 /*
507 job_t *delete_job;
508 delete_job = (job_t *) delete_ike_sa_job_create(this->ike_sa_id);
509 if (delete_job == NULL)
510 {
511 this->logger->log(this->logger, ERROR, "Job to delete IKE SA could not be created");
512 }
513
514 status = global_job_queue->add(global_job_queue,delete_job);
515 if (status != SUCCESS)
516 {
517 this->logger->log(this->logger, ERROR, "%s Job to delete IKE SA could not be added to job queue",mapping_find(status_m,status));
518 delete_job->destroy_all(delete_job);
519 }*/
520 return SUCCESS;
521 }
522
523 static status_t transto_ike_auth_requested(private_ike_sa_t *this, message_t *message)
524 {
525 return SUCCESS;
526 }
527
528 /**
529 * @brief implements function process_configuration of private_ike_sa_t
530 */
531 static status_t initialize_connection(private_ike_sa_t *this, char *name)
532 {
533 /* work is done in transto_ike_sa_init_requested */
534 return (this->transto_ike_sa_init_requested(this,name));
535 }
536
537 /**
538 * @brief implements function private_ike_sa_t.get_id
539 */
540 static ike_sa_id_t* get_id(private_ike_sa_t *this)
541 {
542 return this->ike_sa_id;
543 }
544
545 /**
546 * implements private_ike_sa_t.build_sa_payload
547 */
548 static status_t build_sa_payload(private_ike_sa_t *this, sa_payload_t **payload)
549 {
550 sa_payload_t* sa_payload;
551 linked_list_iterator_t *iterator;
552 status_t status;
553
554 this->logger->log(this->logger, CONTROL|MORE, "building sa payload");
555
556 sa_payload = sa_payload_create();
557 if (sa_payload == NULL)
558 {
559 return OUT_OF_RES;
560 }
561 status = sa_payload->create_proposal_substructure_iterator(sa_payload, &iterator, FALSE);
562 if (status != SUCCESS)
563 {
564 sa_payload->destroy(sa_payload);
565 return status;
566 }
567 status = global_configuration_manager->get_proposals_for_host(global_configuration_manager, this->other.host, iterator);
568 if (status != SUCCESS)
569 {
570 sa_payload->destroy(sa_payload);
571 return status;
572 }
573
574 *payload = sa_payload;
575
576 return SUCCESS;
577 }
578
579 static status_t build_ke_payload(private_ike_sa_t *this, ke_payload_t **payload)
580 {
581 ke_payload_t *ke_payload;
582 chunk_t key_data;
583 status_t status;
584
585 this->logger->log(this->logger, CONTROL|MORE, "building ke payload");
586
587 if (this->state != NO_STATE)
588 {
589 this->logger->log(this->logger, ERROR, "KE payload in state %s not supported",mapping_find(ike_sa_state_m,this->state));
590 return FALSE;
591 }
592
593 switch(this->ike_sa_id->is_initiator(this->ike_sa_id))
594 {
595 case TRUE:
596 {
597 this ->logger->log(this->logger, CONTROL|MORE, "get public dh value to send in ke payload");
598 status = this->ike_sa_init_data.diffie_hellman->get_my_public_value(this->ike_sa_init_data.diffie_hellman,&key_data);
599 if (status != SUCCESS)
600 {
601 this->logger->log(this->logger, ERROR, "Could not get my DH public value");
602 return status;
603 }
604
605 ke_payload = ke_payload_create();
606 if (ke_payload == NULL)
607 {
608 this->logger->log(this->logger, ERROR, "Could not create KE payload");
609 allocator_free_chunk(key_data);
610 return OUT_OF_RES;
611 }
612 ke_payload->set_dh_group_number(ke_payload, MODP_1024_BIT);
613 if (ke_payload->set_key_exchange_data(ke_payload, key_data) != SUCCESS)
614 {
615 this->logger->log(this->logger, ERROR, "Could not set key exchange data of KE payload");
616 ke_payload->destroy(ke_payload);
617 allocator_free_chunk(key_data);
618 return OUT_OF_RES;
619 }
620 allocator_free_chunk(key_data);
621
622 *payload = ke_payload;
623 return SUCCESS;
624 }
625 default: /* FALSE */
626 {
627 break;
628 }
629 }
630
631 return FAILED;
632 }
633
634 /**
635 * implements private_ike_sa_t.build_nonce_payload
636 */
637 static status_t build_nonce_payload(private_ike_sa_t *this, nonce_payload_t **payload)
638 {
639 nonce_payload_t *nonce_payload;
640
641 this->logger->log(this->logger, CONTROL|MORE, "building nonce payload");
642 nonce_payload = nonce_payload_create();
643 if (nonce_payload == NULL)
644 {
645 return OUT_OF_RES;
646 }
647
648 nonce_payload->set_nonce(nonce_payload, this->ike_sa_init_data.sent_nonce);
649
650 *payload = nonce_payload;
651
652 return SUCCESS;
653 }
654
655 /**
656 * @brief implements function destroy of private_ike_sa_t
657 */
658 static status_t destroy (private_ike_sa_t *this)
659 {
660 /* destroy child sa's */
661 while (this->child_sas->get_count(this->child_sas) > 0)
662 {
663 void *child_sa;
664 if (this->child_sas->remove_first(this->child_sas,&child_sa) != SUCCESS)
665 {
666 break;
667 }
668 /* destroy child sa */
669 }
670 this->child_sas->destroy(this->child_sas);
671
672 /* destroy ike_sa_id */
673 this->ike_sa_id->destroy(this->ike_sa_id);
674
675 /* destroy stored requested messages */
676 while (this->requested_messages->get_count(this->requested_messages) > 0)
677 {
678 message_t *message;
679 if (this->requested_messages->remove_first(this->requested_messages,(void **) &message) != SUCCESS)
680 {
681 break;
682 }
683 message->destroy(message);
684 }
685 this->requested_messages->destroy(this->requested_messages);
686
687 /* destroy stored responded messages */
688 while (this->responded_messages->get_count(this->responded_messages) > 0)
689 {
690 message_t *message;
691 if (this->responded_messages->remove_first(this->responded_messages,(void **) &message) != SUCCESS)
692 {
693 break;
694 }
695 message->destroy(message);
696 }
697 this->responded_messages->destroy(this->responded_messages);
698
699
700 this->randomizer->destroy(this->randomizer);
701 if (this->ike_sa_init_data.diffie_hellman != NULL)
702 {
703 this->ike_sa_init_data.diffie_hellman->destroy(this->ike_sa_init_data.diffie_hellman);
704 }
705 if (this->ike_sa_init_data.sent_nonce.ptr != NULL)
706 {
707 allocator_free_chunk(this->ike_sa_init_data.sent_nonce);
708 }
709 if (this->ike_sa_init_data.received_nonce.ptr != NULL)
710 {
711 allocator_free_chunk(this->ike_sa_init_data.received_nonce);
712 }
713
714 global_logger_manager->destroy_logger(global_logger_manager, this->logger);
715
716 allocator_free(this);
717
718 return SUCCESS;
719 }
720
721 /*
722 * Described in Header
723 */
724 ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
725 {
726 private_ike_sa_t *this = allocator_alloc_thing(private_ike_sa_t);
727 if (this == NULL)
728 {
729 return NULL;
730 }
731
732
733 /* Public functions */
734 this->public.process_message = (status_t(*)(ike_sa_t*, message_t*)) process_message;
735 this->public.initialize_connection = (status_t(*)(ike_sa_t*, char*)) initialize_connection;
736 this->public.get_id = (ike_sa_id_t*(*)(ike_sa_t*)) get_id;
737 this->public.destroy = (status_t(*)(ike_sa_t*))destroy;
738
739 /* private functions */
740 this->build_sa_payload = build_sa_payload;
741 this->build_nonce_payload = build_nonce_payload;
742 this->build_ke_payload = build_ke_payload;
743 this->build_message = build_message;
744 this->transto_ike_sa_init_requested = transto_ike_sa_init_requested;
745 this->transto_ike_sa_init_responded = transto_ike_sa_init_responded;
746 this->transto_ike_auth_requested = transto_ike_auth_requested;
747
748
749
750 /* initialize private fields */
751 if (ike_sa_id->clone(ike_sa_id,&(this->ike_sa_id)) != SUCCESS)
752 {
753 allocator_free(this);
754 return NULL;
755 }
756 this->child_sas = linked_list_create();
757 if (this->child_sas == NULL)
758 {
759 this->ike_sa_id->destroy(this->ike_sa_id);
760 allocator_free(this);
761 return NULL;
762 }
763 this->randomizer = randomizer_create();
764 if (this->randomizer == NULL)
765 {
766 this->child_sas->destroy(this->child_sas);
767 this->ike_sa_id->destroy(this->ike_sa_id);
768 allocator_free(this);
769 }
770 this->responded_messages = linked_list_create();
771 if (this->responded_messages == NULL)
772 {
773 this->randomizer->destroy(this->randomizer);
774 this->child_sas->destroy(this->child_sas);
775 this->ike_sa_id->destroy(this->ike_sa_id);
776 allocator_free(this);
777 }
778 this->requested_messages = linked_list_create();
779 if (this->requested_messages == NULL)
780 {
781 this->randomizer->destroy(this->randomizer);
782 this->child_sas->destroy(this->child_sas);
783 this->ike_sa_id->destroy(this->ike_sa_id);
784 this->responded_messages->destroy(this->responded_messages);
785 allocator_free(this);
786 }
787
788 this->logger = global_logger_manager->create_logger(global_logger_manager, IKE_SA, NULL);
789 if (this->logger == NULL)
790 {
791 this->randomizer->destroy(this->randomizer);
792 this->child_sas->destroy(this->child_sas);
793 this->ike_sa_id->destroy(this->ike_sa_id);
794 this->responded_messages->destroy(this->responded_messages);
795 this->requested_messages->destroy(this->requested_messages);
796 allocator_free(this);
797 }
798
799 this->me.host = NULL;
800 this->other.host = NULL;
801 this->ike_sa_init_data.diffie_hellman = NULL;
802 this->ike_sa_init_data.dh_group_number = 0;
803 /* 1 means highest priority */
804 this->ike_sa_init_data.dh_group_priority = 1;
805 this->ike_sa_init_data.sent_nonce.len = 0;
806 this->ike_sa_init_data.sent_nonce.ptr = NULL;
807 this->ike_sa_init_data.received_nonce.len = 0;
808 this->ike_sa_init_data.received_nonce.ptr = NULL;
809 this->message_id_out = 0;
810 this->message_id_in = 0;
811
812
813 /* at creation time, IKE_SA isn't in a specific state */
814 this->state = NO_STATE;
815
816 return (&this->public);
817 }