- memory allocation checks removed
[strongswan.git] / Source / charon / sa / states / responder_init.c
1 /**
2 * @file responder_init.c
3 *
4 * @brief Start state of a IKE_SA as responder
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 "responder_init.h"
24
25 #include <globals.h>
26 #include <sa/states/state.h>
27 #include <sa/states/ike_sa_init_responded.h>
28 #include <utils/allocator.h>
29 #include <encoding/payloads/sa_payload.h>
30 #include <encoding/payloads/ke_payload.h>
31 #include <encoding/payloads/nonce_payload.h>
32 #include <transforms/diffie_hellman.h>
33
34
35 typedef struct private_responder_init_t private_responder_init_t;
36
37 /**
38 * Private data of a responder_init_t object.
39 *
40 */
41 struct private_responder_init_t {
42 /**
43 * Methods of the state_t interface.
44 */
45 responder_init_t public;
46
47 /**
48 * Assigned IKE_SA.
49 */
50 protected_ike_sa_t *ike_sa;
51
52 /**
53 * Diffie Hellman object used to compute shared secret.
54 *
55 * After processing of incoming IKE_SA_INIT-Request the shared key is
56 * passed to the next state of type ike_sa_init_responded_t.
57 */
58 diffie_hellman_t *diffie_hellman;
59
60 /**
61 * Diffie Hellman group number.
62 */
63 u_int16_t dh_group_number;
64
65 /**
66 * Priority used to get matching dh_group number.
67 */
68 u_int16_t dh_group_priority;
69
70 /**
71 * Sent nonce value.
72 *
73 * This value is passed to the next state of type ike_sa_init_responded_t.
74 */
75 chunk_t sent_nonce;
76
77 /**
78 * Received nonce value
79 *
80 * This value is passed to the next state of type ike_sa_init_responded_t.
81 */
82 chunk_t received_nonce;
83
84 /**
85 * Logger used to log data
86 *
87 * Is logger of ike_sa!
88 */
89 logger_t *logger;
90
91 /**
92 * Proposals used to initiate connection
93 */
94 linked_list_t *proposals;
95
96 /**
97 * Builds the SA payload for this state.
98 *
99 * @param this calling object
100 * @param payload The generated SA payload object of type ke_payload_t is
101 * stored at this location.
102 * @return
103 * - SUCCESS
104 * - OUT_OF_RES
105 */
106 status_t (*build_sa_payload) (private_responder_init_t *this, payload_t **payload);
107
108 /**
109 * Builds the KE payload for this state.
110 *
111 * @param this calling object
112 * @param payload The generated KE payload object of type ke_payload_t is
113 * stored at this location.
114 * @return
115 * - SUCCESS
116 * - OUT_OF_RES
117 */
118 status_t (*build_ke_payload) (private_responder_init_t *this, payload_t **payload);
119 /**
120 * Builds the NONCE payload for this state.
121 *
122 * @param this calling object
123 * @param payload The generated NONCE payload object of type ke_payload_t is
124 * stored at this location.
125 * @return
126 * - SUCCESS
127 * - OUT_OF_RES
128 */
129 status_t (*build_nonce_payload) (private_responder_init_t *this, payload_t **payload);
130
131 /**
132 * Destroy function called internally of this class after state change succeeded.
133 *
134 * This destroy function does not destroy objects which were passed to the new state.
135 *
136 * @param this calling object
137 * @return SUCCESS in any case
138 */
139 status_t (*destroy_after_state_change) (private_responder_init_t *this);
140 };
141
142 /**
143 * Implements state_t.get_state
144 */
145 static status_t process_message(private_responder_init_t *this, message_t *message)
146 {
147 iterator_t *payloads;
148 host_t *source, *destination;
149 status_t status;
150 message_t *response;
151 payload_t *payload;
152 packet_t *packet;
153 chunk_t shared_secret;
154 exchange_type_t exchange_type;
155 ike_sa_init_responded_t *next_state;
156 host_t *my_host;
157 host_t *other_host;
158 randomizer_t *randomizer;
159
160 exchange_type = message->get_exchange_type(message);
161 if (exchange_type != IKE_SA_INIT)
162 {
163 this->logger->log(this->logger, ERROR | MORE, "Message of type %s not supported in state responder_init",mapping_find(exchange_type_m,exchange_type));
164 return FAILED;
165 }
166
167 if (!message->get_request(message))
168 {
169 this->logger->log(this->logger, ERROR | MORE, "Only requests of type IKE_SA_INIT supported in state responder_init");
170 return FAILED;
171 }
172
173 /* this is the first message we process, so copy host infos */
174 message->get_source(message, &source);
175 message->get_destination(message, &destination);
176
177 /* we need to clone them, since we destroy the message later */
178 status = destination->clone(destination, &my_host);
179 if (status != SUCCESS)
180 {
181 this->logger->log(this->logger, ERROR, "Fatal error: could not clone my host informations");
182 return status;
183 }
184 status = source->clone(source, &other_host);
185 if (status != SUCCESS)
186 {
187 this->logger->log(this->logger, ERROR, "Fatal error: could not clone other host informations");
188 my_host->destroy(my_host);
189 return status;
190 }
191
192
193 this->ike_sa->set_my_host(this->ike_sa, my_host);
194 this->ike_sa->set_other_host(this->ike_sa, other_host);
195
196 /* parse incoming message */
197 status = message->parse_body(message, NULL, NULL);
198 if (status != SUCCESS)
199 {
200 this->logger->log(this->logger, ERROR | MORE, "Could not parse body of request message");
201 return status;
202 }
203
204 /* iterate over incoming payloads. We can be sure, the message contains only accepted payloads! */
205 message->get_payload_iterator(message, &payloads);
206
207 while (payloads->has_next(payloads))
208 {
209 payload_t *payload;
210
211 /* get current payload */
212 payloads->current(payloads, (void**)&payload);
213
214 this->logger->log(this->logger, CONTROL|MORE, "Processing payload of type %s", mapping_find(payload_type_m, payload->get_type(payload)));
215 switch (payload->get_type(payload))
216 {
217 case SECURITY_ASSOCIATION:
218 {
219 sa_payload_t *sa_payload = (sa_payload_t*)payload;
220 iterator_t *suggested_proposals, *accepted_proposals;
221 proposal_substructure_t *accepted_proposal;
222
223 status = this->proposals->create_iterator(this->proposals, &accepted_proposals, FALSE);
224 if (status != SUCCESS)
225 {
226 this->logger->log(this->logger, ERROR, "Fatal error: Could not create iterator on list for proposals");
227 payloads->destroy(payloads);
228 return status;
229 }
230
231 /* get the list of suggested proposals */
232 status = sa_payload->create_proposal_substructure_iterator(sa_payload, &suggested_proposals, TRUE);
233 if (status != SUCCESS)
234 {
235 this->logger->log(this->logger, ERROR, "Fatal error: Could not create iterator on suggested proposals");
236 accepted_proposals->destroy(accepted_proposals);
237 payloads->destroy(payloads);
238 return status;
239 }
240
241 /* now let the configuration-manager select a subset of the proposals */
242 status = global_configuration_manager->select_proposals_for_host(global_configuration_manager,
243 this->ike_sa->get_other_host(this->ike_sa), suggested_proposals, accepted_proposals);
244 if (status != SUCCESS)
245 {
246 this->logger->log(this->logger, CONTROL | MORE, "No proposal of suggested proposals selected");
247 suggested_proposals->destroy(suggested_proposals);
248 accepted_proposals->destroy(accepted_proposals);
249 payloads->destroy(payloads);
250 return status;
251 }
252
253 /* iterators are not needed anymore */
254 suggested_proposals->destroy(suggested_proposals);
255
256
257 /* let the ike_sa create their own transforms from proposal informations */
258 accepted_proposals->reset(accepted_proposals);
259 /* TODO check for true*/
260 accepted_proposals->has_next(accepted_proposals);
261 status = accepted_proposals->current(accepted_proposals,(void **)&accepted_proposal);
262 if (status != SUCCESS)
263 {
264 this->logger->log(this->logger, ERROR | MORE, "Accepted proposals not supported?!");
265 accepted_proposals->destroy(accepted_proposals);
266 payloads->destroy(payloads);
267 return status;
268 }
269
270 status = this->ike_sa->create_transforms_from_proposal(this->ike_sa,accepted_proposal);
271 accepted_proposals->destroy(accepted_proposals);
272 if (status != SUCCESS)
273 {
274 this->logger->log(this->logger, ERROR | MORE, "Transform objects could not be created from selected proposal");
275 payloads->destroy(payloads);
276 return status;
277 }
278
279 this->logger->log(this->logger, CONTROL | MORE, "SA Payload processed");
280 /* ok, we have what we need for sa_payload (proposals are stored in this->proposals)*/
281 break;
282 }
283 case KEY_EXCHANGE:
284 {
285 ke_payload_t *ke_payload = (ke_payload_t*)payload;
286 diffie_hellman_group_t group;
287 diffie_hellman_t *dh;
288 bool allowed_group;
289
290 group = ke_payload->get_dh_group_number(ke_payload);
291
292 status = global_configuration_manager->is_dh_group_allowed_for_host(global_configuration_manager,
293 this->ike_sa->get_other_host(this->ike_sa), group, &allowed_group);
294
295 if (status != SUCCESS)
296 {
297 this->logger->log(this->logger, ERROR | MORE, "Could not get informations about DH group");
298 payloads->destroy(payloads);
299 return status;
300 }
301 if (!allowed_group)
302 {
303 /** @todo Send info reply */
304 }
305
306 /* create diffie hellman object to handle DH exchange */
307 dh = diffie_hellman_create(group);
308 if (dh == NULL)
309 {
310 this->logger->log(this->logger, ERROR, "Could not generate DH object");
311 payloads->destroy(payloads);
312 return OUT_OF_RES;
313 }
314
315 this->logger->log(this->logger, CONTROL | MORE, "Set other DH public value");
316
317 status = dh->set_other_public_value(dh, ke_payload->get_key_exchange_data(ke_payload));
318 if (status != SUCCESS)
319 {
320 this->logger->log(this->logger, ERROR, "Could not set other DH public value");
321 dh->destroy(dh);
322 payloads->destroy(payloads);
323 return OUT_OF_RES;
324 }
325
326 this->diffie_hellman = dh;
327
328 this->logger->log(this->logger, CONTROL | MORE, "KE Payload processed");
329 break;
330 }
331 case NONCE:
332 {
333 nonce_payload_t *nonce_payload = (nonce_payload_t*)payload;
334
335 if (this->received_nonce.ptr != NULL)
336 {
337 this->logger->log(this->logger, CONTROL | MOST, "Destroy stored received nonce");
338 allocator_free(this->received_nonce.ptr);
339 this->received_nonce.ptr = NULL;
340 this->received_nonce.len = 0;
341 }
342
343 this->logger->log(this->logger, CONTROL | MORE, "Get nonce value and store it");
344 status = nonce_payload->get_nonce(nonce_payload, &(this->received_nonce));
345 if (status != SUCCESS)
346 {
347 this->logger->log(this->logger, ERROR, "Fatal error: Could not get nonce");
348 payloads->destroy(payloads);
349 return OUT_OF_RES;
350 }
351
352 this->logger->log(this->logger, CONTROL | MORE, "Nonce Payload processed");
353 break;
354 }
355 default:
356 {
357 this->logger->log(this->logger, ERROR | MORE, "Payload type not supported!");
358 payloads->destroy(payloads);
359 return OUT_OF_RES;
360 }
361
362 }
363
364 }
365 /* iterator can be destroyed */
366 payloads->destroy(payloads);
367
368 this->logger->log(this->logger, CONTROL | MORE, "Request successfully handled. Going to create reply.");
369
370 this->logger->log(this->logger, CONTROL | MOST, "Going to create nonce.");
371
372 randomizer = this->ike_sa->get_randomizer(this->ike_sa);
373
374 if (randomizer->allocate_pseudo_random_bytes(randomizer, NONCE_SIZE, &(this->sent_nonce)) != SUCCESS)
375 {
376 this->logger->log(this->logger, ERROR, "Could not create nonce!");
377 return OUT_OF_RES;
378 }
379
380 /* store shared secret */
381 this->logger->log(this->logger, CONTROL | MOST, "Retrieve shared secret and store it");
382 status = this->diffie_hellman->get_shared_secret(this->diffie_hellman, &shared_secret);
383 this->logger->log_chunk(this->logger, PRIVATE, "Shared secret", &shared_secret);
384
385 status = this->ike_sa->compute_secrets(this->ike_sa,shared_secret,this->received_nonce, this->sent_nonce);
386 if (status != SUCCESS)
387 {
388 /* secrets could not be computed */
389 this->logger->log(this->logger, ERROR | MORE, "Secrets could not be computed!");
390 return status;
391 }
392
393 /* set up the reply */
394 status = this->ike_sa->build_message(this->ike_sa, IKE_SA_INIT, FALSE, &response);
395 if (status != SUCCESS)
396 {
397 this->logger->log(this->logger, ERROR, "Could not create empty message");
398 return status;
399 }
400
401 /* build SA payload */
402 status = this->build_sa_payload(this, &payload);
403 if (status != SUCCESS)
404 {
405 this->logger->log(this->logger, ERROR, "Could not build SA payload");
406 return status;
407 }
408
409 this->logger->log(this->logger, CONTROL|MOST, "add SA payload to message");
410 response->add_payload(response, payload);
411
412 /* build KE payload */
413 status = this->build_ke_payload(this,&payload);
414 if (status != SUCCESS)
415 {
416 this->logger->log(this->logger, ERROR, "Could not build KE payload");
417 return status;
418 }
419
420 this->logger->log(this->logger, CONTROL|MOST, "add KE payload to message");
421 response->add_payload(response, payload);
422
423 /* build Nonce payload */
424 status = this->build_nonce_payload(this, &payload);
425 if (status != SUCCESS)
426 {
427 this->logger->log(this->logger, ERROR, "Could not build NONCE payload");
428 return status;
429 }
430
431 this->logger->log(this->logger, CONTROL|MOST, "add nonce payload to message");
432 response->add_payload(response, payload);
433
434 /* generate packet */
435 this->logger->log(this->logger, CONTROL|MOST, "generate packet from message");
436 status = response->generate(response, NULL, NULL, &packet);
437 if (status != SUCCESS)
438 {
439 this->logger->log(this->logger, ERROR, "Fatal error: could not generate packet from message");
440 return status;
441 }
442
443 this ->logger->log(this->logger, CONTROL|MOST, "Add packet to global send queue");
444 status = global_send_queue->add(global_send_queue, packet);
445 if (status != SUCCESS)
446 {
447 this->logger->log(this->logger, ERROR, "Could not add packet to send queue");
448 packet->destroy(packet);
449 return status;
450 }
451
452 /* state can now be changed */
453 this ->logger->log(this->logger, CONTROL|MOST, "Create next state object");
454
455 next_state = ike_sa_init_responded_create(this->ike_sa, shared_secret, this->received_nonce, this->sent_nonce);
456
457 if (next_state == NULL)
458 {
459 this ->logger->log(this->logger, ERROR, "Fatal error: could not create next state object of type ike_sa_init_responded_t");
460 allocator_free_chunk(&shared_secret);
461 return FAILED;
462 }
463
464 /* last message can now be set */
465 status = this->ike_sa->set_last_responded_message(this->ike_sa, response);
466
467 if (status != SUCCESS)
468 {
469 this->logger->log(this->logger, ERROR, "Could not set last responded message");
470 response->destroy(response);
471 (next_state->state_interface).destroy(&(next_state->state_interface));
472 return status;
473 }
474
475 /* state can now be changed */
476 this->ike_sa->set_new_state(this->ike_sa, (state_t *) next_state);
477 /* state has NOW changed :-) */
478 this ->logger->log(this->logger, CONTROL|MORE, "Changed state of IKE_SA from %s to %s",mapping_find(ike_sa_state_m,RESPONDER_INIT),mapping_find(ike_sa_state_m,IKE_SA_INIT_RESPONDED) );
479
480 this ->logger->log(this->logger, CONTROL|MOST, "Destroy old sate object");
481 this->destroy_after_state_change(this);
482
483 return SUCCESS;
484 }
485
486 /**
487 * implements private_initiator_init_t.build_sa_payload
488 */
489 static status_t build_sa_payload(private_responder_init_t *this, payload_t **payload)
490 {
491 sa_payload_t* sa_payload;
492 iterator_t *proposal_iterator;
493 status_t status;
494
495
496 /* SA payload takes proposals from this->ike_sa_init_data.proposals and writes them to the created sa_payload */
497
498 this->logger->log(this->logger, CONTROL|MORE, "building sa payload");
499
500 status = this->proposals->create_iterator(this->proposals, &proposal_iterator, FALSE);
501 if (status != SUCCESS)
502 {
503 this->logger->log(this->logger, ERROR, "Fatal error: Could not create iterator on list for proposals");
504 return status;
505 }
506
507 sa_payload = sa_payload_create();
508 if (sa_payload == NULL)
509 {
510 this->logger->log(this->logger, ERROR, "Fatal error: Could not create SA payload object");
511 return OUT_OF_RES;
512 }
513
514 while (proposal_iterator->has_next(proposal_iterator))
515 {
516 proposal_substructure_t *current_proposal;
517 proposal_substructure_t *current_proposal_clone;
518 status = proposal_iterator->current(proposal_iterator,(void **) &current_proposal);
519 if (status != SUCCESS)
520 {
521 this->logger->log(this->logger, ERROR, "Could not get current proposal needed to copy");
522 proposal_iterator->destroy(proposal_iterator);
523 sa_payload->destroy(sa_payload);
524 return status;
525 }
526 status = current_proposal->clone(current_proposal,&current_proposal_clone);
527 if (status != SUCCESS)
528 {
529 this->logger->log(this->logger, ERROR, "Could not clone current proposal");
530 proposal_iterator->destroy(proposal_iterator);
531 sa_payload->destroy(sa_payload);
532 return status;
533 }
534
535 status = sa_payload->add_proposal_substructure(sa_payload,current_proposal_clone);
536 if (status != SUCCESS)
537 {
538 this->logger->log(this->logger, ERROR, "Could not add cloned proposal to SA payload");
539 proposal_iterator->destroy(proposal_iterator);
540 sa_payload->destroy(sa_payload);
541 return status;
542 }
543
544 }
545
546 proposal_iterator->destroy(proposal_iterator);
547
548 this->logger->log(this->logger, CONTROL|MORE, "sa payload builded");
549
550 *payload = (payload_t *) sa_payload;
551
552 return SUCCESS;
553 }
554
555 /**
556 * implements private_initiator_init_t.build_ke_payload
557 */
558 static status_t build_ke_payload(private_responder_init_t *this, payload_t **payload)
559 {
560 ke_payload_t *ke_payload;
561 chunk_t key_data;
562 status_t status;
563
564 this->logger->log(this->logger, CONTROL|MORE, "building ke payload");
565
566
567 this ->logger->log(this->logger, CONTROL|MORE, "get public dh value to send in ke payload");
568 status = this->diffie_hellman->get_my_public_value(this->diffie_hellman,&key_data);
569 if (status != SUCCESS)
570 {
571 this->logger->log(this->logger, ERROR, "Could not get my DH public value");
572 return status;
573 }
574
575 ke_payload = ke_payload_create();
576 if (ke_payload == NULL)
577 {
578 this->logger->log(this->logger, ERROR, "Could not create KE payload");
579 allocator_free_chunk(&key_data);
580 return OUT_OF_RES;
581 }
582 ke_payload->set_dh_group_number(ke_payload, MODP_1024_BIT);
583 if (ke_payload->set_key_exchange_data(ke_payload, key_data) != SUCCESS)
584 {
585 this->logger->log(this->logger, ERROR, "Could not set key exchange data of KE payload");
586 ke_payload->destroy(ke_payload);
587 allocator_free_chunk(&key_data);
588 return OUT_OF_RES;
589 }
590 allocator_free_chunk(&key_data);
591
592 *payload = (payload_t *) ke_payload;
593 return SUCCESS;
594 }
595
596 /**
597 * implements private_initiator_init_t.build_nonce_payload
598 */
599 static status_t build_nonce_payload(private_responder_init_t *this, payload_t **payload)
600 {
601 nonce_payload_t *nonce_payload;
602 status_t status;
603
604 this->logger->log(this->logger, CONTROL|MORE, "building nonce payload");
605
606 nonce_payload = nonce_payload_create();
607 if (nonce_payload == NULL)
608 {
609 this->logger->log(this->logger, ERROR, "Fatal error: could not create nonce payload object");
610 return OUT_OF_RES;
611 }
612
613 status = nonce_payload->set_nonce(nonce_payload, this->sent_nonce);
614
615 if (status != SUCCESS)
616 {
617 this->logger->log(this->logger, ERROR, "Fatal error: could not set nonce data of payload");
618 nonce_payload->destroy(nonce_payload);
619 return status;
620 }
621
622 *payload = (payload_t *) nonce_payload;
623
624 return SUCCESS;
625 }
626
627
628 /**
629 * Implements state_t.get_state
630 */
631 static ike_sa_state_t get_state(private_responder_init_t *this)
632 {
633 return RESPONDER_INIT;
634 }
635
636 /**
637 * Implements state_t.get_state
638 */
639 static status_t destroy(private_responder_init_t *this)
640 {
641 this->logger->log(this->logger, CONTROL | MORE, "Going to destroy responder init state object");
642
643 /* destroy stored proposal */
644 this->logger->log(this->logger, CONTROL | MOST, "Destroy stored proposals");
645 while (this->proposals->get_count(this->proposals) > 0)
646 {
647 proposal_substructure_t *current_proposal;
648 this->proposals->remove_first(this->proposals,(void **)&current_proposal);
649 current_proposal->destroy(current_proposal);
650 }
651 this->proposals->destroy(this->proposals);
652
653 if (this->sent_nonce.ptr != NULL)
654 {
655 this->logger->log(this->logger, CONTROL | MOST, "Destroy sent nonce");
656 allocator_free(this->sent_nonce.ptr);
657 }
658
659 if (this->received_nonce.ptr != NULL)
660 {
661 this->logger->log(this->logger, CONTROL | MOST, "Destroy received nonce");
662 allocator_free(this->received_nonce.ptr);
663 }
664
665 /* destroy diffie hellman object */
666 if (this->diffie_hellman != NULL)
667 {
668 this->logger->log(this->logger, CONTROL | MOST, "Destroy diffie_hellman_t object");
669 this->diffie_hellman->destroy(this->diffie_hellman);
670 }
671
672 allocator_free(this);
673
674 return SUCCESS;
675
676 }
677
678 /**
679 * Implements private_responder_init_t.destroy_after_state_change
680 */
681 static status_t destroy_after_state_change (private_responder_init_t *this)
682 {
683 this->logger->log(this->logger, CONTROL | MORE, "Going to destroy responder_init_t state object");
684
685 /* destroy stored proposal */
686 this->logger->log(this->logger, CONTROL | MOST, "Destroy stored proposals");
687 while (this->proposals->get_count(this->proposals) > 0)
688 {
689 proposal_substructure_t *current_proposal;
690 this->proposals->remove_first(this->proposals,(void **)&current_proposal);
691 current_proposal->destroy(current_proposal);
692 }
693 this->proposals->destroy(this->proposals);
694
695 /* destroy diffie hellman object */
696 if (this->diffie_hellman != NULL)
697 {
698 this->logger->log(this->logger, CONTROL | MOST, "Destroy diffie_hellman_t object");
699 this->diffie_hellman->destroy(this->diffie_hellman);
700 }
701
702 allocator_free(this);
703 return SUCCESS;
704 }
705
706 /*
707 * Described in header.
708 */
709 responder_init_t *responder_init_create(protected_ike_sa_t *ike_sa)
710 {
711 private_responder_init_t *this = allocator_alloc_thing(private_responder_init_t);
712
713 if (this == NULL)
714 {
715 return NULL;
716 }
717
718 /* interface functions */
719 this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
720 this->public.state_interface.get_state = (ike_sa_state_t (*) (state_t *)) get_state;
721 this->public.state_interface.destroy = (status_t (*) (state_t *)) destroy;
722
723 /* private functions */
724 this->build_sa_payload = build_sa_payload;
725 this->build_ke_payload = build_ke_payload;
726 this->build_nonce_payload = build_nonce_payload;
727 this->destroy_after_state_change = destroy_after_state_change;
728
729 /* private data */
730 this->ike_sa = ike_sa;
731 this->logger = this->ike_sa->get_logger(this->ike_sa);
732 this->sent_nonce.ptr = NULL;
733 this->sent_nonce.len = 0;
734 this->received_nonce.ptr = NULL;
735 this->received_nonce.len = 0;
736 this->proposals = linked_list_create();
737 if (this->proposals == NULL)
738 {
739 allocator_free(this);
740 return NULL;
741 }
742
743 return &(this->public);
744 }