Damien Miller | 8eff8e8 | 2010-02-24 17:33:30 +1100 | [diff] [blame] | 1 | # $OpenBSD: keygen-convert.sh,v 1.1 2009/11/09 04:20:04 dtucker Exp $ |
| 2 | # Placed in the Public Domain. |
| 3 | |
| 4 | tid="convert keys" |
| 5 | |
| 6 | for 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 |
| 33 | done |