lfsr_test.c revision ab023a65562e62b85a824509d829b6fad87e00b1
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * Copyright (C) 1999-2001 Internet Software Consortium.
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * Permission to use, copy, modify, and distribute this software for any
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * purpose with or without fee is hereby granted, provided that the above
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * copyright notice and this permission notice appear in all copies.
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * PERFORMANCE OF THIS SOFTWARE.
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff/* $Id: lfsr_test.c,v 1.13 2005/04/27 04:56:09 sra Exp $ */
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * Verify that returned values are reproducable.
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff isc_lfsr_init(&lfsr1, 0, 32, 0x80000057U, 0, NULL, NULL);
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff for (i = 0; i < 32; i++) {
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff printf("lfsr1: state[%2d] = %08x\n", i, state[i]);
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff isc_lfsr_init(&lfsr1, 0, 32, 0x80000057U, 0, NULL, NULL);
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff for (i = 0; i < 32; i++) {
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff "but new state is %08x\n",
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * Now do the same with skipping.
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff isc_lfsr_init(&lfsr1, 0, 32, 0x80000057U, 0, NULL, NULL);
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff for (i = 0; i < 32; i++) {
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff printf("lfsr1: state[%2d] = %08x\n", i, state[i]);
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff isc_lfsr_init(&lfsr1, 0, 32, 0x80000057U, 0, NULL, NULL);
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff for (i = 0; i < 32; i++) {
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff "but new state is %08x\n",
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * Try to find the period of the LFSR.
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff * x^16 + x^5 + x^3 + x^2 + 1
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff isc_lfsr_init(&lfsr2, 0, 16, 0x00008016U, 0, NULL, NULL);
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff for (i = 0; i < 32; i++) {
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff printf("lfsr2: state[%2d] = %08x\n", i, state[i]);
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff isc_lfsr_init(&lfsr2, 0, 16, 0x00008016U, 0, NULL, NULL);
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff for (i = 0; i < 32; i++) {
5585e5da649f170b57a6b70d2014729956c621a7Michael Graff "but new state is %08x\n",