X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/distorted-keys/blobdiff_plain/c47f2aba7d705252c660ba1ad0931fbb93122d80..2c973cfde3da8b47b7da19a35498170250d35ba7:/keys.keeper-cards diff --git a/keys.keeper-cards b/keys.keeper-cards index 73f2411..5ae1ae1 100755 --- a/keys.keeper-cards +++ b/keys.keeper-cards @@ -28,25 +28,56 @@ case "${KEYSLIB+t}" in t) ;; *) echo >&2 "$0: KEYSLIB unset"; exit 1 ;; esac . "$KEYSLIB"/keyfunc.sh defhelp <&2 "$quis: unknown keeper set \`$keeper'" + exit 1 +fi read n hunoz <$KEYS/keeper/$keeper/meta +## Check that nubs are available for the keeper set. +reqsafe +if [ ! -d $SAFE/keys.keeper/$keeper/ ]; then + echo >&2 "$quis: no nubs available for keeper set \`$keeper'" + exit 1 +fi +cd $SAFE/keys.keeper/$keeper/ + ## Build a colon-separated list of the indices we actually want. want=: case $# in 0) set 0- ;; esac @@ -81,143 +112,7 @@ done mktmp umask 077 exec 3>$tmp/$keeper.tex -cat >&3 <<'EOF' -\documentclass[a4paper, landscape, 12pt]{article} -\usepackage[utf8]{inputenc} -\usepackage[T1]{fontenc} -\usepackage[palatino, helvetica, courier, maths = cmr]{mdwfonts} -\usepackage{graphicx} - -%% Report errors with enough context that we can debug them. -\errorcontextlines=999 - -%% Basic layout for the cards. We use the paragraph filling machinery, but -%% don't actually need most of the trimmings. -\parindent=0pt -\parfillskip=0pt -\pagestyle{empty} - -%% Page layout: try to use most of the page. The document class will already -%% have set up the paper size, but we do the rest here. -\hoffset=-1in \voffset=-1in -\oddsidemargin=20mm -\textwidth=\paperwidth \advance\textwidth by -2\oddsidemargin -\topmargin=20mm -\headheight=0pt \headsep=0pt -\textheight=\paperheight \advance\textheight by -2\topmargin -\AtBeginDocument{\special{papersize=\the\paperwidth,\the\paperheight}} - -%% Parameters for the cards and guide rules. -\newdimen\cardwd \cardwd=82mm -\newdimen\cardht \cardht=49mm -\newdimen\guidelen \guidelen=10mm -\newdimen\rulewd \rulewd=0.6pt - -%% Typesetting the secret as text. The macro \snarf TOKEN T0 T1 ... T7 -%% gathers T0 T1 ... T7 into a single argument and passes them to TOKEN, as -%% long as T0 is not \relax. We use this to process the secret text in a -%% continuation-passing style. -\def\snarf#1#2{% - \ifx#2\relax\let\next\empty% - \else\def\next{\snarfdo#1#2}% - \fi% - \next% -} -\def\snarfdo#1#2#3#4#5#6#7#8#9{#1{#2#3#4#5#6#7#8#9}} - -%% Print the left and right halves of the line, with a separator. Use boxes -%% for the lines so that TeX will work out the width of the enclosing vbox -%% for us. The basic usage is \line TEXT \relax ... \relax, with eight -%% \relax tokens: this is enough to complete both \snarf calls. -\def\line{\snarf\lineleft} -\def\lineleft#1{\hbox\bgroup#1 \snarf\lineright} -\def\lineright#1{#1\egroup\line} - -%% Typeset a card containing a secret. Usage is \card{INDEX}{SECRET}. -\def\card#1#2{% - %% - %% Make sure we're setting a paragraph. - \leavevmode% - %% - %% Initial material: a stretchy space on the left. - \hbox{}\nobreak\hfil% - %% - %% An alignment for the guide markers surrounding the actual card. - \vbox{\halign{&##\cr% - %% - %% Top left guides. - \vrule width \guidelen height \rulewd depth 0pt% - \vrule width \rulewd depth 0pt height \guidelen% - &% - %% - %% Top centre gap. - \hfil% - &% - %% - %% Top right guides. - \vrule width \rulewd depth 0pt height \guidelen% - \vrule width \guidelen height \rulewd depth 0pt% - \cr% - %% - %% Left gap. - &% - %% - %% The actual card. - \vbox to \cardht{% - %% - %% We actually do more or less sensible typesetting. TeX will set the - %% box width from the hsize, and we should leave a small margin all - %% around. - \parfillskip=0pt plus 1fil% - \leftskip=1em \rightskip=1em% - \hsize=\cardwd% - %% - %% The heading. - \hrule height 0pt \prevdepth = 0pt% - \medskip% - {\large\bfseries\textsf{\keeper} secret #1/\total}% - %% - %% The QR-code and the text of the secret. - \vfil% - $% - \vcenter{\hbox{\includegraphics[scale = 2.4]{#1.eps}}}% - \hfil% - \vcenter{\ttfamily% - \line#2% - \relax\relax\relax\relax\relax\relax\relax\relax% - }% - $% - %% - %% And we're done. - \vfil% - }% - &% - %% - %% Right gap. - \cr% - %% - %% Bottom left guides. - \vrule width \guidelen depth \rulewd height 0pt% - \vrule width \rulewd depth \guidelen height 0pt% - &% - %% Bottom centre gap. - \hfil% - &% - %% Bottom right guides. - \vrule width \rulewd depth \guidelen height 0pt% - \vrule width \guidelen depth \rulewd height 0pt% - \cr% - %% - %% Leave a small vertical space at the bottom to separate lines of cards. - \strut \cr% - }}% - %% - %% End material: a stretchy space to match the one at the start, and then - %% allow a break. - \nobreak\hfil\hbox{}% - \penalty0% -} -EOF +cat >&3 $ETC/keeper-cards.tex ## Write the basic configuration stuff. cat >&3 <&3 <&3 <<'EOF' \end{document} EOF exec 3>&- -if ! (cd $tmp - exec tex.out 2>&1 - latex $keeper.tex && dvips -o$keeper.ps $keeper.dvi); then - echo >&2 "$quis: document formatting failed" - sed >&2 's/^/| /' $tmp/tex.out - exit 1 -fi -cp $tmp/$keeper.ps . + +case $mode in + ps) + if ! (cd $tmp + exec tex.out 2>&1 + latex $keeper.tex && dvips -o$keeper.ps $keeper.dvi); then + echo >&2 "$quis: document formatting failed" + sed >&2 's/^/| /' $tmp/tex.out + exit 1 + fi + cat $tmp/$keeper.ps + ;; + tar) + (cd $tmp; tar cf - $keeper.tex *.eps) + ;; +esac ###----- That's all, folks --------------------------------------------------