1 /* $FreeBSD: src/sys/dev/rndtest/rndtest.h,v 1.1.4.1 2003/06/04 17:10:30 sam Exp $ */ 2 /* $DragonFly: src/sys/dev/crypto/rndtest/rndtest.h,v 1.2 2003/06/17 04:28:29 dillon Exp $ */ 3 /* $OpenBSD$ */ 4 5 /* 6 * Copyright (c) 2002 Jason L. Wright (jason@thought.net) 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by Jason L. Wright 20 * 4. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 37 /* Some of the tests depend on these values */ 38 #define RNDTEST_NBYTES 2500 39 #define RNDTEST_NBITS (8 * RNDTEST_NBYTES) 40 41 struct rndtest_state { 42 device_t rs_parent; /* associated device */ 43 u_int8_t *rs_end, *rs_begin, *rs_current; 44 struct callout rs_to; 45 int rs_collect; /* collect and test data */ 46 int rs_discard; /* discard/accept random data */ 47 u_int8_t rs_buf[RNDTEST_NBYTES]; 48 }; 49 50 struct rndtest_stats { 51 u_int32_t rst_discard; /* number of bytes discarded */ 52 u_int32_t rst_tests; /* number of test runs */ 53 u_int32_t rst_monobit; /* monobit test failures */ 54 u_int32_t rst_runs; /* 0/1 runs failures */ 55 u_int32_t rst_longruns; /* longruns failures */ 56 u_int32_t rst_chi; /* chi^2 failures */ 57 }; 58 59 extern struct rndtest_state *rndtest_attach(device_t dev); 60 extern void rndtest_detach(struct rndtest_state *); 61 extern void rndtest_harvest(struct rndtest_state *arg, void * buf, u_int len); 62