From: Mark Wooding Date: Sun, 12 Feb 2012 23:08:31 +0000 (+0000) Subject: keyfunc.sh.in, keys.reveal: Factor out sharing parameter file parsing. X-Git-Tag: 0.99.2~34 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/distorted-keys/commitdiff_plain/2661d8aa033971c32f45392fc70e42f0d9a2c14e?ds=sidebyside keyfunc.sh.in, keys.reveal: Factor out sharing parameter file parsing. We'll want it elsewhere soon. --- diff --git a/keyfunc.sh.in b/keyfunc.sh.in index 0256dc0..a618e66 100644 --- a/keyfunc.sh.in +++ b/keyfunc.sh.in @@ -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 diff --git a/keys.reveal b/keys.reveal index f11a59b..9e18879 100755 --- a/keys.reveal +++ b/keys.reveal @@ -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