lfsr.c revision 15a44745412679c30a6d022733925af70a38b715
/*
* Copyright (C) 1999, 2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: lfsr.c,v 1.9 2000/07/27 09:50:55 tale Exp $ */
#include <config.h>
#include <stdlib.h>
#include <isc/assertions.h>
#define VALID_LFSR(x) (x != NULL)
void
{
}
/*
* Return the next state of the lfsr.
*/
static inline isc_uint32_t
{
unsigned int highbit;
/*
* If the previous state is zero, we must fill it with something
* here, or we will begin to generate an extremely predictable output.
*
* First, give the reseed function a crack at it. If the state is
* still 0, set it to all ones.
*/
}
return (1);
} else {
return (0);
}
}
void
{
unsigned char *p;
unsigned int bit;
unsigned int byte;
p = data;
while (byte--) {
*p = 0;
*p |= lfsr_generate(lfsr);
*p <<= 1;
}
*p |= lfsr_generate(lfsr);
p++;
}
else
}
}
static inline isc_uint32_t
{
while (skip--)
(void)lfsr_generate(lfsr);
(void)lfsr_generate(lfsr);
}
/*
* Skip "skip" states in "lfsr".
*/
void
{
while (skip--)
(void)lfsr_generate(lfsr);
}
/*
* Skip states in lfsr1 and lfsr2 using the other's current state.
* Return the final state of lfsr1 ^ lfsr2.
*/
{
/* cross-skip. */
}