]>
git.saurik.com Git - apple/ipsec.git/blob - ipsec-tools/racoon/dnssec.c
1 /* $NetBSD: dnssec.c,v 1.4 2006/09/09 16:22:09 manu Exp $ */
3 /* $KAME: dnssec.c,v 1.2 2001/08/05 18:46:07 itojun 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 #if ENABLE_DNSSEC_CERTS
38 #include <sys/types.h>
39 #include <sys/param.h>
49 #include "isakmp_var.h"
51 #include "ipsec_doi.h"
53 #include "netdb_dnssec.h"
65 struct certinfo
*res
= NULL
;
66 struct ipsecdoi_id_b
*id_b
;
72 id_b
= ALIGNED_CAST(struct ipsecdoi_id_b
*)id
->v
;
74 namelen
= id
->l
- sizeof(*id_b
);
75 name
= racoon_malloc(namelen
+ 1);
78 "failed to get buffer.\n");
81 memcpy(name
, id_b
+ 1, namelen
);
85 case IPSECDOI_ID_FQDN
:
86 error
= getcertsbyname(name
, &res
);
89 "getcertsbyname(\"%s\") failed.\n", name
);
93 case IPSECDOI_ID_IPV4_ADDR
:
94 case IPSECDOI_ID_IPV6_ADDR
:
95 /* XXX should be processed to query PTR ? */
98 "impropper ID type passed %s "
99 "though getcert method is dnssec.\n",
100 s_ipsecdoi_ident(id_b
->type
));
105 if (res
->ci_next
!= NULL
) {
106 plog(ASL_LEVEL_WARNING
,
107 "not supported multiple CERT RR.\n");
109 switch (res
->ci_type
) {
110 case DNSSEC_TYPE_PKIX
:
111 /* XXX is it enough condition to set this type ? */
112 type
= ISAKMP_CERT_X509SIGN
;
116 "not supported CERT RR type %d.\n", res
->ci_type
);
120 /* create cert holder */
121 cert
= oakley_newcert();
124 "failed to get cert buffer.\n");
127 cert
->pl
= vmalloc(res
->ci_certlen
+ 1);
128 if (cert
->pl
== NULL
) {
130 "failed to get cert buffer.\n");
133 memcpy(cert
->pl
->v
+ 1, res
->ci_cert
, res
->ci_certlen
);
134 cert
->pl
->v
[0] = type
;
135 cert
->cert
.v
= cert
->pl
->v
+ 1;
136 cert
->cert
.l
= cert
->pl
->l
- 1;
138 plog(ASL_LEVEL_DEBUG
, "created CERT payload:\n");
150 oakley_delcert(cert
);
157 #endif /* ENABLE_DNSSEC_CERTS */