random.h revision 26491
1226586Sdim/*
2226586Sdim * random.h -- A strong random number generator
3226586Sdim *
4226586Sdim * $Id: random.h,v 1.11 1997/02/22 09:35:05 peter Exp $
5226586Sdim *
6226586Sdim * Version 0.95, last modified 18-Oct-95
7226586Sdim *
8226586Sdim * Copyright Theodore Ts'o, 1994, 1995.  All rights reserved.
9226586Sdim *
10226586Sdim * Redistribution and use in source and binary forms, with or without
11226586Sdim * modification, are permitted provided that the following conditions
12226586Sdim * are met:
13226586Sdim * 1. Redistributions of source code must retain the above copyright
14226586Sdim *    notice, and the entire permission notice in its entirety,
15226586Sdim *    including the disclaimer of warranties.
16226586Sdim * 2. Redistributions in binary form must reproduce the above copyright
17226586Sdim *    notice, this list of conditions and the following disclaimer in the
18226586Sdim *    documentation and/or other materials provided with the distribution.
19226586Sdim * 3. The name of the author may not be used to endorse or promote
20226586Sdim *    products derived from this software without specific prior
21226586Sdim *    written permission.
22226586Sdim *
23249423Sdim * ALTERNATIVELY, this product may be distributed under the terms of
24249423Sdim * the GNU Public License, in which case the provisions of the GPL are
25226586Sdim * required INSTEAD OF the above restrictions.  (This clause is
26226586Sdim * necessary due to a potential bad interaction between the GPL and
27226586Sdim * the restrictions contained in a BSD-style copyright.)
28226586Sdim *
29226586Sdim * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
30226586Sdim * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
31226586Sdim * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32226586Sdim * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
33226586Sdim * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34226586Sdim * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35226586Sdim * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36226586Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37226586Sdim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38226586Sdim * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39226586Sdim * OF THE POSSIBILITY OF SUCH DAMAGE.
40226586Sdim *
41226586Sdim */
42226586Sdim
43226586Sdim/*
44226586Sdim * Many kernel routines will have a use for good random numbers,
45226586Sdim * for example, for truely random TCP sequence numbers, which prevent
46226586Sdim * certain forms of TCP spoofing attacks.
47249423Sdim *
48226586Sdim */
49226586Sdim
50226586Sdim#ifndef	_MACHINE_RANDOM_H_
51249423Sdim#define	_MACHINE_RANDOM_H_
52226586Sdim
53226586Sdim#include <sys/ioccom.h>
54226586Sdim
55226586Sdim#define	MEM_SETIRQ	_IOW('r', 1, u_int16_t)	/* set interrupt */
56226586Sdim#define	MEM_CLEARIRQ	_IOW('r', 2, u_int16_t)	/* clear interrupt */
57226586Sdim#define	MEM_RETURNIRQ	_IOR('r', 3, u_int16_t)	/* return interrupt */
58249423Sdim
59226586Sdim#ifdef KERNEL
60226586Sdim
61226586Sdim/* Interrupts to be used in the randomizing process */
62226586Sdim
63226586Sdimextern inthand2_t *sec_intr_handler[];
64226586Sdimextern int sec_intr_unit[];
65226586Sdim
66226586Sdim/* Exported functions */
67226586Sdim
68226586Sdimvoid rand_initialize(void);
69226586Sdimvoid add_keyboard_randomness(u_char scancode);
70226586Sdimvoid add_interrupt_randomness(int irq);
71226586Sdim#ifdef notused
72226586Sdimvoid add_blkdev_randomness(int major);
73226586Sdim#endif
74226586Sdim
75226586Sdim#ifdef notused
76226586Sdimvoid get_random_bytes(void *buf, u_int nbytes);
77226586Sdim#endif
78226586Sdimu_int read_random(char *buf, u_int size);
79226586Sdimu_int read_random_unlimited(char *buf, u_int size);
80226586Sdim#ifdef notused
81226586Sdimu_int write_random(const char *buf, u_int nbytes);
82226586Sdim#endif
83226586Sdimint random_select(dev_t dev, int rw, struct proc *p);
84226586Sdim
85226586Sdim#endif /* KERNEL */
86226586Sdim
87226586Sdim#endif /* !_MACHINE_RANDOM_H_ */
88226586Sdim