chiark / gitweb /
keyfunc.sh.in: Make sure we can match the `0' string.
[distorted-keys] / cryptop.public
index 27fde4b676c8a5ffd842bc37b6bba4415c5c9bd9..4d57ee5945d839e542cfd67a87231fac013b7e19 100755 (executable)
@@ -28,20 +28,37 @@ case "${KEYSLIB+t}" in t) ;; *) echo >&2 "$0: KEYSLIB unset"; exit 1 ;; esac
 . "$KEYSLIB"/keyfunc.sh
 
 defhelp <<HELP
-KEY
+[-x] KEY
 If the user KEY is asymmetric, write the public key to stdout.
+
+Options:
+  -x           Export the key in a form usable by \`pubkeyop'.
 HELP
 
+exportp=nil
+while getopts "x" opt; do
+  case $opt in
+    x) exportp=t ;;
+    *) usage_err ;;
+  esac
+done
+shift $(( $OPTIND - 1 ))
 case $# in 1) ;; *) usage_err ;; esac
 key=$1
 
 mktmp
 prepare "$key" -
-if [ -f $kdir/pub ]; then
-  cat $kdir/pub
-else
+if [ ! -f $kdir/pub ]; then
   echo >&2 "$quis: \`$key' has no public part"
   exit 1
 fi
+case $exportp in
+  t)
+    prepare "$key" info
+    dumpprops kprop_
+    echo ENDPROP
+    ;;
+esac
+cat $kdir/pub
 
 ###----- That's all, folks --------------------------------------------------