Initial import of bind-9.7.1-P2
[kai/bind9.git] / bin / tests / system / dnssec / ns3 / sign.sh
1 #!/bin/sh -e
2 #
3 # Copyright (C) 2004, 2006-2010  Internet Systems Consortium, Inc. ("ISC")
4 # Copyright (C) 2000-2002  Internet Software Consortium.
5 #
6 # Permission to use, copy, modify, and/or distribute this software for any
7 # purpose with or without fee is hereby granted, provided that the above
8 # copyright notice and this permission notice appear in all copies.
9 #
10 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12 # AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 # PERFORMANCE OF THIS SOFTWARE.
17
18 # $Id: sign.sh,v 1.30.32.2 2010/01/18 23:48:01 tbox Exp $
19
20 SYSTEMTESTTOP=../..
21 . $SYSTEMTESTTOP/conf.sh
22
23 RANDFILE=../random.data
24
25 zone=secure.example.
26 infile=secure.example.db.in
27 zonefile=secure.example.db
28
29 keyname=`$KEYGEN -q -r $RANDFILE -a RSASHA1 -b 768 -n zone $zone`
30
31 cat $infile $keyname.key >$zonefile
32
33 $SIGNER -P -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
34
35 zone=bogus.example.
36 infile=bogus.example.db.in
37 zonefile=bogus.example.db
38
39 keyname=`$KEYGEN -q -r $RANDFILE -a RSAMD5 -b 768 -n zone $zone`
40
41 cat $infile $keyname.key >$zonefile
42
43 $SIGNER -P -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
44
45 zone=dynamic.example.
46 infile=dynamic.example.db.in
47 zonefile=dynamic.example.db
48
49 keyname1=`$KEYGEN -q -r $RANDFILE -a RSAMD5 -b 768 -n zone $zone`
50 keyname2=`$KEYGEN -q -r $RANDFILE -a RSAMD5 -b 1024 -n zone -f KSK $zone`
51
52 cat $infile $keyname1.key $keyname2.key >$zonefile
53
54 $SIGNER -P -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
55
56 zone=keyless.example.
57 infile=keyless.example.db.in
58 zonefile=keyless.example.db
59
60 keyname=`$KEYGEN -q -r $RANDFILE -a RSAMD5 -b 768 -n zone $zone`
61
62 cat $infile $keyname.key >$zonefile
63
64 $SIGNER -P -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
65
66 # Change the signer field of the a.b.keyless.example SIG A
67 # to point to a provably nonexistent KEY record.
68 mv $zonefile.signed $zonefile.tmp
69 <$zonefile.tmp perl -p -e 's/ keyless.example/ b.keyless.example/
70     if /^a.b.keyless.example/../NXT/;' >$zonefile.signed
71 rm -f $zonefile.tmp
72
73 #
74 #  NSEC3/NSEC test zone
75 #
76 zone=secure.nsec3.example.
77 infile=secure.nsec3.example.db.in
78 zonefile=secure.nsec3.example.db
79
80 keyname=`$KEYGEN -q -r $RANDFILE -a RSAMD5 -b 768 -n zone $zone`
81
82 cat $infile $keyname.key >$zonefile
83
84 $SIGNER -P -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
85
86 #
87 #  NSEC3/NSEC3 test zone
88 #
89 zone=nsec3.nsec3.example.
90 infile=nsec3.nsec3.example.db.in
91 zonefile=nsec3.nsec3.example.db
92
93 keyname=`$KEYGEN -q -r $RANDFILE -a NSEC3RSASHA1 -b 768 -n zone $zone`
94
95 cat $infile $keyname.key >$zonefile
96
97 $SIGNER -P -3 - -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
98
99 #
100 #  OPTOUT/NSEC3 test zone
101 #
102 zone=optout.nsec3.example.
103 infile=optout.nsec3.example.db.in
104 zonefile=optout.nsec3.example.db
105
106 keyname=`$KEYGEN -q -r $RANDFILE -a NSEC3RSASHA1 -b 768 -n zone $zone`
107
108 cat $infile $keyname.key >$zonefile
109
110 $SIGNER -P -3 - -A -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
111
112 #
113 # A nsec3 zone (non-optout).
114 #
115 zone=nsec3.example.
116 infile=nsec3.example.db.in
117 zonefile=nsec3.example.db
118
119 keyname=`$KEYGEN -q -r $RANDFILE -a NSEC3RSASHA1 -b 768 -n zone $zone`
120
121 cat $infile $keyname.key >$zonefile
122
123 $SIGNER -P -g -3 - -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
124
125 #
126 #  OPTOUT/NSEC test zone
127 #
128 zone=secure.optout.example.
129 infile=secure.optout.example.db.in
130 zonefile=secure.optout.example.db
131
132 keyname=`$KEYGEN -q -r $RANDFILE -a RSAMD5 -b 768 -n zone $zone`
133
134 cat $infile $keyname.key >$zonefile
135
136 $SIGNER -P -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
137
138 #
139 #  OPTOUT/NSEC3 test zone
140 #
141 zone=nsec3.optout.example.
142 infile=nsec3.optout.example.db.in
143 zonefile=nsec3.optout.example.db
144
145 keyname=`$KEYGEN -q -r $RANDFILE -a NSEC3RSASHA1 -b 768 -n zone $zone`
146
147 cat $infile $keyname.key >$zonefile
148
149 $SIGNER -P -3 - -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
150
151 #
152 #  OPTOUT/OPTOUT test zone
153 #
154 zone=optout.optout.example.
155 infile=optout.optout.example.db.in
156 zonefile=optout.optout.example.db
157
158 keyname=`$KEYGEN -q -r $RANDFILE -a NSEC3RSASHA1 -b 768 -n zone $zone`
159
160 cat $infile $keyname.key >$zonefile
161
162 $SIGNER -P -3 - -A -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
163
164 #
165 # A optout nsec3 zone.
166 #
167 zone=optout.example.
168 infile=optout.example.db.in
169 zonefile=optout.example.db
170
171 keyname=`$KEYGEN -q -r $RANDFILE -a NSEC3RSASHA1 -b 768 -n zone $zone`
172
173 cat $infile $keyname.key >$zonefile
174
175 $SIGNER -P -g -3 - -A -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
176
177 #
178 # A nsec3 zone (non-optout) with unknown hash algorithm.
179 #
180 zone=nsec3-unknown.example.
181 infile=nsec3-unknown.example.db.in
182 zonefile=nsec3-unknown.example.db
183
184 keyname=`$KEYGEN -q -r $RANDFILE -a NSEC3RSASHA1 -b 768 -n zone $zone`
185
186 cat $infile $keyname.key >$zonefile
187
188 $SIGNER -P -3 - -U -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
189
190 #
191 # A optout nsec3 zone.
192 #
193 zone=optout-unknown.example.
194 infile=optout-unknown.example.db.in
195 zonefile=optout-unknown.example.db
196
197 keyname=`$KEYGEN -q -r $RANDFILE -a NSEC3RSASHA1 -b 768 -n zone $zone`
198
199 cat $infile $keyname.key >$zonefile
200
201 $SIGNER -P -3 - -U -A -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
202
203 #
204 # A multiple parameter nsec3 zone.
205 #
206 zone=multiple.example.
207 infile=multiple.example.db.in
208 zonefile=multiple.example.db
209
210 keyname=`$KEYGEN -q -r $RANDFILE -a NSEC3RSASHA1 -b 768 -n zone $zone`
211
212 cat $infile $keyname.key >$zonefile
213
214 $SIGNER -P -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
215 mv $zonefile.signed $zonefile
216 $SIGNER -P -u3 - -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
217 mv $zonefile.signed $zonefile
218 $SIGNER -P -u3 AAAA -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
219 mv $zonefile.signed $zonefile
220 $SIGNER -P -u3 BBBB -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
221 mv $zonefile.signed $zonefile
222 $SIGNER -P -u3 CCCC -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
223 mv $zonefile.signed $zonefile
224 $SIGNER -P -u3 DDDD -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
225
226 #
227 # A RSASHA256 zone.
228 #
229 zone=rsasha256.example.
230 infile=rsasha256.example.db.in
231 zonefile=rsasha256.example.db
232
233 keyname=`$KEYGEN -q -r $RANDFILE -a RSASHA256 -b 768 -n zone $zone`
234
235 cat $infile $keyname.key >$zonefile
236
237 $SIGNER -P -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
238
239 #
240 # A RSASHA512 zone.
241 #
242 zone=rsasha512.example.
243 infile=rsasha512.example.db.in
244 zonefile=rsasha512.example.db
245
246 keyname=`$KEYGEN -q -r $RANDFILE -a RSASHA512 -b 1024 -n zone $zone`
247
248 cat $infile $keyname.key >$zonefile
249
250 $SIGNER -P -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
251
252 #
253 # A zone with the DNSKEY set only signed by the KSK
254 #
255 zone=kskonly.example.
256 infile=kskonly.example.db.in
257 zonefile=kskonly.example.db
258
259 kskname=`$KEYGEN -q -r $RANDFILE -fk $zone`
260 zskname=`$KEYGEN -q -r $RANDFILE $zone`
261 cat $infile $kskname.key $zskname.key >$zonefile
262 $SIGNER -x -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1