]>
git.saurik.com Git - apple/network_cmds.git/blob - racoon.tproj/dnssec.c
1 /* $KAME: dnssec.c,v 1.1 2001/04/11 06:11:55 sakane Exp $ */
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/types.h>
33 #include <sys/param.h>
43 #include "isakmp_var.h"
45 #include "ipsec_doi.h"
47 #include "netdb_dnssec.h"
59 struct certinfo
*res
= NULL
;
60 struct ipsecdoi_id_b
*id_b
;
66 id_b
= (struct ipsecdoi_id_b
*)id
->v
;
68 namelen
= id
->l
- sizeof(*id_b
);
69 name
= racoon_malloc(namelen
+ 1);
71 plog(LLV_ERROR
, LOCATION
, NULL
,
72 "failed to get buffer.\n");
75 memcpy(name
, id_b
+ 1, namelen
);
79 case IPSECDOI_ID_FQDN
:
80 error
= getcertsbyname(name
, &res
);
82 plog(LLV_ERROR
, LOCATION
, NULL
,
83 "getcertsbyname(\"%s\") failed.\n", name
);
87 case IPSECDOI_ID_IPV4_ADDR
:
88 case IPSECDOI_ID_IPV6_ADDR
:
89 /* XXX should be processed to query PTR ? */
91 plog(LLV_ERROR
, LOCATION
, NULL
,
92 "inpropper ID type passed %s "
93 "though getcert method is dnssec.\n",
94 s_ipsecdoi_ident(id_b
->type
));
99 if (res
->ci_next
== NULL
) {
100 plog(LLV_WARNING
, LOCATION
, NULL
,
101 "not supported multiple CERT RR.\n");
103 switch (res
->ci_type
) {
104 case DNSSEC_TYPE_PKIX
:
105 /* XXX is it enough condition to set this type ? */
106 type
= ISAKMP_CERT_X509SIGN
;
109 plog(LLV_ERROR
, LOCATION
, NULL
,
110 "not supported CERT RR type %d.\n", res
->ci_type
);
114 /* create cert holder */
115 cert
= oakley_newcert();
117 plog(LLV_ERROR
, LOCATION
, NULL
,
118 "failed to get cert buffer.\n");
121 cert
->pl
= vmalloc(res
->ci_certlen
+ 1);
122 if (cert
->pl
== NULL
) {
123 plog(LLV_ERROR
, LOCATION
, NULL
,
124 "failed to get cert buffer.\n");
127 memcpy(cert
->pl
->v
+ 1, res
->ci_cert
, res
->ci_certlen
);
128 cert
->pl
->v
[0] = type
;
129 cert
->cert
.v
= cert
->pl
->v
+ 1;
130 cert
->cert
.l
= cert
->pl
->l
- 1;
132 plog(LLV_DEBUG
, LOCATION
, NULL
, "created CERT payload:\n");
133 plogdump(LLV_DEBUG
, cert
->pl
->v
, cert
->pl
->l
);
145 oakley_delcert(cert
);