Package: otpw-bin
Version: 1.3-2
Severity: wishlist
Tags: patch

Hello,

please consider the attached script for inclusion as contributed
code for otpw. It is a bit rough cut, but gives a nice CC-Card
sized password list that carries easily in you wallet.

Best regards,

Joerg



#!/usr/bin/perl --
#
#  otpwprint - output postscript with 100 OPIE passwords credit card sized
#
$ver = "0.1";   # version of this program - otpwprint

$usage = "Usage: otpwprint [-o file] [[-p]|[-f filename]]\n".
         "       output credit card sized postscript with 100 OTPW passwords\n".
         "       this is otpwprint v$ver\n";

#               generate 100 passwords for "user" (default current user)
#               using either STDIN (-p) or otpw-gen (with -f option)
#               to file "file" (default stdout)
#
#  v1.0 - original code distributed with Wietse Venema's logdaemon 4.7 package
#               as keyprint, no author given
#  v2.0 - modified to use OPIE, with PS header in-lined, + opt cnt on cmdline
#               by lawrie.br...@adfa.oz.au / 11 Jan 96
#  v2.1 - added flag to specify seed so can do remote printout of keys
#               by lawrie.br...@adfa.oz.au / 12 Jan 96
#  v3.0 - totally rewrote postscript skeleton, handcrafted, much smaller, epsf
#               by lawrie.br...@adfa.oz.au / 10 Oct 96
#
#  renamed to otpwprint and adapted for otpw
#               by jo...@dorchain.net / 27 Mar 2009

########################## Configurable Parameters #######################

$dir="/usr/bin";                # dir containing otpw-gen

##########################################################################

$ENV{'PATH'}='/bin:/usr/bin:/usr/ucb';
$|=1;                           # unbuffer stdout

$max = 54;                      # default max seq number is 100; 4 header + 2 
pwds per row
$out = "";                      # output file (stdout if blank)
$file = "";                     # otpw file if not default

# process command-line
while (@ARGV) {
    if ($ARGV[0] =~ /-p/) { $pipe = 1; shift @ARGV; next;}
    if ($ARGV[0] =~ /-f/) { shift @ARGV; $file = shift @ARGV; next;}
    if ($ARGV[0] =~ /-o/) { shift @ARGV; $out = shift @ARGV; next;}
    if ($ARGV[0] =~ /-[hv\?]/) { die "otpwprint v$ver\n$usage\nstopped";}
    if ($ARGV[0] =~ /-/)  { die "unknown flag $ARGV[0]\n$usage\nstopped";}
    last;                       # not a flag so must be user, drop out of loop
}

if ( $pipe && $file) { die "-p and -f option are mutally exclusiv\n";}


# open appropriate output stream to either specified file or stdout
if ($out) { open(PRINTER, ">$out") || die "can't open $out: $!, stopped"; }
else { open(PRINTER, ">-") || die "can't send output to STDOUT: $!, stopped"; }

# run otpw-gen to generate the required number of keys and save them in %key
if ($pipe) { $keys = \*STDIN; }
else { open(KEYS, "$dir/otpw-gen -p1 -h $max |")
  || die "can't run otpw-gen: $!, stopped";
  $keys = \*KEYS;
  system("stty -echo");         # yuck! Suppress echo of secret password
}
$seed=<$keys>;                  # header line
$seed =~ /on (\w+)/;$seed=$1;
while(<$keys>) {
    /^(\d\d\d)((\s....){5})\s\s(\d\d\d)((\s....){5})/ && do {
    $key{$1 + 0}=$2.$3;
    $key{$4 + 0}=$5.$6;
    next; }; 
};
if (!$pipe) {
  system("stty echo");          # more yuck!
  close(KEYS);
}
# now read postscript skeleton, filling in the keys at the numbered locations
while(<DATA>) {
    s/OPIESEED/$seed/;          # insert correct seed for top of card
    if (/^\((\d+):\)/) {        # find slots for keys and fill them in
        $n = $1 - 1;            # work out equiv key number for our seq
        s/^\((\d+):\)/($n: $key{$n})/;
    }
    print PRINTER $_;
}

# end of perl program, postscript skeleton follows, with key slots 1: to 100:
#############################################################################
__END__
%!PS-Adobe-2.0 EPSF-2.0
%%Creator: lawrie.br...@adfa.oz.au 
%%CreationDate: Thu 10 Oct 1996
%%BoundingBox: 160 440  435 775
%%Pages: 1
%%EndComments
%
% Skeletal postscript code to output 100 OPIE passwords credit card sized 
% hand crafted from original Framemaker generated skeleton by Lawrie Brown
%

% display seed value for these opie passwords
/Helvetica-Bold findfont 8 scalefont setfont
4 0 (OPIESEED) 261 763 moveto ashow

% display list of 100 passwords, skeleton just has default numbers 1-100
/Helvetica findfont 5 scalefont setfont
(1:) 183 756 moveto show
(26:) 302 756 moveto show
(2:) 183 750 moveto show
(27:) 302 750 moveto show
(3:) 183 744 moveto show
(28:) 302 744 moveto show
(4:) 183 738 moveto show
(29:) 302 738 moveto show
(5:) 183 732 moveto show
(30:) 302 732 moveto show
(6:) 183 726 moveto show
(31:) 302 726 moveto show
(7:) 183 720 moveto show
(32:) 302 720 moveto show
(8:) 183 714 moveto show
(33:) 302 714 moveto show
(9:) 183 708 moveto show
(34:) 302 708 moveto show
(10:) 183 702 moveto show
(35:) 302 702 moveto show
(11:) 183 695 moveto show
(36:) 302 695 moveto show
(12:) 183 689 moveto show
(37:) 302 689 moveto show
(13:) 183 683 moveto show
(38:) 302 683 moveto show
(14:) 183 677 moveto show
(39:) 302 677 moveto show
(15:) 183 671 moveto show
(40:) 302 671 moveto show
(16:) 183 665 moveto show
(41:) 302 665 moveto show
(17:) 183 659 moveto show
(42:) 302 659 moveto show
(18:) 183 653 moveto show
(43:) 302 653 moveto show
(19:) 183 647 moveto show
(44:) 302 647 moveto show
(20:) 183 641 moveto show
(45:) 302 641 moveto show
(21:) 183 634 moveto show
(46:) 302 634 moveto show
(22:) 183 628 moveto show
(47:) 302 628 moveto show
(23:) 183 622 moveto show
(48:) 302 622 moveto show
(24:) 183 616 moveto show
(49:) 302 616 moveto show
(25:) 183 610 moveto show
(50:) 302 610 moveto show
(51:) 183 600 moveto show
(76:) 302 600 moveto show
(52:) 183 594 moveto show
(77:) 302 594 moveto show
(53:) 183 588 moveto show
(78:) 302 588 moveto show
(54:) 183 582 moveto show
(79:) 302 582 moveto show
(55:) 183 576 moveto show
(80:) 302 576 moveto show
(56:) 183 569 moveto show
(81:) 302 569 moveto show
(57:) 183 563 moveto show
(82:) 302 563 moveto show
(58:) 183 557 moveto show
(83:) 302 557 moveto show
(59:) 183 551 moveto show
(84:) 302 551 moveto show
(60:) 183 545 moveto show
(85:) 302 545 moveto show
(61:) 183 539 moveto show
(86:) 302 539 moveto show
(62:) 183 533 moveto show
(87:) 302 533 moveto show
(63:) 183 527 moveto show
(88:) 302 527 moveto show
(64:) 183 521 moveto show
(89:) 302 521 moveto show
(65:) 183 515 moveto show
(90:) 302 515 moveto show
(66:) 183 508 moveto show
(91:) 302 508 moveto show
(67:) 183 502 moveto show
(92:) 302 502 moveto show
(68:) 183 496 moveto show
(93:) 302 496 moveto show
(69:) 183 490 moveto show
(94:) 302 490 moveto show
(70:) 183 484 moveto show
(95:) 302 484 moveto show
(71:) 183 478 moveto show
(96:) 302 478 moveto show
(72:) 183 472 moveto show
(97:) 302 472 moveto show
(73:) 183 466 moveto show
(98:) 302 466 moveto show
(74:) 183 460 moveto show
(99:) 302 460 moveto show
(75:) 183 454 moveto show
(100:) 302 454 moveto show

% draw boxes round each half
0.25 setlinewidth
0 setlinecap

178 761 moveto
178 608 lineto 
416 608 lineto 
416 761 lineto 
178 761 lineto
stroke

178 604 moveto
178 452 lineto
416 452 lineto
416 604 lineto
178 604 lineto
stroke

% now draw thin dashed lines
0.01 setlinewidth
2 setlinecap
[1 3] 0 setdash

% draw cutlines round outside
171 445 moveto
171 769 lineto
423 769 lineto
423 445 lineto
171 445 lineto
stroke

% draw fold line through middle
163 606 moveto
433 606 lineto
stroke

% display our handiwork
showpage

Attachment: signature.asc
Description: Digital signature

Reply via email to