1 /* $NetBSD: remoteconf.c,v 1.17 2009/08/19 13:54:07 vanhu Exp $ */
3 /* Id: remoteconf.c,v 1.38 2006/05/06 15:52:44 manubsd Exp */
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include <sys/types.h>
37 #include <sys/param.h>
38 #include <sys/socket.h>
39 #include <sys/queue.h>
41 #include <netinet/in.h>
42 #include <netinet/in_systm.h>
43 #include <netinet/ip.h>
60 #include "isakmp_var.h"
62 #include "isakmp_xauth.h"
65 #include "ipsec_doi.h"
66 #include "crypto_openssl.h"
68 #include "remoteconf.h"
69 #include "localconf.h"
70 #include "grabmyaddr.h"
76 #include "algorithm.h"
77 #include "nattraversal.h"
78 #include "isakmp_frag.h"
82 static TAILQ_HEAD(_rmtree
, remoteconf
) rmtree
, rmtree_save
, rmtree_tmp
;
85 * Script hook names and script hook paths
87 char *script_names
[SCRIPT_MAX
+ 1] = { "phase1_up", "phase1_down" };
92 rmconf_match_identity(rmconf
, id_p
)
93 struct remoteconf
*rmconf
;
96 struct ipsecdoi_id_b
*id_b
= (struct ipsecdoi_id_b
*) id_p
->v
;
101 struct genlist_entry
*gpb
;
103 /* compare with the ID if specified. */
104 if (!genlist_next(rmconf
->idvl_p
, 0))
107 for (id
= genlist_next(rmconf
->idvl_p
, &gpb
); id
; id
= genlist_next(0, &gpb
)) {
108 /* check the type of both IDs */
109 if (id
->idtype
!= doi2idtype(id_b
->type
))
110 continue; /* ID type mismatch */
114 /* compare defined ID with the ID sent by peer. */
115 switch (id
->idtype
) {
117 ident
.v
= id_p
->v
+ sizeof(*id_b
);
118 ident
.l
= id_p
->l
- sizeof(*id_b
);
119 if (eay_cmp_asn1dn(id
->id
, &ident
) == 0)
123 sa
= (struct sockaddr
*)id
->id
->v
;
124 sa2
= (caddr_t
)(id_b
+ 1);
125 switch (sa
->sa_family
) {
127 if (id_p
->l
- sizeof(*id_b
) != sizeof(struct in_addr
))
128 continue; /* ID value mismatch */
129 sa1
= (caddr_t
) &((struct sockaddr_in
*)sa
)->sin_addr
;
130 if (memcmp(sa1
, sa2
, sizeof(struct in_addr
)) == 0)
135 if (id_p
->l
- sizeof(*id_b
) != sizeof(struct in6_addr
))
136 continue; /* ID value mismatch */
137 sa1
= (caddr_t
) &((struct sockaddr_in6
*)sa
)->sin6_addr
;
138 if (memcmp(sa1
, sa2
, sizeof(struct in6_addr
)) == 0)
147 if (memcmp(id
->id
->v
, id_b
+ 1, id
->id
->l
) == 0)
153 plog(LLV_WARNING
, LOCATION
, NULL
, "No ID match.\n");
154 if (rmconf
->verify_identifier
)
155 return ISAKMP_NTYPE_INVALID_ID_INFORMATION
;
161 rmconf_match_etype_and_approval(rmconf
, etype
, approval
)
162 struct remoteconf
*rmconf
;
164 struct isakmpsa
*approval
;
168 if (check_etypeok(rmconf
, (void *) (intptr_t) etype
) == 0)
169 return ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN
;
171 if (approval
== NULL
)
174 if (etype
== ISAKMP_ETYPE_AGG
&&
175 approval
->dh_group
!= rmconf
->dh_group
)
176 return ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN
;
178 if (checkisakmpsa(rmconf
->pcheck_level
, approval
,
179 rmconf
->proposal
) == NULL
)
180 return ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN
;
185 enum rmconf_match_t
{
187 MATCH_BASIC
= 0x0000001,
188 MATCH_ADDRESS
= 0x0000002,
189 MATCH_SA
= 0x0000004,
190 MATCH_IDENTITY
= 0x0000008,
191 MATCH_AUTH_IDENTITY
= 0x0000010,
195 rmconf_match_type(rmsel
, rmconf
)
196 struct rmconfselector
*rmsel
;
197 struct remoteconf
*rmconf
;
199 int ret
= MATCH_NONE
;
201 /* No match at all: unwanted anonymous */
202 if ((rmsel
->flags
& GETRMCONF_F_NO_ANONYMOUS
) &&
203 rmconf
->remote
->sa_family
== AF_UNSPEC
)
206 if ((rmsel
->flags
& GETRMCONF_F_NO_PASSIVE
) && rmconf
->passive
)
212 if (rmsel
->remote
!= NULL
) {
213 if (rmconf
->remote
->sa_family
!= AF_UNSPEC
) {
214 if (cmpsaddr(rmsel
->remote
, rmconf
->remote
) == CMPSADDR_MISMATCH
)
217 /* Address matched */
218 ret
|= MATCH_ADDRESS
;
222 /* Check etype and approval */
223 if (rmsel
->etype
!= ISAKMP_ETYPE_NONE
) {
224 if (rmconf_match_etype_and_approval(rmconf
, rmsel
->etype
,
225 rmsel
->approval
) != 0)
231 if (rmsel
->identity
!= NULL
&& rmconf
->verify_identifier
) {
232 if (rmconf_match_identity(rmconf
, rmsel
->identity
) != 0)
234 ret
|= MATCH_IDENTITY
;
237 /* Check certificate request */
238 if (rmsel
->certificate_request
!= NULL
) {
239 if (oakley_get_certtype(rmsel
->certificate_request
) !=
240 oakley_get_certtype(rmconf
->mycert
))
243 if (rmsel
->certificate_request
->l
> 1) {
246 issuer
= eay_get_x509asn1issuername(rmconf
->mycert
);
247 if (rmsel
->certificate_request
->l
- 1 != issuer
->l
||
248 memcmp(rmsel
->certificate_request
->v
+ 1,
249 issuer
->v
, issuer
->l
) != 0) {
255 if (!rmconf
->match_empty_cr
)
259 ret
|= MATCH_AUTH_IDENTITY
;
265 void rmconf_selector_from_ph1(rmsel
, iph1
)
266 struct rmconfselector
*rmsel
;
267 struct ph1handle
*iph1
;
269 memset(rmsel
, 0, sizeof(*rmsel
));
271 rmsel
->remote
= iph1
->remote
;
272 rmsel
->etype
= iph1
->etype
;
273 rmsel
->approval
= iph1
->approval
;
274 rmsel
->identity
= iph1
->id_p
;
275 rmsel
->certificate_request
= iph1
->cr_p
;
279 enumrmconf(rmsel
, enum_func
, enum_arg
)
280 struct rmconfselector
*rmsel
;
281 int (* enum_func
)(struct remoteconf
*rmconf
, void *arg
);
284 struct remoteconf
*p
;
287 RACOON_TAILQ_FOREACH_REVERSE(p
, &rmtree
, _rmtree
, chain
) {
289 if (rmconf_match_type(rmsel
, p
) == MATCH_NONE
)
293 plog(LLV_DEBUG2
, LOCATION
, NULL
,
294 "enumrmconf: \"%s\" matches.\n", p
->name
);
296 ret
= (*enum_func
)(p
, enum_arg
);
304 struct rmconf_find_context
{
305 struct rmconfselector sel
;
307 struct remoteconf
*rmconf
;
313 rmconf_find(rmconf
, ctx
)
314 struct remoteconf
*rmconf
;
317 struct rmconf_find_context
*fctx
= (struct rmconf_find_context
*) ctx
;
320 /* First matching remote conf? */
321 match_type
= rmconf_match_type(&fctx
->sel
, rmconf
);
323 if (fctx
->rmconf
!= NULL
) {
324 /* More ambiguous matches are ignored. */
325 if (match_type
< fctx
->match_type
)
328 if (match_type
== fctx
->match_type
) {
329 /* Ambiguous match */
335 /* More exact match found */
336 fctx
->match_type
= match_type
;
338 fctx
->rmconf
= rmconf
;
344 * search remote configuration.
345 * don't use port number to search if its value is either IPSEC_PORT_ANY.
346 * If matching anonymous entry, then new entry is copied from anonymous entry.
347 * If no anonymous entry found, then return NULL.
349 * Other: remote configuration entry.
353 getrmconf(remote
, flags
)
354 struct sockaddr
*remote
;
357 struct rmconf_find_context ctx
;
360 memset(&ctx
, 0, sizeof(ctx
));
361 ctx
.sel
.flags
= flags
;
362 ctx
.sel
.remote
= remote
;
364 if (enumrmconf(&ctx
.sel
, rmconf_find
, &ctx
) != 0) {
365 plog(LLV_ERROR
, LOCATION
, remote
,
366 "multiple exact configurations.\n");
370 if (ctx
.rmconf
== NULL
) {
371 plog(LLV_DEBUG
, LOCATION
, remote
,
372 "no remote configuration found.\n");
376 if (ctx
.num_found
!= 1) {
377 plog(LLV_DEBUG
, LOCATION
, remote
,
378 "multiple non-exact configurations found.\n");
382 plog(LLV_DEBUG
, LOCATION
, remote
,
383 "configuration \"%s\" selected.\n",
390 getrmconf_by_ph1(iph1
)
391 struct ph1handle
*iph1
;
393 struct rmconf_find_context ctx
;
395 memset(&ctx
, 0, sizeof(ctx
));
396 rmconf_selector_from_ph1(&ctx
.sel
, iph1
);
397 if (loglevel
>= LLV_DEBUG
) {
400 if (iph1
->id_p
!= NULL
)
401 idstr
= ipsecdoi_id2str(iph1
->id_p
);
403 plog(LLV_DEBUG
, LOCATION
, iph1
->remote
,
404 "getrmconf_by_ph1: remote %s, identity %s.\n",
405 saddr2str(iph1
->remote
), idstr
? idstr
: "<any>");
411 if (enumrmconf(&ctx
.sel
, rmconf_find
, &ctx
) != 0) {
412 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
413 "multiple exact configurations.\n");
414 return RMCONF_ERR_MULTIPLE
;
417 if (ctx
.rmconf
== NULL
) {
418 plog(LLV_DEBUG
, LOCATION
, iph1
->remote
,
419 "no remote configuration found\n");
423 if (ctx
.num_found
!= 1) {
424 plog(LLV_DEBUG
, LOCATION
, iph1
->remote
,
425 "multiple non-exact configurations found.\n");
426 return RMCONF_ERR_MULTIPLE
;
429 plog(LLV_DEBUG
, LOCATION
, iph1
->remote
,
430 "configuration \"%s\" selected.\n",
437 getrmconf_by_name(name
)
440 struct remoteconf
*p
;
442 plog(LLV_DEBUG
, LOCATION
, NULL
,
443 "getrmconf_by_name: remote \"%s\".\n",
446 RACOON_TAILQ_FOREACH_REVERSE(p
, &rmtree
, _rmtree
, chain
) {
450 if (strcmp(name
, p
->name
) == 0)
460 struct remoteconf
*new;
463 new = racoon_calloc(1, sizeof(*new));
467 new->proposal
= NULL
;
470 new->doitype
= IPSEC_DOI
;
471 new->sittype
= IPSECDOI_SIT_IDENTITY_ONLY
;
472 new->idvtype
= IDTYPE_UNDEFINED
;
473 new->idvl_p
= genlist_init();
474 new->nonce_size
= DEFAULT_NONCE_SIZE
;
475 new->passive
= FALSE
;
476 new->ike_frag
= FALSE
;
477 new->esp_frag
= IP_MAXPACKET
;
478 new->ini_contact
= TRUE
;
479 new->mode_cfg
= FALSE
;
480 new->pcheck_level
= PROP_CHECK_STRICT
;
481 new->verify_identifier
= FALSE
;
482 new->verify_cert
= TRUE
;
483 new->cacertfile
= NULL
;
484 new->send_cert
= TRUE
;
486 new->match_empty_cr
= FALSE
;
487 new->support_proxy
= FALSE
;
488 for (i
= 0; i
<= SCRIPT_MAX
; i
++)
489 new->script
[i
] = NULL
;
490 new->gen_policy
= FALSE
;
491 new->nat_traversal
= FALSE
;
492 new->rsa_private
= genlist_init();
493 new->rsa_public
= genlist_init();
497 new->dpd
= TRUE
; /* Enable DPD support by default */
498 new->dpd_interval
= 0; /* Disable DPD checks by default */
500 new->dpd_maxfails
= 5;
502 new->rekey
= REKEY_ON
;
504 new->weak_phase1_check
= 0;
510 new->lifetime
= oakley_get_defaultlifetime();
521 struct idspec
*old
= (struct idspec
*) entry
;
523 if (!id
) return (void *) -1;
525 if (set_identifier(&id
->id
, old
->idtype
, old
->id
) != 0) {
530 id
->idtype
= old
->idtype
;
532 genlist_append(arg
, id
);
538 struct remoteconf
*rmconf
;
540 struct remoteconf
*new;
541 struct proposalspec
*prspec
;
543 new = racoon_calloc(1, sizeof(*new));
547 memcpy(new, rmconf
, sizeof(*new));
549 new->inherited_from
= rmconf
;
551 /* duplicate dynamic structures */
553 new->etypes
= dupetypes(new->etypes
);
554 new->idvl_p
= genlist_init();
555 genlist_foreach(rmconf
->idvl_p
, dupidvl
, new->idvl_p
);
561 idspec_free(void *data
)
563 vfree (((struct idspec
*)data
)->id
);
569 struct remoteconf
*rmconf
;
573 xauth_rmconf_delete(&rmconf
->xauth
);
576 deletypes(rmconf
->etypes
);
580 genlist_free(rmconf
->idvl_p
, idspec_free
);
582 oakley_dhgrp_free(rmconf
->dhgrp
);
583 if (rmconf
->proposal
)
584 delisakmpsa(rmconf
->proposal
);
586 vfree(rmconf
->mycert
);
587 if (rmconf
->mycertfile
)
588 racoon_free(rmconf
->mycertfile
);
589 if (rmconf
->myprivfile
)
590 racoon_free(rmconf
->myprivfile
);
591 if (rmconf
->peerscert
)
592 vfree(rmconf
->peerscert
);
593 if (rmconf
->peerscertfile
)
594 racoon_free(rmconf
->peerscertfile
);
596 vfree(rmconf
->cacert
);
597 if (rmconf
->cacertfile
)
598 racoon_free(rmconf
->cacertfile
);
600 racoon_free(rmconf
->name
);
609 oakley_dhgrp_free(sa
->dhgrp
);
611 delisakmpsa(sa
->next
);
628 new = racoon_malloc(sizeof(struct etypes
));
632 new->type
= orig
->type
;
636 new->next
=dupetypes(orig
->next
);
651 * insert into head of list.
655 struct remoteconf
*new;
657 if (new->name
== NULL
) {
658 new->name
= racoon_strdup(saddr2str(new->remote
));
660 if (new->remote
== NULL
) {
661 new->remote
= newsaddr(sizeof(struct sockaddr
));
662 new->remote
->sa_family
= AF_UNSPEC
;
665 TAILQ_INSERT_HEAD(&rmtree
, new, chain
);
670 struct remoteconf
*rmconf
;
672 TAILQ_REMOVE(&rmtree
, rmconf
, chain
);
678 struct remoteconf
*p
, *next
;
680 for (p
= TAILQ_FIRST(&rmtree
); p
; p
= next
) {
681 next
= TAILQ_NEXT(p
, chain
);
712 /* check exchange type to be acceptable */
714 check_etypeok(rmconf
, ctx
)
715 struct remoteconf
*rmconf
;
718 u_int8_t etype
= (u_int8_t
) (intptr_t) ctx
;
721 for (e
= rmconf
->etypes
; e
!= NULL
; e
= e
->next
) {
722 if (e
->type
== etype
)
733 struct isakmpsa
*new;
735 new = racoon_calloc(1, sizeof(*new));
740 * Just for sanity, make sure this is initialized. This is
741 * filled in for real when the ISAKMP proposal is configured.
743 new->vendorid
= VENDORID_UNKNOWN
;
754 * insert into tail of list.
757 insisakmpsa(new, rmconf
)
758 struct isakmpsa
*new;
759 struct remoteconf
*rmconf
;
763 if (rmconf
->proposal
== NULL
) {
764 rmconf
->proposal
= new;
768 for (p
= rmconf
->proposal
; p
->next
!= NULL
; p
= p
->next
)
774 dump_peers_identifiers (void *entry
, void *arg
)
776 struct idspec
*id
= (struct idspec
*) entry
;
777 char buf
[1024], *pbuf
;
779 pbuf
+= sprintf (pbuf
, "\tpeers_identifier %s",
780 s_idtype (id
->idtype
));
782 pbuf
+= sprintf (pbuf
, " \"%s\"", id
->id
->v
);
783 plog(LLV_INFO
, LOCATION
, NULL
, "%s;\n", buf
);
788 dump_rmconf_single (struct remoteconf
*p
, void *data
)
790 struct etypes
*etype
= p
->etypes
;
791 struct isakmpsa
*prop
= p
->proposal
;
792 char buf
[1024], *pbuf
;
796 pbuf
+= sprintf(pbuf
, "remote \"%s\"", p
->name
);
797 if (p
->inherited_from
)
798 pbuf
+= sprintf(pbuf
, " inherit \"%s\"",
799 p
->inherited_from
->name
);
800 plog(LLV_INFO
, LOCATION
, NULL
, "%s {\n", buf
);
802 pbuf
+= sprintf(pbuf
, "\texchange_type ");
804 pbuf
+= sprintf (pbuf
, "%s%s", s_etype(etype
->type
),
805 etype
->next
!= NULL
? ", " : ";\n");
808 plog(LLV_INFO
, LOCATION
, NULL
, "%s", buf
);
809 plog(LLV_INFO
, LOCATION
, NULL
, "\tdoi %s;\n", s_doi(p
->doitype
));
811 pbuf
+= sprintf(pbuf
, "\tmy_identifier %s", s_idtype (p
->idvtype
));
812 if (p
->idvtype
== IDTYPE_ASN1DN
) {
813 plog(LLV_INFO
, LOCATION
, NULL
, "%s;\n", buf
);
814 plog(LLV_INFO
, LOCATION
, NULL
,
815 "\tcertificate_type %s \"%s\" \"%s\";\n",
816 oakley_get_certtype(p
->mycert
) == ISAKMP_CERT_X509SIGN
817 ? "x509" : "*UNKNOWN*",
818 p
->mycertfile
, p
->myprivfile
);
820 switch (oakley_get_certtype(p
->peerscert
)) {
821 case ISAKMP_CERT_NONE
:
822 plog(LLV_INFO
, LOCATION
, NULL
,
823 "\t/* peers certificate from payload */\n");
825 case ISAKMP_CERT_X509SIGN
:
826 plog(LLV_INFO
, LOCATION
, NULL
,
827 "\tpeers_certfile \"%s\";\n", p
->peerscertfile
);
829 case ISAKMP_CERT_DNS
:
830 plog(LLV_INFO
, LOCATION
, NULL
,
831 "\tpeers_certfile dnssec;\n");
834 plog(LLV_INFO
, LOCATION
, NULL
,
835 "\tpeers_certfile *UNKNOWN* (%d)\n",
836 oakley_get_certtype(p
->peerscert
));
842 pbuf
+= sprintf (pbuf
, " \"%s\"", p
->idv
->v
);
843 plog(LLV_INFO
, LOCATION
, NULL
, "%s;\n", buf
);
844 genlist_foreach(p
->idvl_p
, &dump_peers_identifiers
, NULL
);
847 plog(LLV_INFO
, LOCATION
, NULL
, "\trekey %s;\n",
848 p
->rekey
== REKEY_FORCE
? "force" : s_switch (p
->rekey
));
849 plog(LLV_INFO
, LOCATION
, NULL
, "\tsend_cert %s;\n",
850 s_switch (p
->send_cert
));
851 plog(LLV_INFO
, LOCATION
, NULL
, "\tsend_cr %s;\n",
852 s_switch (p
->send_cr
));
853 plog(LLV_INFO
, LOCATION
, NULL
, "\tmatch_empty_cr %s;\n",
854 s_switch (p
->match_empty_cr
));
855 plog(LLV_INFO
, LOCATION
, NULL
, "\tverify_cert %s;\n",
856 s_switch (p
->verify_cert
));
857 plog(LLV_INFO
, LOCATION
, NULL
, "\tverify_identifier %s;\n",
858 s_switch (p
->verify_identifier
));
859 plog(LLV_INFO
, LOCATION
, NULL
, "\tnat_traversal %s;\n",
860 p
->nat_traversal
== NATT_FORCE
?
861 "force" : s_switch (p
->nat_traversal
));
862 plog(LLV_INFO
, LOCATION
, NULL
, "\tnonce_size %d;\n",
864 plog(LLV_INFO
, LOCATION
, NULL
, "\tpassive %s;\n",
865 s_switch (p
->passive
));
866 plog(LLV_INFO
, LOCATION
, NULL
, "\tike_frag %s;\n",
867 p
->ike_frag
== ISAKMP_FRAG_FORCE
?
868 "force" : s_switch (p
->ike_frag
));
869 plog(LLV_INFO
, LOCATION
, NULL
, "\tesp_frag %d;\n", p
->esp_frag
);
870 plog(LLV_INFO
, LOCATION
, NULL
, "\tinitial_contact %s;\n",
871 s_switch (p
->ini_contact
));
872 plog(LLV_INFO
, LOCATION
, NULL
, "\tgenerate_policy %s;\n",
873 s_switch (p
->gen_policy
));
874 plog(LLV_INFO
, LOCATION
, NULL
, "\tsupport_proxy %s;\n",
875 s_switch (p
->support_proxy
));
878 plog(LLV_INFO
, LOCATION
, NULL
, "\n");
879 plog(LLV_INFO
, LOCATION
, NULL
,
880 "\t/* prop_no=%d, trns_no=%d */\n",
881 prop
->prop_no
, prop
->trns_no
);
882 plog(LLV_INFO
, LOCATION
, NULL
, "\tproposal {\n");
883 plog(LLV_INFO
, LOCATION
, NULL
, "\t\tlifetime time %lu sec;\n",
884 (long)prop
->lifetime
);
885 plog(LLV_INFO
, LOCATION
, NULL
, "\t\tlifetime bytes %zd;\n",
887 plog(LLV_INFO
, LOCATION
, NULL
, "\t\tdh_group %s;\n",
888 alg_oakley_dhdef_name(prop
->dh_group
));
889 plog(LLV_INFO
, LOCATION
, NULL
, "\t\tencryption_algorithm %s;\n",
890 alg_oakley_encdef_name(prop
->enctype
));
891 plog(LLV_INFO
, LOCATION
, NULL
, "\t\thash_algorithm %s;\n",
892 alg_oakley_hashdef_name(prop
->hashtype
));
893 plog(LLV_INFO
, LOCATION
, NULL
, "\t\tauthentication_method %s;\n",
894 alg_oakley_authdef_name(prop
->authmethod
));
895 plog(LLV_INFO
, LOCATION
, NULL
, "\t}\n");
898 plog(LLV_INFO
, LOCATION
, NULL
, "}\n");
899 plog(LLV_INFO
, LOCATION
, NULL
, "\n");
907 enumrmconf(NULL
, dump_rmconf_single
, NULL
);
915 new = racoon_calloc(1, sizeof(*new));
918 new->idtype
= IDTYPE_ADDRESS
;
924 script_path_add(path
)
929 vchar_t
*new_storage
;
934 script_dir
= lcconf
->pathinfo
[LC_PATHTYPE_SCRIPT
];
936 /* Try to find the script in the script directory */
937 if ((path
->v
[0] != '/') && (script_dir
!= NULL
)) {
938 len
= strlen(script_dir
) + sizeof("/") + path
->l
+ 1;
940 if ((new_path
= vmalloc(len
)) == NULL
) {
941 plog(LLV_ERROR
, LOCATION
, NULL
,
942 "Cannot allocate memory: %s\n", strerror(errno
));
946 new_path
->v
[0] = '\0';
947 (void)strlcat(new_path
->v
, script_dir
, len
);
948 (void)strlcat(new_path
->v
, "/", len
);
949 (void)strlcat(new_path
->v
, path
->v
, len
);
960 dupisakmpsa(struct isakmpsa
*sa
)
962 struct isakmpsa
*res
= NULL
;
973 if (sa
->gssid
!= NULL
)
974 res
->gssid
= vdup(sa
->gssid
);
978 if(sa
->dhgrp
!= NULL
)
979 oakley_setdhgroup(sa
->dh_group
, &res
->dhgrp
);
987 isakmpsa_switch_authmethod(authmethod
)
991 case OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_R
:
992 authmethod
= OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_I
;
994 case OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_R
:
995 authmethod
= OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_I
;
997 case OAKLEY_ATTR_AUTH_METHOD_XAUTH_PSKEY_R
:
998 authmethod
= OAKLEY_ATTR_AUTH_METHOD_XAUTH_PSKEY_I
;
1000 case OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSASIG_R
:
1001 authmethod
= OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSASIG_I
;
1003 case OAKLEY_ATTR_AUTH_METHOD_XAUTH_DSSSIG_R
:
1004 authmethod
= OAKLEY_ATTR_AUTH_METHOD_XAUTH_DSSSIG_I
;
1006 case OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSAENC_R
:
1007 authmethod
= OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSAENC_I
;
1009 case OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSAREV_R
:
1010 authmethod
= OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSAREV_I
;
1021 * Given a proposed ISAKMP SA, and a list of acceptable
1022 * ISAKMP SAs, it compares using pcheck_level policy and
1023 * returns first match (if any).
1026 checkisakmpsa(pcheck_level
, proposal
, acceptable
)
1028 struct isakmpsa
*proposal
, *acceptable
;
1032 for (p
= acceptable
; p
!= NULL
; p
= p
->next
){
1033 if (proposal
->authmethod
!= isakmpsa_switch_authmethod(p
->authmethod
) ||
1034 proposal
->enctype
!= p
->enctype
||
1035 proposal
->dh_group
!= p
->dh_group
||
1036 proposal
->hashtype
!= p
->hashtype
)
1039 switch (pcheck_level
) {
1040 case PROP_CHECK_OBEY
:
1043 case PROP_CHECK_CLAIM
:
1044 case PROP_CHECK_STRICT
:
1045 if (proposal
->encklen
< p
->encklen
||
1047 proposal
->lifebyte
> p
->lifebyte
||
1049 proposal
->lifetime
> p
->lifetime
)
1053 case PROP_CHECK_EXACT
:
1054 if (proposal
->encklen
!= p
->encklen
||
1056 proposal
->lifebyte
!= p
->lifebyte
||
1058 proposal
->lifetime
!= p
->lifetime
)