diff options
author | Damien Miller <djm@mindrot.org> | 2014-07-02 17:38:31 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2014-07-02 17:38:31 +1000 |
commit | dd8b1dd7933eb6f5652641b0cdced34a387f2e80 (patch) | |
tree | 8c5422101cb6991722ed617d068c1d540847f41d /regress/unittests/sshkey/mktestdata.sh | |
parent | c1dc24b71f087f385b92652b9673f52af64e0428 (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-x | regress/unittests/sshkey/mktestdata.sh | 189 |
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 | |||
3 | PW=mekmitasdigoat | ||
4 | |||
5 | rsa1_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 | |||
22 | rsa_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 | |||
43 | dsa_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 | |||
64 | ecdsa_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 | |||
85 | set -ex | ||
86 | |||
87 | cd testdata | ||
88 | |||
89 | rm -f rsa1_1 rsa_1 dsa_1 ecdsa_1 ed25519_1 | ||
90 | rm -f rsa1_2 rsa_2 dsa_2 ecdsa_2 ed25519_2 | ||
91 | rm -f rsa_n dsa_n ecdsa_n # new-format keys | ||
92 | rm -f rsa1_1_pw rsa_1_pw dsa_1_pw ecdsa_1_pw ed25519_1_pw | ||
93 | rm -f rsa_n_pw dsa_n_pw ecdsa_n_pw | ||
94 | rm -f pw *.pub *.bn.* *.param.* *.fp *.fp.bb | ||
95 | |||
96 | ssh-keygen -t rsa1 -b 768 -C "RSA1 test key #1" -N "" -f rsa1_1 | ||
97 | ssh-keygen -t rsa -b 768 -C "RSA test key #1" -N "" -f rsa_1 | ||
98 | ssh-keygen -t dsa -b 1024 -C "DSA test key #1" -N "" -f dsa_1 | ||
99 | ssh-keygen -t ecdsa -b 256 -C "ECDSA test key #1" -N "" -f ecdsa_1 | ||
100 | ssh-keygen -t ed25519 -C "ED25519 test key #1" -N "" -f ed25519_1 | ||
101 | |||
102 | ssh-keygen -t rsa1 -b 2048 -C "RSA1 test key #2" -N "" -f rsa1_2 | ||
103 | ssh-keygen -t rsa -b 2048 -C "RSA test key #2" -N "" -f rsa_2 | ||
104 | ssh-keygen -t dsa -b 1024 -C "DSA test key #2" -N "" -f dsa_2 | ||
105 | ssh-keygen -t ecdsa -b 521 -C "ECDSA test key #2" -N "" -f ecdsa_2 | ||
106 | ssh-keygen -t ed25519 -C "ED25519 test key #1" -N "" -f ed25519_2 | ||
107 | |||
108 | cp rsa_1 rsa_n | ||
109 | cp dsa_1 dsa_n | ||
110 | cp ecdsa_1 ecdsa_n | ||
111 | |||
112 | cp rsa1_1 rsa1_1_pw | ||
113 | cp rsa_1 rsa_1_pw | ||
114 | cp dsa_1 dsa_1_pw | ||
115 | cp ecdsa_1 ecdsa_1_pw | ||
116 | cp ed25519_1 ed25519_1_pw | ||
117 | cp rsa_1 rsa_n_pw | ||
118 | cp dsa_1 dsa_n_pw | ||
119 | cp ecdsa_1 ecdsa_n_pw | ||
120 | |||
121 | ssh-keygen -pf rsa1_1_pw -N "$PW" | ||
122 | ssh-keygen -pf rsa_1_pw -N "$PW" | ||
123 | ssh-keygen -pf dsa_1_pw -N "$PW" | ||
124 | ssh-keygen -pf ecdsa_1_pw -N "$PW" | ||
125 | ssh-keygen -pf ed25519_1_pw -N "$PW" | ||
126 | ssh-keygen -opf rsa_n_pw -N "$PW" | ||
127 | ssh-keygen -opf dsa_n_pw -N "$PW" | ||
128 | ssh-keygen -opf ecdsa_n_pw -N "$PW" | ||
129 | |||
130 | rsa1_params rsa1_1 rsa1_1.param | ||
131 | rsa1_params rsa1_2 rsa1_2.param | ||
132 | rsa_params rsa_1 rsa_1.param | ||
133 | rsa_params rsa_2 rsa_2.param | ||
134 | dsa_params dsa_1 dsa_1.param | ||
135 | dsa_params dsa_1 dsa_1.param | ||
136 | ecdsa_params ecdsa_1 ecdsa_1.param | ||
137 | ecdsa_params ecdsa_2 ecdsa_2.param | ||
138 | # XXX ed25519 params | ||
139 | |||
140 | ssh-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 | ||
143 | ssh-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 | ||
146 | ssh-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 | ||
149 | ssh-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 | |||
153 | ssh-keygen -s ecdsa_1 -I julius -n host1,host2 -h \ | ||
154 | -V 19990101:20110101 -z 5 rsa_1.pub | ||
155 | ssh-keygen -s ecdsa_1 -I julius -n host1,host2 -h \ | ||
156 | -V 19990101:20110101 -z 6 dsa_1.pub | ||
157 | ssh-keygen -s ecdsa_1 -I julius -n host1,host2 -h \ | ||
158 | -V 19990101:20110101 -z 7 ecdsa_1.pub | ||
159 | ssh-keygen -s ecdsa_1 -I julius -n host1,host2 -h \ | ||
160 | -V 19990101:20110101 -z 8 ed25519_1.pub | ||
161 | |||
162 | ssh-keygen -lf rsa1_1 | awk '{print $2}' > rsa1_1.fp | ||
163 | ssh-keygen -lf rsa_1 | awk '{print $2}' > rsa_1.fp | ||
164 | ssh-keygen -lf dsa_1 | awk '{print $2}' > dsa_1.fp | ||
165 | ssh-keygen -lf ecdsa_1 | awk '{print $2}' > ecdsa_1.fp | ||
166 | ssh-keygen -lf ed25519_1 | awk '{print $2}' > ed25519_1.fp | ||
167 | ssh-keygen -lf rsa1_2 | awk '{print $2}' > rsa1_2.fp | ||
168 | ssh-keygen -lf rsa_2 | awk '{print $2}' > rsa_2.fp | ||
169 | ssh-keygen -lf dsa_2 | awk '{print $2}' > dsa_2.fp | ||
170 | ssh-keygen -lf ecdsa_2 | awk '{print $2}' > ecdsa_2.fp | ||
171 | ssh-keygen -lf ed25519_2 | awk '{print $2}' > ed25519_2.fp | ||
172 | |||
173 | ssh-keygen -lf dsa_1-cert.pub | awk '{print $2}' > dsa_1-cert.fp | ||
174 | ssh-keygen -lf ecdsa_1-cert.pub | awk '{print $2}' > ecdsa_1-cert.fp | ||
175 | ssh-keygen -lf ed25519_1-cert.pub | awk '{print $2}' > ed25519_1-cert.fp | ||
176 | ssh-keygen -lf rsa_1-cert.pub | awk '{print $2}' > rsa_1-cert.fp | ||
177 | |||
178 | ssh-keygen -Bf rsa1_1 | awk '{print $2}' > rsa1_1.fp.bb | ||
179 | ssh-keygen -Bf rsa_1 | awk '{print $2}' > rsa_1.fp.bb | ||
180 | ssh-keygen -Bf dsa_1 | awk '{print $2}' > dsa_1.fp.bb | ||
181 | ssh-keygen -Bf ecdsa_1 | awk '{print $2}' > ecdsa_1.fp.bb | ||
182 | ssh-keygen -Bf ed25519_1 | awk '{print $2}' > ed25519_1.fp.bb | ||
183 | ssh-keygen -Bf rsa1_2 | awk '{print $2}' > rsa1_2.fp.bb | ||
184 | ssh-keygen -Bf rsa_2 | awk '{print $2}' > rsa_2.fp.bb | ||
185 | ssh-keygen -Bf dsa_2 | awk '{print $2}' > dsa_2.fp.bb | ||
186 | ssh-keygen -Bf ecdsa_2 | awk '{print $2}' > ecdsa_2.fp.bb | ||
187 | ssh-keygen -Bf ed25519_2 | awk '{print $2}' > ed25519_2.fp.bb | ||
188 | |||
189 | echo "$PW" > pw | ||