chiark / gitweb /
cryptop.public: New operation to export a key with its properties.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 15 Feb 2012 00:49:26 +0000 (00:49 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 23 Feb 2012 03:14:37 +0000 (03:14 +0000)
This form will be useful soon.

cryptop.public

index 27fde4b..4d57ee5 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 --------------------------------------------------