xref: /freebsd/crypto/openssh/regress/unittests/sshsig/mktestdata.sh (revision d4eeb02986980bf33dd56c41ceb9fc5f180c0d47)
1#!/bin/sh
2# $OpenBSD: mktestdata.sh,v 1.1 2020/06/19 04:32:09 djm Exp $
3
4NAMESPACE=unittest
5
6set -ex
7
8cd testdata
9
10if [ -f ../../../misc/sk-dummy/sk-dummy.so ] ; then
11	SK_DUMMY=../../../misc/sk-dummy/sk-dummy.so
12elif [ -f ../../../misc/sk-dummy/obj/sk-dummy.so ] ; then
13	SK_DUMMY=../../../misc/sk-dummy/obj/sk-dummy.so
14else
15	echo "Can't find sk-dummy.so" 1>&2
16	exit 1
17fi
18
19rm -f signed-data namespace
20rm -f rsa dsa ecdsa ed25519 ecdsa_sk ed25519_sk
21rm -f rsa.sig dsa.sig ecdsa.sig ed25519.sig ecdsa_sk.sig ed25519_sk.sig
22
23printf "This is a test, this is only a test" > signed-data
24printf "$NAMESPACE" > namespace
25
26ssh-keygen -t rsa -C "RSA test" -N "" -f rsa -m PEM
27ssh-keygen -t dsa -C "DSA test" -N "" -f dsa -m PEM
28ssh-keygen -t ecdsa -C "ECDSA test" -N "" -f ecdsa -m PEM
29ssh-keygen -t ed25519 -C "ED25519 test key" -N "" -f ed25519
30ssh-keygen -w "$SK_DUMMY" -t ecdsa-sk -C "ECDSA-SK test key" \
31    -N "" -f ecdsa_sk
32ssh-keygen -w "$SK_DUMMY" -t ed25519-sk -C "ED25519-SK test key" \
33    -N "" -f ed25519_sk
34
35ssh-keygen -Y sign -f rsa -n $NAMESPACE - < signed-data > rsa.sig
36ssh-keygen -Y sign -f dsa -n $NAMESPACE - < signed-data > dsa.sig
37ssh-keygen -Y sign -f ecdsa -n $NAMESPACE - < signed-data > ecdsa.sig
38ssh-keygen -Y sign -f ed25519 -n $NAMESPACE - < signed-data > ed25519.sig
39ssh-keygen -w "$SK_DUMMY" \
40	-Y sign -f ecdsa_sk -n $NAMESPACE - < signed-data > ecdsa_sk.sig
41ssh-keygen -w "$SK_DUMMY" \
42	-Y sign -f ed25519_sk -n $NAMESPACE - < signed-data > ed25519_sk.sig
43