blob: ad0e9c637d0fd9888eb1b0b7839f36a13449f265 [file] [log] [blame]
Damien Miller8eff8e82010-02-24 17:33:30 +11001# $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