lfsr.c revision 69fe9aaafdd6a141610e86a777d325db75422070
/*
* Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2002 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 ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC 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.16 2005/04/29 00:23:27 marka Exp $ */
/*! \file */
#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. */
}