1256381Smarkm/*-
2256381Smarkm * Copyright (c) 2013 Arthur Mesh <arthurmesh@gmail.com>
3256381Smarkm * Copyright (c) 2013 Mark R V Murray
4256381Smarkm * All rights reserved.
5256381Smarkm *
6256381Smarkm * Redistribution and use in source and binary forms, with or without
7256381Smarkm * modification, are permitted provided that the following conditions
8256381Smarkm * are met:
9256381Smarkm * 1. Redistributions of source code must retain the above copyright
10256381Smarkm *    notice, this list of conditions and the following disclaimer
11256381Smarkm *    in this position and unchanged.
12256381Smarkm * 2. Redistributions in binary form must reproduce the above copyright
13256381Smarkm *    notice, this list of conditions and the following disclaimer in the
14256381Smarkm *    documentation and/or other materials provided with the distribution.
15256381Smarkm *
16256381Smarkm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17256381Smarkm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18256381Smarkm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19256381Smarkm * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20256381Smarkm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21256381Smarkm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22256381Smarkm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23256381Smarkm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24256381Smarkm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25256381Smarkm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26256381Smarkm *
27256381Smarkm * $FreeBSD$
28256381Smarkm */
29256381Smarkm
30256381Smarkm#ifndef SYS_DEV_RANDOM_LIVE_ENTROPY_SOURCES_H_INCLUDED
31256381Smarkm#define SYS_DEV_RANDOM_LIVE_ENTROPY_SOURCES_H_INCLUDED
32256381Smarkm
33256381Smarkm/*
34256381Smarkm * Live entropy source is a source of entropy that can provide
35256381Smarkm * specified or approximate amount of entropy immediately upon request or within
36256381Smarkm * an acceptable amount of time.
37256381Smarkm */
38256381Smarkmstruct live_entropy_sources {
39256381Smarkm	LIST_ENTRY(live_entropy_sources) entries;	/* list of providers */
40256381Smarkm	struct random_hardware_source	*rsource;	/* associated random adaptor */
41256381Smarkm};
42256381Smarkm
43256381Smarkmextern struct mtx live_mtx;
44256381Smarkm
45256381Smarkmvoid live_entropy_source_register(struct random_hardware_source *);
46256381Smarkmvoid live_entropy_source_deregister(struct random_hardware_source *);
47256381Smarkmvoid live_entropy_sources_feed(int, event_proc_f);
48256381Smarkm
49256381Smarkm#define LIVE_ENTROPY_SRC_MODULE(name, modevent, ver)		\
50256381Smarkm    static moduledata_t name##_mod = {				\
51256381Smarkm	#name,							\
52256381Smarkm	modevent,						\
53256381Smarkm	0							\
54256381Smarkm    };								\
55295480Sjhb    DECLARE_MODULE(name, name##_mod, SI_SUB_RANDOM,		\
56256381Smarkm		   SI_ORDER_SECOND);				\
57256381Smarkm    MODULE_VERSION(name, ver);					\
58256381Smarkm    MODULE_DEPEND(name, random, 1, 1, 1);
59256381Smarkm
60256381Smarkm#endif /* SYS_DEV_RANDOM_LIVE_ENTROPY_SOURCES_H_INCLUDED */
61