summaryrefslogtreecommitdiffstats
path: root/pubkey
diff options
context:
space:
mode:
Diffstat (limited to 'pubkey')
-rwxr-xr-xpubkey27
1 files changed, 27 insertions, 0 deletions
diff --git a/pubkey b/pubkey
new file mode 100755
index 0000000..4a6d781
--- /dev/null
+++ b/pubkey
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+KEY=$1
+PASS=$2
+
+declare -a ARGS
+if [[ -n "$KEY" ]]; then
+ if [[ ! -r "$KEY" ]]; then
+ echo "Usage: $0 [KEY [PASSFILE]]" >&2
+ exit 1
+ fi
+
+ ARGS+=("-in" "$KEY")
+fi
+
+if [[ -n "$PASS" ]]; then
+ if [[ ! -r "$PASS" ]]; then
+ echo "Usage: $0 [KEY [PASSFILE]]" >&2
+ exit 1
+ fi
+
+ ARGS+=("-passin" "file:$PASS")
+fi
+
+openssl rsa "${ARGS[@]}" -pubout 2>/dev/null | \
+ openssl rsa -pubin -noout -text | \
+ sed -e '/Modulus:$/d;s/Public-Key: (\(.*\))/Modulus (\1):/'