--- otp-970425.orig/Makefile +++ otp-970425/Makefile @@ -21,8 +21,7 @@ gzip /tmp/otp.tar test: otp - chmod u+x test.bat - test.bat + . ./test.sh diff test.mas test.out clean: --- otp-970425.orig/README +++ otp-970425/README @@ -1,3 +1,35 @@ +(Note: Most of this README is taken from otp.c, grimaldi) + + One-Time Pad Generator + + by John Walker -- kelvin@fourmilab.ch + http://www.fourmilab.ch/ + + Creates ready to use one-time pads containing either passwords + that obey the digraph frequencies of English text (less secure + but easier to remember), completely random letters, or digits. + + Random values for the pad are generated from the XOR of four + concurrently-running BSD random() generators, each with a 256 byte + state vector, independently seeded with four 4 byte blocks of the + MD5 message digest of a vector containing: + + Time and date (time()) + Several hundred bytes of unitialised storage + + and, depending on the operating system: + + MSDOS: + Default drive size and free space + Absolute address program loaded in memory + + Unix: + Time in microseconds (to system's timer resolution) + Process ID number + Parent process ID number + Machine's host ID + +(Note: Original readme follows, grimaldi) This program can be built on both MS-DOS and Unix. Because MS-DOS development tools differ so much from one another, a ready-to-run --- otp-970425.orig/md5.h +++ otp-970425/md5.h @@ -1,10 +1,12 @@ #ifndef MD5_H #define MD5_H -#ifdef __alpha +#if defined(__alpha) || defined(__amd64) || defined(__ia64) || defined(__hppa) || defined(__powerpc64__) typedef unsigned int uint32; +typedef int int32; #else typedef unsigned long uint32; +typedef long int32; #endif struct MD5Context { --- otp-970425.orig/otp.c +++ otp-970425/otp.c @@ -152,10 +152,10 @@ concurrently running random number generators to produce a random value based on a 16 byte seed. */ -static long mrandom() +static int32 mrandom() { int i; - long r = 0; + int32 r = 0; for (i = 0; i < 4; i++) { setstate(rvec[i]); @@ -175,10 +175,10 @@ numeric = 0, upper = 0, english = 0, pw_length = PW_LENGTH, pw_item, linelen = 79, npline, lineno, nch; - long rseed; + int32 rseed; char *password, *pwp, *v, *seed = NULL; FILE *ofile = stdout, *sigfile = NULL; - unsigned long trash[100]; + uint32 trash[100]; struct MD5Context md5c; unsigned char digest[16]; #ifdef MSDOS @@ -307,10 +307,10 @@ ri.h.ah = 0x36; /* Get disc free space */ ri.h.dl = 0; /* Default drive */ if (_intdos(&ri, &ro) != 0xFFFF) { - trash[1] = (((long) ro.x.ax) << 16) | ro.x.bx; - trash[2] = (((long) ro.x.cx) << 16) | ro.x.dx; + trash[1] = (((int32) ro.x.ax) << 16) | ro.x.bx; + trash[2] = (((int32) ro.x.cx) << 16) | ro.x.dx; } - trash[4] = (long) (char __far *) trash; + trash[4] = (int32) (char __far *) trash; #define OS_KNOWN 1 #endif @@ -335,9 +335,9 @@ } MD5Final(digest, &md5c); for (j = 0; j < 4; j++) { - rseed = (((long) digest[0 + (4 * j)]) << 24) | - (((long) digest[1 + (4 * j)]) << 16) | - (((long) digest[2 + (4 * j)]) << 8) | digest[3 + (4 * j)]; + rseed = (((int32) digest[0 + (4 * j)]) << 24) | + (((int32) digest[1 + (4 * j)]) << 16) | + (((int32) digest[2 + (4 * j)]) << 8) | digest[3 + (4 * j)]; initstate(rseed, rvec[j], RandVecL); #ifdef DEBUG fprintf(stderr, "Digest[%d : %d]:", j * 4, (j * 4) + 3); --- otp-970425.orig/random.c +++ otp-970425/random.c @@ -47,10 +47,10 @@ * congruential generator. If the amount of state information is less than * 32 bytes, a simple linear congruential R.N.G. is used. * - * Internally, the state information is treated as an array of longs; the + * Internally, the state information is treated as an array of int32s; the * zeroeth element of the array is the type of R.N.G. being used (small * integer); the remainder of the array is the state information for the - * R.N.G. Thus, 32 bytes of state information will give 7 longs worth of + * R.N.G. Thus, 32 bytes of state information will give 7 int32s worth of * state information, which will allow a degree seven polynomial. (Note: * the zeroeth word of state information also has some other information * stored in it -- see setstate() for details). @@ -61,13 +61,13 @@ * the state table will act as a linear feedback shift register, and will * have period 2^deg - 1 (where deg is the degree of the polynomial being * used, assuming that the polynomial is irreducible and primitive). The - * higher order bits will have longer periods, since their values are also + * higher order bits will have int32er periods, since their values are also * influenced by pseudo-random carries out of the lower bits. The total * period of the generator is approximately deg*(2**deg - 1); thus doubling * the amount of state information has a vast influence on the period of the * generator. Note: the deg*(2**deg - 1) is an approximation only good for * large deg, when the period of the shift register is the dominant factor. - * With deg equal to seven, the period is actually much longer than the + * With deg equal to seven, the period is actually much int32er than the * 7*(2**7 - 1) predicted by this formula. */ @@ -112,6 +112,15 @@ static int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; static int seps [MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; +/* Define int32 and uint32 to signed and unsigned 32 bit types */ +#if defined(__alpha) || defined(__amd64) || defined(__ia64) || defined(__hppa) || defined(__powerpc64__) +typedef unsigned int uint32; +typedef int int32; +#else +typedef unsigned long uint32; +typedef long int32; +#endif + /* * Initially, everything is set up as if from: * @@ -126,7 +135,7 @@ * MAX_TYPES * (rptr - state) + TYPE_3 == TYPE_3. */ -static long randtbl[DEG_3 + 1] = { +static int32 randtbl[DEG_3 + 1] = { TYPE_3, 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, 0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb, 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd, @@ -150,8 +159,8 @@ * in the initialization of randtbl) because the state table pointer is set * to point to randtbl[1] (as explained below). */ -static long *fptr = &randtbl[SEP_3 + 1]; -static long *rptr = &randtbl[1]; +static int32 *fptr = &randtbl[SEP_3 + 1]; +static int32 *rptr = &randtbl[1]; /* * The following things are the pointer to the state information table, the @@ -163,11 +172,11 @@ * this is more efficient than indexing every time to find the address of * the last element to see if the front and rear pointers have wrapped. */ -static long *state = &randtbl[1]; +static int32 *state = &randtbl[1]; static int rand_type = TYPE_3; static int rand_deg = DEG_3; static int rand_sep = SEP_3; -static long *end_ptr = &randtbl[DEG_3 + 1]; +static int32 *end_ptr = &randtbl[DEG_3 + 1]; /* * srandom: @@ -182,15 +191,15 @@ * for default usage relies on values produced by this routine. */ -#define u_int unsigned long +#define u_int uint32 -extern long random(); +extern int32 random(); void srandom(x) u_int x; { - register long i, j; + register int32 i, j; #ifdef NEEDED if (rand_type == TYPE_0) @@ -269,7 +278,7 @@ rand_deg = DEG_4; rand_sep = SEP_4; } - state = &(((long *)arg_state)[1]); /* first location */ + state = &(((int32 *)arg_state)[1]); /* first location */ end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */ srandom(seed); if (rand_type == TYPE_0) @@ -298,7 +307,7 @@ setstate(arg_state) char *arg_state; { - register long *new_state = (long *)arg_state; + register int32 *new_state = (int32 *)arg_state; register int type = new_state[0] % MAX_TYPES; register int rear = new_state[0] / MAX_TYPES; char *ostate = (char *)(&state[-1]); @@ -351,10 +360,10 @@ * * Returns a 31-bit random number. */ -long +int32 random() { - long i; + int32 i; #ifdef NEEDED if (rand_type == TYPE_0) --- otp-970425.orig/debian/README.Debian +++ otp-970425/debian/README.Debian @@ -0,0 +1,10 @@ +otp for DEBIAN +---------------------- + +This package is available from http://www.fourmilab.ch/onetime/ +you might want to check out the Java Script version offered there. + +The source package provides a binary for Dos, see README in the +source package. + +Jens Ritter , Tue, 24 Feb 1998 10:38:15 +0100 --- otp-970425.orig/debian/changelog +++ otp-970425/debian/changelog @@ -0,0 +1,57 @@ +otp (970425-7) unstable; urgency=low + + * Applied patch from Martin Orr to fix segfaults on 64 bit archs + (closes: #343524) + * Rebuilt to finish /usr/doc transition (closes: #359544) + * Updated standards-version in debian/control + + -- Pawel Wiecek Wed, 29 Mar 2006 23:16:53 +0200 + +otp (970425-6) unstable; urgency=low + + * Fixed a couple of minor spelling issues in debian/control + (closes: #125210) + + -- Pawel Wiecek Tue, 18 Dec 2001 10:10:02 +0100 + +otp (970425-5) unstable; urgency=low + + * New maintainer (closes: #92731) + + -- Pawel Wiecek Wed, 9 May 2001 13:31:07 +0200 + +otp (970425-4) unstable; urgency=low + + * Package is orphaned (see #92731); maintainer set to Debian QA Group. + * Converted to debhelper. Closes: #61330, #62902, #84542, #91026, + #91606. + * Conforms to Standards version 3.5.2: + * Added build dependencies. + * debian/rules: Support the `debug' build option. + + -- Matej Vela Sun, 8 Apr 2001 15:01:13 +0200 + +otp (970425-3) frozen unstable; urgency=low + + * Distribution to frozen was rejected (Needs new maintainer version) + + -- Jens Ritter Wed, 15 Apr 1998 11:02:36 +0200 + +otp (970425-2) frozen unstable; urgency=low + + * changed Architecture to any (closes Bug #19692) + * added Distribution frozen unstable. + + -- Jens Ritter Mon, 23 Mar 1998 17:17:43 +0100 + +otp (970425-1) unstable; urgency=low + + * Initial Release. + * uncommented a C header for random() (it`s different in stdlib.h) + * created test.sh (replaces test.bat for MSDOS) + * edited target "test" in Makefile for usage of test.sh, + added rm in target test + * modified README with documentation from otp.c + + -- Jens Ritter Tue, 24 Feb 1998 11:05:23 +0100 + --- otp-970425.orig/debian/control +++ otp-970425/debian/control @@ -0,0 +1,24 @@ +Source: otp +Section: misc +Priority: optional +Maintainer: Pawel Wiecek +Standards-Version: 3.6.2 +Build-Depends: debhelper (>= 4) + +Package: otp +Architecture: any +Depends: ${shlibs:Depends} +Description: Generator for One Time Passwords + otp creates key and password lists for verification and + security purposes in a variety of formats. Keys can be of + any length, consist of digits or letters (capital or lower + case), and alphabetic passwords can either be entirely + random (most secure) or obey the digraph statistics of + English text (easier to remember when transcribing, but less + secure). + . + For computer applications, for example one-time login + passwords, otp can create a file containing the MD5 + signature of each of the generated keys. This permits the + computer to verify keys without the need to store the keys in + plaintext. --- otp-970425.orig/debian/copyright +++ otp-970425/debian/copyright @@ -0,0 +1,18 @@ +This package was debianized by Jens Ritter grimaldi@debian.org on +Tue, 24 Feb 1998 11:05:23 +0100. + +It was downloaded from http://www.fourmilab.ch/onetime/otp.tar.gz + +Copyright: (from otp.c) + + The English-digraph password generator is based on the "mpw" + program developed at MIT: + + mpw: Make up passwords which have similar letter digraph + frequencies to English. + Converted from Multics PL/I by Bill Sommerfeld, 4/21/86. + Original PL/I version provided by Jerry Saltzer. + + This program is in the public domain. + +John Walker --- otp-970425.orig/debian/rules +++ otp-970425/debian/rules @@ -0,0 +1,44 @@ +#!/usr/bin/make -f + +export DH_COMPAT=4 + +CFLAGS := -O2 -Wall +ifneq ($(findstring debug,$(DEB_BUILD_OPTIONS)),) +CFLAGS += -g +endif + +clean: + dh_testdir + dh_testroot + dh_clean build.stamp + $(MAKE) clean + +build: build.stamp +build.stamp: + dh_testdir + $(MAKE) CFLAGS="$(CFLAGS)" + > $@ + +binary: binary-arch binary-indep + +binary-arch: build + dh_testdir + dh_testroot + dh_clean + dh_installdirs usr/bin + install otp debian/otp/usr/bin + dh_installdocs README + dh_installman otp.1 + dh_installchangelogs + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary-indep: build + +.PHONY: clean build binary binary-arch binary-indep --- otp-970425.orig/test.sh +++ otp-970425/test.sh @@ -0,0 +1,9 @@ +#! /bin/sh +set -e +exec > test.out +./otp -rTEST -n4 -mt1.md5 +./otp -rTEST -n3 -c12 -mt2.md5 +./otp -rTEST -n3 -e12 -mt3.md5 +./otp -rTEST -n4 -S5 -e -c -mt4.md5 +./otp -rTEST -n7 -d4 -mt5.md5 +cat t[1-5].md5