xref: /freebsd/crypto/openssh/regress/keygen-convert.sh (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
1#	$OpenBSD: keygen-convert.sh,v 1.1 2009/11/09 04:20:04 dtucker Exp $
2#	Placed in the Public Domain.
3
4tid="convert keys"
5
6for t in rsa dsa; do
7	# generate user key for agent
8	trace "generating $t key"
9	rm -f $OBJ/$t-key
10	${SSHKEYGEN} -q -N "" -t $t -f $OBJ/$t-key
11
12	trace "export $t private to rfc4716 public"
13	${SSHKEYGEN} -q -e -f $OBJ/$t-key >$OBJ/$t-key-rfc || \
14	    fail "export $t private to rfc4716 public"
15
16	trace "export $t public to rfc4716 public"
17	${SSHKEYGEN} -q -e -f $OBJ/$t-key.pub >$OBJ/$t-key-rfc.pub || \
18	    fail "$t public to rfc4716 public"
19
20	cmp $OBJ/$t-key-rfc $OBJ/$t-key-rfc.pub || \
21	    fail "$t rfc4716 exports differ between public and private"
22
23	trace "import $t rfc4716 public"
24	${SSHKEYGEN} -q -i -f $OBJ/$t-key-rfc >$OBJ/$t-rfc-imported || \
25	    fail "$t import rfc4716 public"
26
27	cut -f1,2 -d " " $OBJ/$t-key.pub >$OBJ/$t-key-nocomment.pub
28	cmp $OBJ/$t-key-nocomment.pub $OBJ/$t-rfc-imported || \
29	    fail "$t imported differs from original"
30
31	rm -f $OBJ/$t-key $OBJ/$t-key.pub $OBJ/$t-key-rfc $OBJ/$t-key-rfc.pub \
32	    $OBJ/$t-rfc-imported $OBJ/$t-key-nocomment.pub
33done
34