diffie-hellman: Add a bool return value to get_my_public_value()
[strongswan.git] / src / libcharon / sa / ikev2 / tasks / ike_init.c
1 /*
2 * Copyright (C) 2008-2015 Tobias Brunner
3 * Copyright (C) 2005-2008 Martin Willi
4 * Copyright (C) 2005 Jan Hutter
5 * Hochschule fuer Technik Rapperswil
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 */
17
18 #include "ike_init.h"
19
20 #include <string.h>
21
22 #include <daemon.h>
23 #include <bio/bio_reader.h>
24 #include <bio/bio_writer.h>
25 #include <sa/ikev2/keymat_v2.h>
26 #include <crypto/diffie_hellman.h>
27 #include <crypto/hashers/hash_algorithm_set.h>
28 #include <encoding/payloads/sa_payload.h>
29 #include <encoding/payloads/ke_payload.h>
30 #include <encoding/payloads/nonce_payload.h>
31
32 /** maximum retries to do with cookies/other dh groups */
33 #define MAX_RETRIES 5
34
35 typedef struct private_ike_init_t private_ike_init_t;
36
37 /**
38 * Private members of a ike_init_t task.
39 */
40 struct private_ike_init_t {
41
42 /**
43 * Public methods and task_t interface.
44 */
45 ike_init_t public;
46
47 /**
48 * Assigned IKE_SA.
49 */
50 ike_sa_t *ike_sa;
51
52 /**
53 * Are we the initiator?
54 */
55 bool initiator;
56
57 /**
58 * IKE config to establish
59 */
60 ike_cfg_t *config;
61
62 /**
63 * diffie hellman group to use
64 */
65 diffie_hellman_group_t dh_group;
66
67 /**
68 * diffie hellman key exchange
69 */
70 diffie_hellman_t *dh;
71
72 /**
73 * Keymat derivation (from IKE_SA)
74 */
75 keymat_v2_t *keymat;
76
77 /**
78 * nonce chosen by us
79 */
80 chunk_t my_nonce;
81
82 /**
83 * nonce chosen by peer
84 */
85 chunk_t other_nonce;
86
87 /**
88 * Negotiated proposal used for IKE_SA
89 */
90 proposal_t *proposal;
91
92 /**
93 * Old IKE_SA which gets rekeyed
94 */
95 ike_sa_t *old_sa;
96
97 /**
98 * cookie received from responder
99 */
100 chunk_t cookie;
101
102 /**
103 * retries done so far after failure (cookie or bad dh group)
104 */
105 u_int retry;
106
107 /**
108 * Whether to use Signature Authentication as per RFC 7427
109 */
110 bool signature_authentication;
111 };
112
113 /**
114 * Notify the peer about the hash algorithms we support or expect,
115 * as per RFC 7427
116 */
117 static void send_supported_hash_algorithms(private_ike_init_t *this,
118 message_t *message)
119 {
120 hash_algorithm_set_t *algos;
121 enumerator_t *enumerator, *rounds;
122 bio_writer_t *writer;
123 hash_algorithm_t hash;
124 peer_cfg_t *peer;
125 auth_cfg_t *auth;
126 auth_rule_t rule;
127 uintptr_t config;
128 char *plugin_name;
129
130 algos = hash_algorithm_set_create();
131 peer = this->ike_sa->get_peer_cfg(this->ike_sa);
132 if (peer)
133 {
134 rounds = peer->create_auth_cfg_enumerator(peer, FALSE);
135 while (rounds->enumerate(rounds, &auth))
136 {
137 enumerator = auth->create_enumerator(auth);
138 while (enumerator->enumerate(enumerator, &rule, &config))
139 {
140 if (rule == AUTH_RULE_SIGNATURE_SCHEME)
141 {
142 hash = hasher_from_signature_scheme(config);
143 if (hasher_algorithm_for_ikev2(hash))
144 {
145 algos->add(algos, hash);
146 }
147 }
148 }
149 enumerator->destroy(enumerator);
150 }
151 rounds->destroy(rounds);
152 }
153
154 if (!algos->count(algos))
155 {
156 enumerator = lib->crypto->create_hasher_enumerator(lib->crypto);
157 while (enumerator->enumerate(enumerator, &hash, &plugin_name))
158 {
159 if (hasher_algorithm_for_ikev2(hash))
160 {
161 algos->add(algos, hash);
162 }
163 }
164 enumerator->destroy(enumerator);
165 }
166
167 if (algos->count(algos))
168 {
169 writer = bio_writer_create(0);
170 enumerator = algos->create_enumerator(algos);
171 while (enumerator->enumerate(enumerator, &hash))
172 {
173 writer->write_uint16(writer, hash);
174 }
175 enumerator->destroy(enumerator);
176 message->add_notify(message, FALSE, SIGNATURE_HASH_ALGORITHMS,
177 writer->get_buf(writer));
178 writer->destroy(writer);
179 }
180 algos->destroy(algos);
181 }
182
183 /**
184 * Store algorithms supported by other peer
185 */
186 static void handle_supported_hash_algorithms(private_ike_init_t *this,
187 notify_payload_t *notify)
188 {
189 bio_reader_t *reader;
190 u_int16_t algo;
191 bool added = FALSE;
192
193 reader = bio_reader_create(notify->get_notification_data(notify));
194 while (reader->remaining(reader) >= 2 && reader->read_uint16(reader, &algo))
195 {
196 if (hasher_algorithm_for_ikev2(algo))
197 {
198 this->keymat->add_hash_algorithm(this->keymat, algo);
199 added = TRUE;
200 }
201 }
202 reader->destroy(reader);
203
204 if (added)
205 {
206 this->ike_sa->enable_extension(this->ike_sa, EXT_SIGNATURE_AUTH);
207 }
208 }
209
210 /**
211 * build the payloads for the message
212 */
213 static bool build_payloads(private_ike_init_t *this, message_t *message)
214 {
215 sa_payload_t *sa_payload;
216 ke_payload_t *ke_payload;
217 nonce_payload_t *nonce_payload;
218 linked_list_t *proposal_list;
219 ike_sa_id_t *id;
220 proposal_t *proposal;
221 enumerator_t *enumerator;
222
223 id = this->ike_sa->get_id(this->ike_sa);
224
225 this->config = this->ike_sa->get_ike_cfg(this->ike_sa);
226
227 if (this->initiator)
228 {
229 proposal_list = this->config->get_proposals(this->config);
230 if (this->old_sa)
231 {
232 /* include SPI of new IKE_SA when we are rekeying */
233 enumerator = proposal_list->create_enumerator(proposal_list);
234 while (enumerator->enumerate(enumerator, (void**)&proposal))
235 {
236 proposal->set_spi(proposal, id->get_initiator_spi(id));
237 }
238 enumerator->destroy(enumerator);
239 }
240
241 sa_payload = sa_payload_create_from_proposals_v2(proposal_list);
242 proposal_list->destroy_offset(proposal_list, offsetof(proposal_t, destroy));
243 }
244 else
245 {
246 if (this->old_sa)
247 {
248 /* include SPI of new IKE_SA when we are rekeying */
249 this->proposal->set_spi(this->proposal, id->get_responder_spi(id));
250 }
251 sa_payload = sa_payload_create_from_proposal_v2(this->proposal);
252 }
253 message->add_payload(message, (payload_t*)sa_payload);
254
255 nonce_payload = nonce_payload_create(PLV2_NONCE);
256 nonce_payload->set_nonce(nonce_payload, this->my_nonce);
257 ke_payload = ke_payload_create_from_diffie_hellman(PLV2_KEY_EXCHANGE,
258 this->dh);
259 if (!ke_payload)
260 {
261 DBG1(DBG_IKE, "creating KE payload failed");
262 return FALSE;
263 }
264
265 if (this->old_sa)
266 { /* payload order differs if we are rekeying */
267 message->add_payload(message, (payload_t*)nonce_payload);
268 message->add_payload(message, (payload_t*)ke_payload);
269 }
270 else
271 {
272 message->add_payload(message, (payload_t*)ke_payload);
273 message->add_payload(message, (payload_t*)nonce_payload);
274 }
275
276 /* negotiate fragmentation if we are not rekeying */
277 if (!this->old_sa &&
278 this->config->fragmentation(this->config) != FRAGMENTATION_NO)
279 {
280 if (this->initiator ||
281 this->ike_sa->supports_extension(this->ike_sa,
282 EXT_IKE_FRAGMENTATION))
283 {
284 message->add_notify(message, FALSE, FRAGMENTATION_SUPPORTED,
285 chunk_empty);
286 }
287 }
288 /* submit supported hash algorithms for signature authentication */
289 if (!this->old_sa && this->signature_authentication)
290 {
291 if (this->initiator ||
292 this->ike_sa->supports_extension(this->ike_sa,
293 EXT_SIGNATURE_AUTH))
294 {
295 send_supported_hash_algorithms(this, message);
296 }
297 }
298 return TRUE;
299 }
300
301 /**
302 * Read payloads from message
303 */
304 static void process_payloads(private_ike_init_t *this, message_t *message)
305 {
306 enumerator_t *enumerator;
307 payload_t *payload;
308 ke_payload_t *ke_payload = NULL;
309
310 enumerator = message->create_payload_enumerator(message);
311 while (enumerator->enumerate(enumerator, &payload))
312 {
313 switch (payload->get_type(payload))
314 {
315 case PLV2_SECURITY_ASSOCIATION:
316 {
317 sa_payload_t *sa_payload = (sa_payload_t*)payload;
318 linked_list_t *proposal_list;
319 bool private;
320
321 proposal_list = sa_payload->get_proposals(sa_payload);
322 private = this->ike_sa->supports_extension(this->ike_sa,
323 EXT_STRONGSWAN);
324 this->proposal = this->config->select_proposal(this->config,
325 proposal_list, private);
326 if (!this->proposal)
327 {
328 charon->bus->alert(charon->bus, ALERT_PROPOSAL_MISMATCH_IKE,
329 proposal_list);
330 }
331 proposal_list->destroy_offset(proposal_list,
332 offsetof(proposal_t, destroy));
333 break;
334 }
335 case PLV2_KEY_EXCHANGE:
336 {
337 ke_payload = (ke_payload_t*)payload;
338
339 this->dh_group = ke_payload->get_dh_group_number(ke_payload);
340 break;
341 }
342 case PLV2_NONCE:
343 {
344 nonce_payload_t *nonce_payload = (nonce_payload_t*)payload;
345
346 this->other_nonce = nonce_payload->get_nonce(nonce_payload);
347 break;
348 }
349 case PLV2_NOTIFY:
350 {
351 notify_payload_t *notify = (notify_payload_t*)payload;
352
353 switch (notify->get_notify_type(notify))
354 {
355 case FRAGMENTATION_SUPPORTED:
356 this->ike_sa->enable_extension(this->ike_sa,
357 EXT_IKE_FRAGMENTATION);
358 break;
359 case SIGNATURE_HASH_ALGORITHMS:
360 if (this->signature_authentication)
361 {
362 handle_supported_hash_algorithms(this, notify);
363 }
364 break;
365 default:
366 /* other notifies are handled elsewhere */
367 break;
368 }
369
370 }
371 default:
372 break;
373 }
374 }
375 enumerator->destroy(enumerator);
376
377 if (ke_payload && this->proposal &&
378 this->proposal->has_dh_group(this->proposal, this->dh_group))
379 {
380 if (!this->initiator)
381 {
382 this->dh = this->keymat->keymat.create_dh(
383 &this->keymat->keymat, this->dh_group);
384 }
385 if (this->dh)
386 {
387 this->dh->set_other_public_value(this->dh,
388 ke_payload->get_key_exchange_data(ke_payload));
389 }
390 }
391 }
392
393 METHOD(task_t, build_i, status_t,
394 private_ike_init_t *this, message_t *message)
395 {
396 this->config = this->ike_sa->get_ike_cfg(this->ike_sa);
397 DBG0(DBG_IKE, "initiating IKE_SA %s[%d] to %H",
398 this->ike_sa->get_name(this->ike_sa),
399 this->ike_sa->get_unique_id(this->ike_sa),
400 this->ike_sa->get_other_host(this->ike_sa));
401 this->ike_sa->set_state(this->ike_sa, IKE_CONNECTING);
402
403 if (this->retry >= MAX_RETRIES)
404 {
405 DBG1(DBG_IKE, "giving up after %d retries", MAX_RETRIES);
406 return FAILED;
407 }
408
409 /* if the DH group is set via use_dh_group(), we already have a DH object */
410 if (!this->dh)
411 {
412 this->dh_group = this->config->get_dh_group(this->config);
413 this->dh = this->keymat->keymat.create_dh(&this->keymat->keymat,
414 this->dh_group);
415 if (!this->dh)
416 {
417 DBG1(DBG_IKE, "configured DH group %N not supported",
418 diffie_hellman_group_names, this->dh_group);
419 return FAILED;
420 }
421 }
422
423 /* generate nonce only when we are trying the first time */
424 if (this->my_nonce.ptr == NULL)
425 {
426 nonce_gen_t *nonceg;
427
428 nonceg = this->keymat->keymat.create_nonce_gen(&this->keymat->keymat);
429 if (!nonceg)
430 {
431 DBG1(DBG_IKE, "no nonce generator found to create nonce");
432 return FAILED;
433 }
434 if (!nonceg->allocate_nonce(nonceg, NONCE_SIZE, &this->my_nonce))
435 {
436 DBG1(DBG_IKE, "nonce allocation failed");
437 nonceg->destroy(nonceg);
438 return FAILED;
439 }
440 nonceg->destroy(nonceg);
441 }
442
443 if (this->cookie.ptr)
444 {
445 message->add_notify(message, FALSE, COOKIE, this->cookie);
446 }
447
448 if (!build_payloads(this, message))
449 {
450 return FAILED;
451 }
452
453 #ifdef ME
454 {
455 chunk_t connect_id = this->ike_sa->get_connect_id(this->ike_sa);
456 if (connect_id.ptr)
457 {
458 message->add_notify(message, FALSE, ME_CONNECTID, connect_id);
459 }
460 }
461 #endif /* ME */
462
463 return NEED_MORE;
464 }
465
466 METHOD(task_t, process_r, status_t,
467 private_ike_init_t *this, message_t *message)
468 {
469 nonce_gen_t *nonceg;
470
471 this->config = this->ike_sa->get_ike_cfg(this->ike_sa);
472 DBG0(DBG_IKE, "%H is initiating an IKE_SA", message->get_source(message));
473 this->ike_sa->set_state(this->ike_sa, IKE_CONNECTING);
474
475 nonceg = this->keymat->keymat.create_nonce_gen(&this->keymat->keymat);
476 if (!nonceg)
477 {
478 DBG1(DBG_IKE, "no nonce generator found to create nonce");
479 return FAILED;
480 }
481 if (!nonceg->allocate_nonce(nonceg, NONCE_SIZE, &this->my_nonce))
482 {
483 DBG1(DBG_IKE, "nonce allocation failed");
484 nonceg->destroy(nonceg);
485 return FAILED;
486 }
487 nonceg->destroy(nonceg);
488
489 #ifdef ME
490 {
491 notify_payload_t *notify = message->get_notify(message, ME_CONNECTID);
492 if (notify)
493 {
494 chunk_t connect_id = notify->get_notification_data(notify);
495 DBG2(DBG_IKE, "received ME_CONNECTID %#B", &connect_id);
496 charon->connect_manager->stop_checks(charon->connect_manager,
497 connect_id);
498 }
499 }
500 #endif /* ME */
501
502 process_payloads(this, message);
503
504 return NEED_MORE;
505 }
506
507 /**
508 * Derive the keymat for the IKE_SA
509 */
510 static bool derive_keys(private_ike_init_t *this,
511 chunk_t nonce_i, chunk_t nonce_r)
512 {
513 keymat_v2_t *old_keymat;
514 pseudo_random_function_t prf_alg = PRF_UNDEFINED;
515 chunk_t skd = chunk_empty;
516 ike_sa_id_t *id;
517
518 id = this->ike_sa->get_id(this->ike_sa);
519 if (this->old_sa)
520 {
521 /* rekeying: Include old SKd, use old PRF, apply SPI */
522 old_keymat = (keymat_v2_t*)this->old_sa->get_keymat(this->old_sa);
523 prf_alg = old_keymat->get_skd(old_keymat, &skd);
524 if (this->initiator)
525 {
526 id->set_responder_spi(id, this->proposal->get_spi(this->proposal));
527 }
528 else
529 {
530 id->set_initiator_spi(id, this->proposal->get_spi(this->proposal));
531 }
532 }
533 if (!this->keymat->derive_ike_keys(this->keymat, this->proposal, this->dh,
534 nonce_i, nonce_r, id, prf_alg, skd))
535 {
536 return FALSE;
537 }
538 charon->bus->ike_keys(charon->bus, this->ike_sa, this->dh, chunk_empty,
539 nonce_i, nonce_r, this->old_sa, NULL);
540 return TRUE;
541 }
542
543 METHOD(task_t, build_r, status_t,
544 private_ike_init_t *this, message_t *message)
545 {
546 /* check if we have everything we need */
547 if (this->proposal == NULL ||
548 this->other_nonce.len == 0 || this->my_nonce.len == 0)
549 {
550 DBG1(DBG_IKE, "received proposals inacceptable");
551 message->add_notify(message, TRUE, NO_PROPOSAL_CHOSEN, chunk_empty);
552 return FAILED;
553 }
554 this->ike_sa->set_proposal(this->ike_sa, this->proposal);
555
556 if (this->dh == NULL ||
557 !this->proposal->has_dh_group(this->proposal, this->dh_group))
558 {
559 u_int16_t group;
560
561 if (this->proposal->get_algorithm(this->proposal, DIFFIE_HELLMAN_GROUP,
562 &group, NULL))
563 {
564 DBG1(DBG_IKE, "DH group %N inacceptable, requesting %N",
565 diffie_hellman_group_names, this->dh_group,
566 diffie_hellman_group_names, group);
567 this->dh_group = group;
568 group = htons(group);
569 message->add_notify(message, FALSE, INVALID_KE_PAYLOAD,
570 chunk_from_thing(group));
571 }
572 else
573 {
574 DBG1(DBG_IKE, "no acceptable proposal found");
575 }
576 return FAILED;
577 }
578
579 if (!derive_keys(this, this->other_nonce, this->my_nonce))
580 {
581 DBG1(DBG_IKE, "key derivation failed");
582 message->add_notify(message, TRUE, NO_PROPOSAL_CHOSEN, chunk_empty);
583 return FAILED;
584 }
585 if (!build_payloads(this, message))
586 {
587 message->add_notify(message, TRUE, NO_PROPOSAL_CHOSEN, chunk_empty);
588 return FAILED;
589 }
590 return SUCCESS;
591 }
592
593 /**
594 * Raise alerts for received notify errors
595 */
596 static void raise_alerts(private_ike_init_t *this, notify_type_t type)
597 {
598 linked_list_t *list;
599
600 switch (type)
601 {
602 case NO_PROPOSAL_CHOSEN:
603 list = this->config->get_proposals(this->config);
604 charon->bus->alert(charon->bus, ALERT_PROPOSAL_MISMATCH_IKE, list);
605 list->destroy_offset(list, offsetof(proposal_t, destroy));
606 break;
607 default:
608 break;
609 }
610 }
611
612 METHOD(task_t, process_i, status_t,
613 private_ike_init_t *this, message_t *message)
614 {
615 enumerator_t *enumerator;
616 payload_t *payload;
617
618 /* check for erroneous notifies */
619 enumerator = message->create_payload_enumerator(message);
620 while (enumerator->enumerate(enumerator, &payload))
621 {
622 if (payload->get_type(payload) == PLV2_NOTIFY)
623 {
624 notify_payload_t *notify = (notify_payload_t*)payload;
625 notify_type_t type = notify->get_notify_type(notify);
626
627 switch (type)
628 {
629 case INVALID_KE_PAYLOAD:
630 {
631 chunk_t data;
632 diffie_hellman_group_t bad_group;
633
634 bad_group = this->dh_group;
635 data = notify->get_notification_data(notify);
636 this->dh_group = ntohs(*((u_int16_t*)data.ptr));
637 DBG1(DBG_IKE, "peer didn't accept DH group %N, "
638 "it requested %N", diffie_hellman_group_names,
639 bad_group, diffie_hellman_group_names, this->dh_group);
640
641 if (this->old_sa == NULL)
642 { /* reset the IKE_SA if we are not rekeying */
643 this->ike_sa->reset(this->ike_sa);
644 }
645
646 enumerator->destroy(enumerator);
647 this->retry++;
648 return NEED_MORE;
649 }
650 case NAT_DETECTION_SOURCE_IP:
651 case NAT_DETECTION_DESTINATION_IP:
652 /* skip, handled in ike_natd_t */
653 break;
654 case MULTIPLE_AUTH_SUPPORTED:
655 /* handled in ike_auth_t */
656 break;
657 case COOKIE:
658 {
659 chunk_free(&this->cookie);
660 this->cookie = chunk_clone(notify->get_notification_data(notify));
661 this->ike_sa->reset(this->ike_sa);
662 enumerator->destroy(enumerator);
663 DBG2(DBG_IKE, "received %N notify", notify_type_names, type);
664 this->retry++;
665 return NEED_MORE;
666 }
667 default:
668 {
669 if (type <= 16383)
670 {
671 DBG1(DBG_IKE, "received %N notify error",
672 notify_type_names, type);
673 enumerator->destroy(enumerator);
674 raise_alerts(this, type);
675 return FAILED;
676 }
677 DBG2(DBG_IKE, "received %N notify",
678 notify_type_names, type);
679 break;
680 }
681 }
682 }
683 }
684 enumerator->destroy(enumerator);
685
686 process_payloads(this, message);
687
688 /* check if we have everything */
689 if (this->proposal == NULL ||
690 this->other_nonce.len == 0 || this->my_nonce.len == 0)
691 {
692 DBG1(DBG_IKE, "peers proposal selection invalid");
693 return FAILED;
694 }
695 this->ike_sa->set_proposal(this->ike_sa, this->proposal);
696
697 if (this->dh == NULL ||
698 !this->proposal->has_dh_group(this->proposal, this->dh_group))
699 {
700 DBG1(DBG_IKE, "peer DH group selection invalid");
701 return FAILED;
702 }
703
704 if (!derive_keys(this, this->my_nonce, this->other_nonce))
705 {
706 DBG1(DBG_IKE, "key derivation failed");
707 return FAILED;
708 }
709 return SUCCESS;
710 }
711
712 METHOD(task_t, get_type, task_type_t,
713 private_ike_init_t *this)
714 {
715 return TASK_IKE_INIT;
716 }
717
718 METHOD(task_t, migrate, void,
719 private_ike_init_t *this, ike_sa_t *ike_sa)
720 {
721 DESTROY_IF(this->proposal);
722 chunk_free(&this->other_nonce);
723
724 this->ike_sa = ike_sa;
725 this->keymat = (keymat_v2_t*)ike_sa->get_keymat(ike_sa);
726 this->proposal = NULL;
727 if (this->dh && this->dh->get_dh_group(this->dh) != this->dh_group)
728 { /* reset DH value only if group changed (INVALID_KE_PAYLOAD) */
729 this->dh->destroy(this->dh);
730 this->dh = this->keymat->keymat.create_dh(&this->keymat->keymat,
731 this->dh_group);
732 }
733 }
734
735 METHOD(task_t, destroy, void,
736 private_ike_init_t *this)
737 {
738 DESTROY_IF(this->dh);
739 DESTROY_IF(this->proposal);
740 chunk_free(&this->my_nonce);
741 chunk_free(&this->other_nonce);
742 chunk_free(&this->cookie);
743 free(this);
744 }
745
746 METHOD(ike_init_t, get_lower_nonce, chunk_t,
747 private_ike_init_t *this)
748 {
749 if (memcmp(this->my_nonce.ptr, this->other_nonce.ptr,
750 min(this->my_nonce.len, this->other_nonce.len)) < 0)
751 {
752 return this->my_nonce;
753 }
754 else
755 {
756 return this->other_nonce;
757 }
758 }
759
760 /*
761 * Described in header.
762 */
763 ike_init_t *ike_init_create(ike_sa_t *ike_sa, bool initiator, ike_sa_t *old_sa)
764 {
765 private_ike_init_t *this;
766
767 INIT(this,
768 .public = {
769 .task = {
770 .get_type = _get_type,
771 .migrate = _migrate,
772 .destroy = _destroy,
773 },
774 .get_lower_nonce = _get_lower_nonce,
775 },
776 .ike_sa = ike_sa,
777 .initiator = initiator,
778 .dh_group = MODP_NONE,
779 .keymat = (keymat_v2_t*)ike_sa->get_keymat(ike_sa),
780 .old_sa = old_sa,
781 .signature_authentication = lib->settings->get_bool(lib->settings,
782 "%s.signature_authentication", TRUE, lib->ns),
783 );
784
785 if (initiator)
786 {
787 this->public.task.build = _build_i;
788 this->public.task.process = _process_i;
789 }
790 else
791 {
792 this->public.task.build = _build_r;
793 this->public.task.process = _process_r;
794 }
795
796 return &this->public;
797 }