From: billm@cygnus.com (Bill Moyer)
Subject: Re: Steal their thunder (was Re: Alpha window of opportunity?)
Date: 1998/06/11 [thread overview]
Message-ID: <6lp8a8$crd$1@andros.cygnus.com> (raw)
In-Reply-To: 357F78F4.15322973@shore.net
In article <357F78F4.15322973@shore.net> Russell Sasamori <puzzle@shore.net> writes:
>> Regarding LFSR's, wide integers still help you here when you are
>>implementing your LFSR ADT as multiple LFSR's operating in parallel,
>>with each register representing a bitslice of all of the LFSR's.
>
>I'm trying to visualize this. Would it help if I turned my head
>sideways? If possible I would like to see an example in C code.
Sure .. here's an NLFSR ADT I wrote a while ago which implements eight
parallel LFSR's in a byte stream and uses multiple eight-stream LFSR's
to generate random numbers via a nonlinear function. It's not very
optimized code, but then when I wrote it performance wasn't an issue.
/* LFSR.H -- defining the Linear Feedback Shift Register ADT */
#include <stdtypes.h>
typedef struct lfsrtag {
int32 mag; /* number of bytes pointed to by d */
int32 finger; /* roving pointer into d[] to front/list */
int32 mix; /* bitmask of xor elements */
byte *d; /* data */
} lfsrt;
/* LFSR.C -- defining the Linear Feedback Shift Register ADT */
#include "lfsr.h"
/* crank() extracts a byte from the lfsr, performs the */
/* "mix" to generate the replacement byte, and returns */
/* the extracted byte. */
byte crank ( lfsr ) lfsrt *lfsr; {
byte retval;
byte vat;
int32 targ;
int32 index;
int32 mix = lfsr->mix;
retval = lfsr->d[lfsr->finger];
targ = lfsr->finger;
lfsr->finger++;
if ( lfsr->finger == lfsr->mag ) lfsr->finger = 0;
vat = 0; index = 0;
while(mix) {
if ( mix & 1 ) {
index = index + targ;
if ( index >= lfsr->mag ) index -= lfsr->mag;
if ( index >= lfsr->mag ) index -= lfsr->mag;
vat ^= lfsr->d[index];
}
index++;
mix >>= 1;
}
lfsr->d[targ] = vat;
return retval;
}
/* nonlinear() returns a byte calculated by performing a nonlinear */
/* operation on bytes extracted from three lfsr's. The byte stream */
/* obtained from nonlinear() is not suceptible to the correlation */
/* attack, and is a cryptographically strong source of randomness */
/* given that the lfsr's were initialized with random data from a */
/* cryptographically strong source. */
byte nonlinear ( a, b, c ) byte a, b, c; {
byte retval;
byte upper;
word32 pot;
int i = 0;
pot = a * b;
while ( pot && !(pot&1) ) {
i++;
pot >>= 1;
}
i++;
pot >>= 1;
retval = pot << i;
if (i>=8) return c;
if (!pot) return c;
upper = c << (8-i);
retval ^= upper >> (8-i);
return retval;
}
****DISCLAIMER****DISCLAIMER****DISCLAIMER****DISCLAIMER****DISCLAIMER****
Whether or not this NLFSR actually can be a cryptographically strong
source of randomness is anyone's guess. I make no claims about its
appropriateness for any task whatsoever, despite the comments in the code.
It has been somewhat tested and appears to operate well.
****DISCLAIMER****DISCLAIMER****DISCLAIMER****DISCLAIMER****DISCLAIMER****
Note - stdtypes.h is an automatically generated file. The "stdtypes"
utility tests the host computer for various characteristics and creates
the .h file with a bunch of standard values and types. I use it as a
matter of course with most of my personal projects and distribute it with
them, to make writing portable and clearly-defined C code easier. Feel
free to use/promulgate it. The source is a little large to politely dis-
tribute in a newsgroup, so I stuck it at my workplace web site:
<http://www.cygnus.com/~billm/stdtypes.c>
A sample stdtypes.h file is at:
<http://www.cygnus.com/~billm/stdtypes.h>
-- Bill Moyer
next prev parent reply other threads:[~1998-06-11 4:00 UTC|newest]
Thread overview: 100+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-06-04 4:00 Alpha window of opportunity? (was Re: Intel announces six month Merced delay.) Anil T Maliyekke
1998-06-05 4:00 ` Steal their thunder (was Re: Alpha window of opportunity?) Alan Chee
1998-06-05 4:00 ` Ketil Z Malde
1998-06-05 4:00 ` Doug Siebert
1998-06-05 4:00 ` Brian Hurt
1998-06-05 4:00 ` Anil T Maliyekke
1998-06-06 4:00 ` Andy Glew
1998-06-09 4:00 ` M Sweger
1998-06-10 4:00 ` 128-bit CPUs (was: Re: Steal their thunder ) Gary Heston
1998-06-12 4:00 ` Steal their thunder (was Re: Alpha window of opportunity?) Gregg E Economou
1998-06-12 4:00 ` Silliness (was Re: Steal their thunder) Bill Moyer
1998-06-13 4:00 ` Jamie Lokier
1998-06-17 4:00 ` Gregg E Economou
1998-06-18 4:00 ` Bernd Paysan
1998-06-18 4:00 ` James Cownie
1998-06-18 4:00 ` Stanley Chow
1998-06-13 4:00 ` Steal their thunder (was Re: Alpha window of opportunity?) Jamie Lokier
1998-06-15 4:00 ` M Sweger
1998-06-17 4:00 ` Gregg E Economou
1998-06-05 4:00 ` Stefan Monnier
1998-06-06 4:00 ` Ketil Z Malde
1998-06-06 4:00 ` Gregg E Economou
1998-06-09 4:00 ` M Sweger
1998-06-14 4:00 ` Heikki Kultala
1998-06-05 4:00 ` Kai Harrekilde-Petersen
1998-06-05 4:00 ` JF Mezei
1998-06-05 4:00 ` George Herbert
1998-06-09 4:00 ` M Sweger
1998-06-10 4:00 ` Russell Sasamori
1998-06-10 4:00 ` Bill Moyer
1998-06-11 4:00 ` Russell Sasamori
1998-06-11 4:00 ` Bill Moyer [this message]
1998-06-10 4:00 ` [++] " Terje Mathisen
1998-06-11 4:00 ` Russell Sasamori
1998-06-11 4:00 ` Terje Mathisen
1998-06-11 4:00 ` Kai Harrekilde-Petersen
1998-06-10 4:00 ` Peter L. Montgomery
1998-06-11 4:00 ` Russell Sasamori
1998-06-06 4:00 ` Ketil Z Malde
1998-06-05 4:00 ` Bernd Paysan
1998-06-05 4:00 ` Craig Burley
1998-06-08 4:00 ` Bernd Paysan
1998-06-09 4:00 ` Maynard Handley
1998-06-06 4:00 ` Gregg E Economou
1998-06-06 4:00 ` Thomas Womack
1998-06-08 4:00 ` Alan Chee
1998-06-08 4:00 ` Gregg E Economou
1998-06-07 4:00 ` Pierre Asselin
1998-06-06 4:00 ` Gregg E Economou
1998-06-08 4:00 ` Terry Shannon
1998-06-08 4:00 ` Miro Jurcevic
1998-06-09 4:00 ` Russell Sasamori
1998-06-09 4:00 ` Ketil Z Malde
1998-06-09 4:00 ` Bernd Paysan
1998-06-09 4:00 ` Petter Gustad
1998-06-09 4:00 ` Joachim Strombergson
1998-06-10 4:00 ` What is bitness? Russell Sasamori
1998-06-10 4:00 ` Jan Vorbrueggen
1998-06-10 4:00 ` Alex Colvin
1998-06-10 4:00 ` Jeffrey S. Dutky
1998-06-11 4:00 ` Russell Sasamori
1998-06-11 4:00 ` Ketil Z Malde
1998-06-11 4:00 ` Jeffrey S. Dutky
1998-06-12 4:00 ` Ketil Z Malde
1998-06-14 4:00 ` msimon
1998-06-11 4:00 ` Russell Sasamori
1998-06-11 4:00 ` Russell Sasamori
1998-06-10 4:00 ` Bernd Paysan
1998-06-11 4:00 ` Russell Sasamori
1998-06-10 4:00 ` Zalman Stern
1998-06-10 4:00 ` Ketil Z Malde
1998-06-11 4:00 ` Russell Sasamori
1998-06-11 4:00 ` Ketil Z Malde
1998-06-10 4:00 ` Peter da Silva
1998-06-11 4:00 ` Gary Heston
1998-06-11 4:00 ` Peter da Silva
1998-06-12 4:00 ` Mike McCarty
1998-06-08 4:00 ` Steal their thunder (was Re: Alpha window of opportunity?) Bill Broadley
1998-06-08 4:00 ` Peter da Silva
1998-06-08 4:00 ` stev knowles
[not found] ` <6lhc0e$bak@web.nmti.com>
1998-06-08 4:00 ` stev knowles
1998-06-08 4:00 ` Gregg E Economou
1998-06-08 4:00 ` Terry Shannon
1998-06-09 4:00 ` Donald G. Marchlenski
1998-06-09 4:00 ` Peter da Silva
1998-06-10 4:00 ` Special VMS Sauce on WNT from McDEC: see http://www.acersoft.com Terry Shannon
[not found] ` <6lmt5s$oaa@web.nmti.com>
1998-06-10 4:00 ` Graham Allan
1998-06-10 4:00 ` Peter da Silva
1998-06-11 4:00 ` Graham Allan
1998-06-11 4:00 ` Quentin Fennessy
1998-06-11 4:00 ` Peter da Silva
1998-06-12 4:00 ` Quentin Fennessy
1998-06-18 4:00 ` Fred Kleinsorge
1998-06-18 4:00 ` quodling
1998-06-12 4:00 ` Steal their thunder (was Re: Alpha window of opportunity?) Gregg E Economou
1998-06-09 4:00 ` JF Mezei
1998-06-09 4:00 ` stev knowles
1998-06-13 4:00 ` Andrew C. Stoffel
1998-06-09 4:00 ` [++] " Terje Mathisen
1998-06-06 4:00 ` Alpha window of opportunity? (was Re: Intel announces six month Merced delay.) Matthias Dolder
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox