]>
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 #include <sys/types.h>
37 #include <sys/param.h>
47 #include "isakmp_var.h"
49 #include "ipsec_doi.h"
51 #include "netdb_dnssec.h"
63 struct certinfo
*res
= NULL
;
64 struct ipsecdoi_id_b
*id_b
;
70 id_b
= (struct ipsecdoi_id_b
*)id
->v
;
72 namelen
= id
->l
- sizeof(*id_b
);
73 name
= racoon_malloc(namelen
+ 1);
75 plog(LLV_ERROR
, LOCATION
, NULL
,
76 "failed to get buffer.\n");
79 memcpy(name
, id_b
+ 1, namelen
);
83 case IPSECDOI_ID_FQDN
:
84 error
= getcertsbyname(name
, &res
);
86 plog(LLV_ERROR
, LOCATION
, NULL
,
87 "getcertsbyname(\"%s\") failed.\n", name
);
91 case IPSECDOI_ID_IPV4_ADDR
:
92 case IPSECDOI_ID_IPV6_ADDR
:
93 /* XXX should be processed to query PTR ? */
95 plog(LLV_ERROR
, LOCATION
, NULL
,
96 "impropper ID type passed %s "
97 "though getcert method is dnssec.\n",
98 s_ipsecdoi_ident(id_b
->type
));
103 if (res
->ci_next
!= NULL
) {
104 plog(LLV_WARNING
, LOCATION
, NULL
,
105 "not supported multiple CERT RR.\n");
107 switch (res
->ci_type
) {
108 case DNSSEC_TYPE_PKIX
:
109 /* XXX is it enough condition to set this type ? */
110 type
= ISAKMP_CERT_X509SIGN
;
113 plog(LLV_ERROR
, LOCATION
, NULL
,
114 "not supported CERT RR type %d.\n", res
->ci_type
);
118 /* create cert holder */
119 cert
= oakley_newcert();
121 plog(LLV_ERROR
, LOCATION
, NULL
,
122 "failed to get cert buffer.\n");
125 cert
->pl
= vmalloc(res
->ci_certlen
+ 1);
126 if (cert
->pl
== NULL
) {
127 plog(LLV_ERROR
, LOCATION
, NULL
,
128 "failed to get cert buffer.\n");
131 memcpy(cert
->pl
->v
+ 1, res
->ci_cert
, res
->ci_certlen
);
132 cert
->pl
->v
[0] = type
;
133 cert
->cert
.v
= cert
->pl
->v
+ 1;
134 cert
->cert
.l
= cert
->pl
->l
- 1;
136 plog(LLV_DEBUG
, LOCATION
, NULL
, "created CERT payload:\n");
137 plogdump(LLV_DEBUG
, cert
->pl
->v
, cert
->pl
->l
);
149 oakley_delcert(cert
);