chiark / gitweb /
keyfunc.sh.in, keys.reveal: Factor out sharing parameter file parsing.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 12 Feb 2012 23:08:31 +0000 (23:08 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 13 Feb 2012 00:25:30 +0000 (00:25 +0000)
We'll want it elsewhere soon.

keyfunc.sh.in
keys.reveal

index 0256dc0cb48e2820f9a0a6c71fc1e3b9c35028cc..a618e666a1ddd4dbd49ce343827bfb3c4e95e946 100644 (file)
@@ -557,6 +557,31 @@ c_sysverify () { c_sysop verify "$1" /dev/null; }
 ###--------------------------------------------------------------------------
 ### Recovery operations.
 
+sharethresh () {
+  pf=$1
+  ## Return the sharing threshold from the parameter file PARAM.
+
+  read param <"$pf"
+  case "$param" in
+    shamir-params:*) ;;
+    *)
+      echo >&2 "$quis: secret sharing parameter file damaged (wrong header)"
+      exit 1
+      ;;
+  esac
+  t=";${param#*:}"
+  case "$t" in
+    *";t="*) ;;
+    *)
+      echo >&2 "$quis: secret sharing parameter file damaged (missing t)"
+      exit 1
+      ;;
+  esac
+  t=${t#*;t=}
+  t=${t%%;*}
+  echo "$t"
+}
+
 stash () {
   recov=$1 label=$2
   ## Stash a copy of stdin encrypted under the recovery key RECOV, with a
index f11a59b7bbe12c8651853adc8b6eda3500297361..9e18879abf62b470e199fe2cb593cc08c6ebbdd3 100755 (executable)
@@ -64,24 +64,7 @@ mktmp
 cat >$tmp/secret
 
 ## Read the threshold from the recovery metadata.
-read param <$KEYS/recov/$recov/$keeper.param
-case "$param" in
-  shamir-params:*) ;;
-  *)
-    echo >&2 "$quis: secret sharing parameter file damaged (wrong header)"
-    exit 1
-    ;;
-esac
-t=";${param#*:}"
-case "$t" in
-  *";t="*) ;;
-  *)
-    echo >&2 "$quis: secret sharing parameter file damaged (missing t)"
-    exit 1
-    ;;
-esac
-t=${t#*;t=}
-t=${t%%;*}
+t=$(sharethresh $KEYS/recov/$recov/$keeper.param)
 
 ## Find out which keeper index it corresponds to.
 read n hunoz <$KEYS/keeper/$keeper/meta