1646041a8SMark Murray /*- 2646041a8SMark Murray * Copyright (c) 2015 Mark R V Murray 3646041a8SMark Murray * All rights reserved. 4646041a8SMark Murray * 5646041a8SMark Murray * Redistribution and use in source and binary forms, with or without 6646041a8SMark Murray * modification, are permitted provided that the following conditions 7646041a8SMark Murray * are met: 8646041a8SMark Murray * 1. Redistributions of source code must retain the above copyright 9646041a8SMark Murray * notice, this list of conditions and the following disclaimer 10646041a8SMark Murray * in this position and unchanged. 11646041a8SMark Murray * 2. Redistributions in binary form must reproduce the above copyright 12646041a8SMark Murray * notice, this list of conditions and the following disclaimer in the 13646041a8SMark Murray * documentation and/or other materials provided with the distribution. 14646041a8SMark Murray * 15646041a8SMark Murray * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16646041a8SMark Murray * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17646041a8SMark Murray * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18646041a8SMark Murray * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19646041a8SMark Murray * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20646041a8SMark Murray * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21646041a8SMark Murray * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22646041a8SMark Murray * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23646041a8SMark Murray * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24646041a8SMark Murray * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25646041a8SMark Murray * 26646041a8SMark Murray * $FreeBSD$ 27646041a8SMark Murray */ 28646041a8SMark Murray 29646041a8SMark Murray /*- 30646041a8SMark Murray * This is a skeleton for folks who wish to build a loadable module 31646041a8SMark Murray * containing an alternative entropy-processing algorithm for random(4). 32646041a8SMark Murray * 33646041a8SMark Murray * The functions below should be completed with the appropriate code, 34*19fa89e9SMark Murray * and the nearby fortuna.c may be consulted for examples of working code. 35646041a8SMark Murray * 36646041a8SMark Murray * The author is willing to provide reasonable help to those wishing to 37646041a8SMark Murray * write such a module for themselves. Please use the markm@ FreeBSD 38646041a8SMark Murray * email address, and ensure that you are developing this on a suitably 39*19fa89e9SMark Murray * supported branch (This is currently 12-CURRENT, and may be no 40*19fa89e9SMark Murray * older than 12-STABLE in the future). 41646041a8SMark Murray */ 42646041a8SMark Murray 43646041a8SMark Murray #ifndef SYS_DEV_RANDOM_OTHER_H_INCLUDED 44646041a8SMark Murray #define SYS_DEV_RANDOM_OTHER_H_INCLUDED 45646041a8SMark Murray 46646041a8SMark Murray #ifdef _KERNEL 47646041a8SMark Murray typedef struct mtx mtx_t; 48646041a8SMark Murray #define RANDOM_RESEED_INIT_LOCK(x) mtx_init(&other_mtx, "reseed mutex", NULL, MTX_DEF) 49646041a8SMark Murray #define RANDOM_RESEED_DEINIT_LOCK(x) mtx_destroy(&other_mtx) 50646041a8SMark Murray #define RANDOM_RESEED_LOCK(x) mtx_lock(&other_mtx) 51646041a8SMark Murray #define RANDOM_RESEED_UNLOCK(x) mtx_unlock(&other_mtx) 52646041a8SMark Murray #define RANDOM_RESEED_ASSERT_LOCK_OWNED(x) mtx_assert(&other_mtx, MA_OWNED) 53646041a8SMark Murray #else 54646041a8SMark Murray #define RANDOM_RESEED_INIT_LOCK(x) mtx_init(&other_mtx, mtx_plain) 55646041a8SMark Murray #define RANDOM_RESEED_DEINIT_LOCK(x) mtx_destroy(&other_mtx) 56646041a8SMark Murray #define RANDOM_RESEED_LOCK(x) mtx_lock(&other_mtx) 57646041a8SMark Murray #define RANDOM_RESEED_UNLOCK(x) mtx_unlock(&other_mtx) 58646041a8SMark Murray #define RANDOM_RESEED_ASSERT_LOCK_OWNED(x) 59646041a8SMark Murray #endif 60646041a8SMark Murray 61646041a8SMark Murray #endif /* SYS_DEV_RANDOM_OTHER_H_INCLUDED */ 62