summaryrefslogtreecommitdiff
path: root/regress/unittests/sshkey/mktestdata.sh
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2014-07-02 17:38:31 +1000
committerDamien Miller <djm@mindrot.org>2014-07-02 17:38:31 +1000
commitdd8b1dd7933eb6f5652641b0cdced34a387f2e80 (patch)
tree8c5422101cb6991722ed617d068c1d540847f41d /regress/unittests/sshkey/mktestdata.sh
parentc1dc24b71f087f385b92652b9673f52af64e0428 (diff)
- djm@cvs.openbsd.org 2014/06/24 01:14:17
[Makefile.in regress/Makefile regress/unittests/Makefile] [regress/unittests/sshkey/Makefile] [regress/unittests/sshkey/common.c] [regress/unittests/sshkey/common.h] [regress/unittests/sshkey/mktestdata.sh] [regress/unittests/sshkey/test_file.c] [regress/unittests/sshkey/test_fuzz.c] [regress/unittests/sshkey/test_sshkey.c] [regress/unittests/sshkey/tests.c] [regress/unittests/sshkey/testdata/dsa_1] [regress/unittests/sshkey/testdata/dsa_1-cert.fp] [regress/unittests/sshkey/testdata/dsa_1-cert.pub] [regress/unittests/sshkey/testdata/dsa_1.fp] [regress/unittests/sshkey/testdata/dsa_1.fp.bb] [regress/unittests/sshkey/testdata/dsa_1.param.g] [regress/unittests/sshkey/testdata/dsa_1.param.priv] [regress/unittests/sshkey/testdata/dsa_1.param.pub] [regress/unittests/sshkey/testdata/dsa_1.pub] [regress/unittests/sshkey/testdata/dsa_1_pw] [regress/unittests/sshkey/testdata/dsa_2] [regress/unittests/sshkey/testdata/dsa_2.fp] [regress/unittests/sshkey/testdata/dsa_2.fp.bb] [regress/unittests/sshkey/testdata/dsa_2.pub] [regress/unittests/sshkey/testdata/dsa_n] [regress/unittests/sshkey/testdata/dsa_n_pw] [regress/unittests/sshkey/testdata/ecdsa_1] [regress/unittests/sshkey/testdata/ecdsa_1-cert.fp] [regress/unittests/sshkey/testdata/ecdsa_1-cert.pub] [regress/unittests/sshkey/testdata/ecdsa_1.fp] [regress/unittests/sshkey/testdata/ecdsa_1.fp.bb] [regress/unittests/sshkey/testdata/ecdsa_1.param.curve] [regress/unittests/sshkey/testdata/ecdsa_1.param.priv] [regress/unittests/sshkey/testdata/ecdsa_1.param.pub] [regress/unittests/sshkey/testdata/ecdsa_1.pub] [regress/unittests/sshkey/testdata/ecdsa_1_pw] [regress/unittests/sshkey/testdata/ecdsa_2] [regress/unittests/sshkey/testdata/ecdsa_2.fp] [regress/unittests/sshkey/testdata/ecdsa_2.fp.bb] [regress/unittests/sshkey/testdata/ecdsa_2.param.curve] [regress/unittests/sshkey/testdata/ecdsa_2.param.priv] [regress/unittests/sshkey/testdata/ecdsa_2.param.pub] [regress/unittests/sshkey/testdata/ecdsa_2.pub] [regress/unittests/sshkey/testdata/ecdsa_n] [regress/unittests/sshkey/testdata/ecdsa_n_pw] [regress/unittests/sshkey/testdata/ed25519_1] [regress/unittests/sshkey/testdata/ed25519_1-cert.fp] [regress/unittests/sshkey/testdata/ed25519_1-cert.pub] [regress/unittests/sshkey/testdata/ed25519_1.fp] [regress/unittests/sshkey/testdata/ed25519_1.fp.bb] [regress/unittests/sshkey/testdata/ed25519_1.pub] [regress/unittests/sshkey/testdata/ed25519_1_pw] [regress/unittests/sshkey/testdata/ed25519_2] [regress/unittests/sshkey/testdata/ed25519_2.fp] [regress/unittests/sshkey/testdata/ed25519_2.fp.bb] [regress/unittests/sshkey/testdata/ed25519_2.pub] [regress/unittests/sshkey/testdata/pw] [regress/unittests/sshkey/testdata/rsa1_1] [regress/unittests/sshkey/testdata/rsa1_1.fp] [regress/unittests/sshkey/testdata/rsa1_1.fp.bb] [regress/unittests/sshkey/testdata/rsa1_1.param.n] [regress/unittests/sshkey/testdata/rsa1_1.pub] [regress/unittests/sshkey/testdata/rsa1_1_pw] [regress/unittests/sshkey/testdata/rsa1_2] [regress/unittests/sshkey/testdata/rsa1_2.fp] [regress/unittests/sshkey/testdata/rsa1_2.fp.bb] [regress/unittests/sshkey/testdata/rsa1_2.param.n] [regress/unittests/sshkey/testdata/rsa1_2.pub] [regress/unittests/sshkey/testdata/rsa_1] [regress/unittests/sshkey/testdata/rsa_1-cert.fp] [regress/unittests/sshkey/testdata/rsa_1-cert.pub] [regress/unittests/sshkey/testdata/rsa_1.fp] [regress/unittests/sshkey/testdata/rsa_1.fp.bb] [regress/unittests/sshkey/testdata/rsa_1.param.n] [regress/unittests/sshkey/testdata/rsa_1.param.p] [regress/unittests/sshkey/testdata/rsa_1.param.q] [regress/unittests/sshkey/testdata/rsa_1.pub] [regress/unittests/sshkey/testdata/rsa_1_pw] [regress/unittests/sshkey/testdata/rsa_2] [regress/unittests/sshkey/testdata/rsa_2.fp] [regress/unittests/sshkey/testdata/rsa_2.fp.bb] [regress/unittests/sshkey/testdata/rsa_2.param.n] [regress/unittests/sshkey/testdata/rsa_2.param.p] [regress/unittests/sshkey/testdata/rsa_2.param.q] [regress/unittests/sshkey/testdata/rsa_2.pub] [regress/unittests/sshkey/testdata/rsa_n] [regress/unittests/sshkey/testdata/rsa_n_pw] unit and fuzz tests for new key API
Diffstat (limited to 'regress/unittests/sshkey/mktestdata.sh')
-rwxr-xr-xregress/unittests/sshkey/mktestdata.sh189
1 files changed, 189 insertions, 0 deletions
diff --git a/regress/unittests/sshkey/mktestdata.sh b/regress/unittests/sshkey/mktestdata.sh
new file mode 100755
index 000000000..2039bf974
--- /dev/null
+++ b/regress/unittests/sshkey/mktestdata.sh
@@ -0,0 +1,189 @@
1#!/bin/sh
2
3PW=mekmitasdigoat
4
5rsa1_params() {
6 _in="$1"
7 _outbase="$2"
8 set -e
9 ssh-keygen -f $_in -e -m pkcs8 | \
10 openssl rsa -noout -text -pubin | \
11 awk '/^Modulus:$/,/^Exponent:/' | \
12 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.n
13 # XXX need conversion support in ssh-keygen for the other params
14 for x in n ; do
15 echo "" >> ${_outbase}.$x
16 echo ============ ${_outbase}.$x
17 cat ${_outbase}.$x
18 echo ============
19 done
20}
21
22rsa_params() {
23 _in="$1"
24 _outbase="$2"
25 set -e
26 openssl rsa -noout -text -in $_in | \
27 awk '/^modulus:$/,/^publicExponent:/' | \
28 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.n
29 openssl rsa -noout -text -in $_in | \
30 awk '/^prime1:$/,/^prime2:/' | \
31 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.p
32 openssl rsa -noout -text -in $_in | \
33 awk '/^prime2:$/,/^exponent1:/' | \
34 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.q
35 for x in n p q ; do
36 echo "" >> ${_outbase}.$x
37 echo ============ ${_outbase}.$x
38 cat ${_outbase}.$x
39 echo ============
40 done
41}
42
43dsa_params() {
44 _in="$1"
45 _outbase="$2"
46 set -e
47 openssl dsa -noout -text -in $_in | \
48 awk '/^priv:$/,/^pub:/' | \
49 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.priv
50 openssl dsa -noout -text -in $_in | \
51 awk '/^pub:/,/^P:/' | #\
52 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.pub
53 openssl dsa -noout -text -in $_in | \
54 awk '/^G:/,0' | \
55 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.g
56 for x in priv pub g ; do
57 echo "" >> ${_outbase}.$x
58 echo ============ ${_outbase}.$x
59 cat ${_outbase}.$x
60 echo ============
61 done
62}
63
64ecdsa_params() {
65 _in="$1"
66 _outbase="$2"
67 set -e
68 openssl ec -noout -text -in $_in | \
69 awk '/^priv:$/,/^pub:/' | \
70 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.priv
71 openssl ec -noout -text -in $_in | \
72 awk '/^pub:/,/^ASN1 OID:/' | #\
73 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.pub
74 openssl ec -noout -text -in $_in | \
75 grep "ASN1 OID:" | tr -d '\n' | \
76 sed 's/.*: //;s/ *$//' > ${_outbase}.curve
77 for x in priv pub curve ; do
78 echo "" >> ${_outbase}.$x
79 echo ============ ${_outbase}.$x
80 cat ${_outbase}.$x
81 echo ============
82 done
83}
84
85set -ex
86
87cd testdata
88
89rm -f rsa1_1 rsa_1 dsa_1 ecdsa_1 ed25519_1
90rm -f rsa1_2 rsa_2 dsa_2 ecdsa_2 ed25519_2
91rm -f rsa_n dsa_n ecdsa_n # new-format keys
92rm -f rsa1_1_pw rsa_1_pw dsa_1_pw ecdsa_1_pw ed25519_1_pw
93rm -f rsa_n_pw dsa_n_pw ecdsa_n_pw
94rm -f pw *.pub *.bn.* *.param.* *.fp *.fp.bb
95
96ssh-keygen -t rsa1 -b 768 -C "RSA1 test key #1" -N "" -f rsa1_1
97ssh-keygen -t rsa -b 768 -C "RSA test key #1" -N "" -f rsa_1
98ssh-keygen -t dsa -b 1024 -C "DSA test key #1" -N "" -f dsa_1
99ssh-keygen -t ecdsa -b 256 -C "ECDSA test key #1" -N "" -f ecdsa_1
100ssh-keygen -t ed25519 -C "ED25519 test key #1" -N "" -f ed25519_1
101
102ssh-keygen -t rsa1 -b 2048 -C "RSA1 test key #2" -N "" -f rsa1_2
103ssh-keygen -t rsa -b 2048 -C "RSA test key #2" -N "" -f rsa_2
104ssh-keygen -t dsa -b 1024 -C "DSA test key #2" -N "" -f dsa_2
105ssh-keygen -t ecdsa -b 521 -C "ECDSA test key #2" -N "" -f ecdsa_2
106ssh-keygen -t ed25519 -C "ED25519 test key #1" -N "" -f ed25519_2
107
108cp rsa_1 rsa_n
109cp dsa_1 dsa_n
110cp ecdsa_1 ecdsa_n
111
112cp rsa1_1 rsa1_1_pw
113cp rsa_1 rsa_1_pw
114cp dsa_1 dsa_1_pw
115cp ecdsa_1 ecdsa_1_pw
116cp ed25519_1 ed25519_1_pw
117cp rsa_1 rsa_n_pw
118cp dsa_1 dsa_n_pw
119cp ecdsa_1 ecdsa_n_pw
120
121ssh-keygen -pf rsa1_1_pw -N "$PW"
122ssh-keygen -pf rsa_1_pw -N "$PW"
123ssh-keygen -pf dsa_1_pw -N "$PW"
124ssh-keygen -pf ecdsa_1_pw -N "$PW"
125ssh-keygen -pf ed25519_1_pw -N "$PW"
126ssh-keygen -opf rsa_n_pw -N "$PW"
127ssh-keygen -opf dsa_n_pw -N "$PW"
128ssh-keygen -opf ecdsa_n_pw -N "$PW"
129
130rsa1_params rsa1_1 rsa1_1.param
131rsa1_params rsa1_2 rsa1_2.param
132rsa_params rsa_1 rsa_1.param
133rsa_params rsa_2 rsa_2.param
134dsa_params dsa_1 dsa_1.param
135dsa_params dsa_1 dsa_1.param
136ecdsa_params ecdsa_1 ecdsa_1.param
137ecdsa_params ecdsa_2 ecdsa_2.param
138# XXX ed25519 params
139
140ssh-keygen -s rsa_2 -I hugo -n user1,user2 \
141 -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \
142 -V 19990101:20110101 -z 1 rsa_1.pub
143ssh-keygen -s rsa_2 -I hugo -n user1,user2 \
144 -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \
145 -V 19990101:20110101 -z 2 dsa_1.pub
146ssh-keygen -s rsa_2 -I hugo -n user1,user2 \
147 -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \
148 -V 19990101:20110101 -z 3 ecdsa_1.pub
149ssh-keygen -s rsa_2 -I hugo -n user1,user2 \
150 -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \
151 -V 19990101:20110101 -z 4 ed25519_1.pub
152
153ssh-keygen -s ecdsa_1 -I julius -n host1,host2 -h \
154 -V 19990101:20110101 -z 5 rsa_1.pub
155ssh-keygen -s ecdsa_1 -I julius -n host1,host2 -h \
156 -V 19990101:20110101 -z 6 dsa_1.pub
157ssh-keygen -s ecdsa_1 -I julius -n host1,host2 -h \
158 -V 19990101:20110101 -z 7 ecdsa_1.pub
159ssh-keygen -s ecdsa_1 -I julius -n host1,host2 -h \
160 -V 19990101:20110101 -z 8 ed25519_1.pub
161
162ssh-keygen -lf rsa1_1 | awk '{print $2}' > rsa1_1.fp
163ssh-keygen -lf rsa_1 | awk '{print $2}' > rsa_1.fp
164ssh-keygen -lf dsa_1 | awk '{print $2}' > dsa_1.fp
165ssh-keygen -lf ecdsa_1 | awk '{print $2}' > ecdsa_1.fp
166ssh-keygen -lf ed25519_1 | awk '{print $2}' > ed25519_1.fp
167ssh-keygen -lf rsa1_2 | awk '{print $2}' > rsa1_2.fp
168ssh-keygen -lf rsa_2 | awk '{print $2}' > rsa_2.fp
169ssh-keygen -lf dsa_2 | awk '{print $2}' > dsa_2.fp
170ssh-keygen -lf ecdsa_2 | awk '{print $2}' > ecdsa_2.fp
171ssh-keygen -lf ed25519_2 | awk '{print $2}' > ed25519_2.fp
172
173ssh-keygen -lf dsa_1-cert.pub | awk '{print $2}' > dsa_1-cert.fp
174ssh-keygen -lf ecdsa_1-cert.pub | awk '{print $2}' > ecdsa_1-cert.fp
175ssh-keygen -lf ed25519_1-cert.pub | awk '{print $2}' > ed25519_1-cert.fp
176ssh-keygen -lf rsa_1-cert.pub | awk '{print $2}' > rsa_1-cert.fp
177
178ssh-keygen -Bf rsa1_1 | awk '{print $2}' > rsa1_1.fp.bb
179ssh-keygen -Bf rsa_1 | awk '{print $2}' > rsa_1.fp.bb
180ssh-keygen -Bf dsa_1 | awk '{print $2}' > dsa_1.fp.bb
181ssh-keygen -Bf ecdsa_1 | awk '{print $2}' > ecdsa_1.fp.bb
182ssh-keygen -Bf ed25519_1 | awk '{print $2}' > ed25519_1.fp.bb
183ssh-keygen -Bf rsa1_2 | awk '{print $2}' > rsa1_2.fp.bb
184ssh-keygen -Bf rsa_2 | awk '{print $2}' > rsa_2.fp.bb
185ssh-keygen -Bf dsa_2 | awk '{print $2}' > dsa_2.fp.bb
186ssh-keygen -Bf ecdsa_2 | awk '{print $2}' > ecdsa_2.fp.bb
187ssh-keygen -Bf ed25519_2 | awk '{print $2}' > ed25519_2.fp.bb
188
189echo "$PW" > pw