1#!/bin/sh 2# $OpenBSD: mktestdata.sh,v 1.11 2020/06/19 03:48:49 djm Exp $ 3 4PW=mekmitasdigoat 5 6rsa_params() { 7 _in="$1" 8 _outbase="$2" 9 set -e 10 openssl rsa -noout -text -in $_in | \ 11 awk '/^modulus:$/,/^publicExponent:/' | \ 12 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.n 13 openssl rsa -noout -text -in $_in | \ 14 awk '/^prime1:$/,/^prime2:/' | \ 15 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.p 16 openssl rsa -noout -text -in $_in | \ 17 awk '/^prime2:$/,/^exponent1:/' | \ 18 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.q 19 for x in n p q ; do 20 echo "" >> ${_outbase}.$x 21 echo ============ ${_outbase}.$x 22 cat ${_outbase}.$x 23 echo ============ 24 done 25} 26 27dsa_params() { 28 _in="$1" 29 _outbase="$2" 30 set -e 31 openssl dsa -noout -text -in $_in | \ 32 awk '/^priv:$/,/^pub:/' | \ 33 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.priv 34 openssl dsa -noout -text -in $_in | \ 35 awk '/^pub:/,/^P:/' | #\ 36 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.pub 37 openssl dsa -noout -text -in $_in | \ 38 awk '/^G:/,0' | \ 39 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.g 40 for x in priv pub g ; do 41 echo "" >> ${_outbase}.$x 42 echo ============ ${_outbase}.$x 43 cat ${_outbase}.$x 44 echo ============ 45 done 46} 47 48ecdsa_params() { 49 _in="$1" 50 _outbase="$2" 51 set -e 52 openssl ec -noout -text -in $_in | \ 53 awk '/^priv:$/,/^pub:/' | \ 54 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.priv 55 openssl ec -noout -text -in $_in | \ 56 awk '/^pub:/,/^ASN1 OID:/' | #\ 57 grep -v '^[a-zA-Z]' | tr -d ' \n:' > ${_outbase}.pub 58 openssl ec -noout -text -in $_in | \ 59 grep "ASN1 OID:" | \ 60 sed 's/.*: //;s/ *$//' | tr -d '\n' > ${_outbase}.curve 61 for x in priv pub curve ; do 62 echo "" >> ${_outbase}.$x 63 echo ============ ${_outbase}.$x 64 cat ${_outbase}.$x 65 echo ============ 66 done 67} 68 69set -ex 70 71cd testdata 72 73if [ -f ../../../misc/sk-dummy/sk-dummy.so ] ; then 74 SK_DUMMY=../../../misc/sk-dummy/sk-dummy.so 75elif [ -f ../../../misc/sk-dummy/obj/sk-dummy.so ] ; then 76 SK_DUMMY=../../../misc/sk-dummy/obj/sk-dummy.so 77else 78 echo "Can't find sk-dummy.so" 1>&2 79 exit 1 80fi 81 82rm -f rsa_1 dsa_1 ecdsa_1 ed25519_1 83rm -f rsa_2 dsa_2 ecdsa_2 ed25519_2 84rm -f rsa_n dsa_n ecdsa_n # new-format keys 85rm -f rsa_1_pw dsa_1_pw ecdsa_1_pw ed25519_1_pw 86rm -f rsa_n_pw dsa_n_pw ecdsa_n_pw 87rm -f pw *.pub *.bn.* *.param.* *.fp *.fp.bb 88 89ssh-keygen -t rsa -b 1024 -C "RSA test key #1" -N "" -f rsa_1 -m PEM 90ssh-keygen -t dsa -b 1024 -C "DSA test key #1" -N "" -f dsa_1 -m PEM 91ssh-keygen -t ecdsa -b 256 -C "ECDSA test key #1" -N "" -f ecdsa_1 -m PEM 92ssh-keygen -t ed25519 -C "ED25519 test key #1" -N "" -f ed25519_1 93ssh-keygen -w "$SK_DUMMY" -t ecdsa-sk -C "ECDSA-SK test key #1" \ 94 -N "" -f ecdsa_sk1 95ssh-keygen -w "$SK_DUMMY" -t ed25519-sk -C "ED25519-SK test key #1" \ 96 -N "" -f ed25519_sk1 97 98 99ssh-keygen -t rsa -b 2048 -C "RSA test key #2" -N "" -f rsa_2 -m PEM 100ssh-keygen -t dsa -b 1024 -C "DSA test key #2" -N "" -f dsa_2 -m PEM 101ssh-keygen -t ecdsa -b 521 -C "ECDSA test key #2" -N "" -f ecdsa_2 -m PEM 102ssh-keygen -t ed25519 -C "ED25519 test key #2" -N "" -f ed25519_2 103ssh-keygen -w "$SK_DUMMY" -t ecdsa-sk -C "ECDSA-SK test key #2" \ 104 -N "" -f ecdsa_sk2 105ssh-keygen -w "$SK_DUMMY" -t ed25519-sk -C "ED25519-SK test key #2" \ 106 -N "" -f ed25519_sk2 107 108cp rsa_1 rsa_n 109cp dsa_1 dsa_n 110cp ecdsa_1 ecdsa_n 111 112ssh-keygen -pf rsa_n -N "" 113ssh-keygen -pf dsa_n -N "" 114ssh-keygen -pf ecdsa_n -N "" 115 116cp rsa_1 rsa_1_pw 117cp dsa_1 dsa_1_pw 118cp ecdsa_1 ecdsa_1_pw 119cp ed25519_1 ed25519_1_pw 120cp ecdsa_sk1 ecdsa_sk1_pw 121cp ed25519_sk1 ed25519_sk1_pw 122cp rsa_1 rsa_n_pw 123cp dsa_1 dsa_n_pw 124cp ecdsa_1 ecdsa_n_pw 125 126ssh-keygen -pf rsa_1_pw -m PEM -N "$PW" 127ssh-keygen -pf dsa_1_pw -m PEM -N "$PW" 128ssh-keygen -pf ecdsa_1_pw -m PEM -N "$PW" 129ssh-keygen -pf ed25519_1_pw -N "$PW" 130ssh-keygen -pf ecdsa_sk1_pw -m PEM -N "$PW" 131ssh-keygen -pf ed25519_sk1_pw -N "$PW" 132ssh-keygen -pf rsa_n_pw -N "$PW" 133ssh-keygen -pf dsa_n_pw -N "$PW" 134ssh-keygen -pf ecdsa_n_pw -N "$PW" 135 136rsa_params rsa_1 rsa_1.param 137rsa_params rsa_2 rsa_2.param 138dsa_params dsa_1 dsa_1.param 139dsa_params dsa_1 dsa_1.param 140ecdsa_params ecdsa_1 ecdsa_1.param 141ecdsa_params ecdsa_2 ecdsa_2.param 142# XXX ed25519, *sk params 143 144ssh-keygen -s rsa_2 -I hugo -n user1,user2 \ 145 -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \ 146 -V 19990101:20110101 -z 1 rsa_1.pub 147ssh-keygen -s rsa_2 -I hugo -n user1,user2 \ 148 -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \ 149 -V 19990101:20110101 -z 2 dsa_1.pub 150ssh-keygen -s rsa_2 -I hugo -n user1,user2 \ 151 -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \ 152 -V 19990101:20110101 -z 3 ecdsa_1.pub 153ssh-keygen -s rsa_2 -I hugo -n user1,user2 \ 154 -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \ 155 -V 19990101:20110101 -z 4 ed25519_1.pub 156ssh-keygen -s rsa_2 -I hugo -n user1,user2 \ 157 -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \ 158 -V 19990101:20110101 -z 4 ecdsa_sk1.pub 159ssh-keygen -s rsa_2 -I hugo -n user1,user2 \ 160 -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \ 161 -V 19990101:20110101 -z 4 ed25519_sk1.pub 162 163 164# Make a few RSA variant signature too. 165cp rsa_1 rsa_1_sha1 166cp rsa_1 rsa_1_sha512 167cp rsa_1.pub rsa_1_sha1.pub 168cp rsa_1.pub rsa_1_sha512.pub 169ssh-keygen -s rsa_2 -I hugo -n user1,user2 -t ssh-rsa \ 170 -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \ 171 -V 19990101:20110101 -z 1 rsa_1_sha1.pub 172ssh-keygen -s rsa_2 -I hugo -n user1,user2 -t rsa-sha2-512 \ 173 -Oforce-command=/bin/ls -Ono-port-forwarding -Osource-address=10.0.0.0/8 \ 174 -V 19990101:20110101 -z 1 rsa_1_sha512.pub 175 176ssh-keygen -s ed25519_1 -I julius -n host1,host2 -h \ 177 -V 19990101:20110101 -z 5 rsa_1.pub 178ssh-keygen -s ed25519_1 -I julius -n host1,host2 -h \ 179 -V 19990101:20110101 -z 6 dsa_1.pub 180ssh-keygen -s ecdsa_1 -I julius -n host1,host2 -h \ 181 -V 19990101:20110101 -z 7 ecdsa_1.pub 182ssh-keygen -s ed25519_1 -I julius -n host1,host2 -h \ 183 -V 19990101:20110101 -z 8 ed25519_1.pub 184ssh-keygen -s ecdsa_1 -I julius -n host1,host2 -h \ 185 -V 19990101:20110101 -z 7 ecdsa_sk1.pub 186ssh-keygen -s ed25519_1 -I julius -n host1,host2 -h \ 187 -V 19990101:20110101 -z 8 ed25519_sk1.pub 188 189ssh-keygen -lf rsa_1 | awk '{print $2}' > rsa_1.fp 190ssh-keygen -lf dsa_1 | awk '{print $2}' > dsa_1.fp 191ssh-keygen -lf ecdsa_1 | awk '{print $2}' > ecdsa_1.fp 192ssh-keygen -lf ed25519_1 | awk '{print $2}' > ed25519_1.fp 193ssh-keygen -lf ecdsa_sk1 | awk '{print $2}' > ecdsa_sk1.fp 194ssh-keygen -lf ed25519_sk1 | awk '{print $2}' > ed25519_sk1.fp 195ssh-keygen -lf rsa_2 | awk '{print $2}' > rsa_2.fp 196ssh-keygen -lf dsa_2 | awk '{print $2}' > dsa_2.fp 197ssh-keygen -lf ecdsa_2 | awk '{print $2}' > ecdsa_2.fp 198ssh-keygen -lf ed25519_2 | awk '{print $2}' > ed25519_2.fp 199ssh-keygen -lf ecdsa_sk2 | awk '{print $2}' > ecdsa_sk2.fp 200ssh-keygen -lf ed25519_sk2 | awk '{print $2}' > ed25519_sk2.fp 201 202ssh-keygen -lf rsa_1-cert.pub | awk '{print $2}' > rsa_1-cert.fp 203ssh-keygen -lf dsa_1-cert.pub | awk '{print $2}' > dsa_1-cert.fp 204ssh-keygen -lf ecdsa_1-cert.pub | awk '{print $2}' > ecdsa_1-cert.fp 205ssh-keygen -lf ed25519_1-cert.pub | awk '{print $2}' > ed25519_1-cert.fp 206ssh-keygen -lf ecdsa_sk1-cert.pub | awk '{print $2}' > ecdsa_sk1-cert.fp 207ssh-keygen -lf ed25519_sk1-cert.pub | awk '{print $2}' > ed25519_sk1-cert.fp 208 209ssh-keygen -Bf rsa_1 | awk '{print $2}' > rsa_1.fp.bb 210ssh-keygen -Bf dsa_1 | awk '{print $2}' > dsa_1.fp.bb 211ssh-keygen -Bf ecdsa_1 | awk '{print $2}' > ecdsa_1.fp.bb 212ssh-keygen -Bf ed25519_1 | awk '{print $2}' > ed25519_1.fp.bb 213ssh-keygen -Bf ecdsa_sk1 | awk '{print $2}' > ecdsa_sk1.fp.bb 214ssh-keygen -Bf ed25519_sk1 | awk '{print $2}' > ed25519_sk1.fp.bb 215ssh-keygen -Bf rsa_2 | awk '{print $2}' > rsa_2.fp.bb 216ssh-keygen -Bf dsa_2 | awk '{print $2}' > dsa_2.fp.bb 217ssh-keygen -Bf ecdsa_2 | awk '{print $2}' > ecdsa_2.fp.bb 218ssh-keygen -Bf ed25519_2 | awk '{print $2}' > ed25519_2.fp.bb 219ssh-keygen -Bf ecdsa_sk2 | awk '{print $2}' > ecdsa_sk2.fp.bb 220ssh-keygen -Bf ed25519_sk2 | awk '{print $2}' > ed25519_sk2.fp.bb 221 222echo "$PW" > pw 223