keygen-convert.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # $OpenBSD: keygen-convert.sh,v 1.2 2019/07/23 07:55:29 dtucker Exp $
  2. # Placed in the Public Domain.
  3. tid="convert keys"
  4. types=""
  5. for i in ${SSH_KEYTYPES}; do
  6. case "$i" in
  7. ssh-dss) types="$types dsa" ;;
  8. ssh-rsa) types="$types rsa" ;;
  9. esac
  10. done
  11. for t in $types; do
  12. # generate user key for agent
  13. trace "generating $t key"
  14. rm -f $OBJ/$t-key
  15. ${SSHKEYGEN} -q -N "" -t $t -f $OBJ/$t-key
  16. trace "export $t private to rfc4716 public"
  17. ${SSHKEYGEN} -q -e -f $OBJ/$t-key > $OBJ/$t-key-rfc ||
  18. fail "export $t private to rfc4716 public"
  19. trace "export $t public to rfc4716 public"
  20. ${SSHKEYGEN} -q -e -f $OBJ/$t-key.pub > $OBJ/$t-key-rfc.pub ||
  21. fail "$t public to rfc4716 public"
  22. cmp $OBJ/$t-key-rfc $OBJ/$t-key-rfc.pub ||
  23. fail "$t rfc4716 exports differ between public and private"
  24. trace "import $t rfc4716 public"
  25. ${SSHKEYGEN} -q -i -f $OBJ/$t-key-rfc > $OBJ/$t-rfc-imported ||
  26. fail "$t import rfc4716 public"
  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. rm -f $OBJ/$t-key $OBJ/$t-key.pub $OBJ/$t-key-rfc $OBJ/$t-key-rfc.pub \
  31. $OBJ/$t-rfc-imported $OBJ/$t-key-nocomment.pub
  32. done