1c1e80940SXin LI /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3c1e80940SXin LI * 4c1e80940SXin LI * Copyright (c) 2018 Google LLC 5c1e80940SXin LI * All rights reserved. 6c1e80940SXin LI * 7c1e80940SXin LI * Redistribution and use in source and binary forms, with or without 8c1e80940SXin LI * modification, are permitted provided that the following conditions 9c1e80940SXin LI * are met: 10c1e80940SXin LI * 1. Redistributions of source code must retain the above copyright 11c1e80940SXin LI * notice, this list of conditions and the following disclaimer. 12c1e80940SXin LI * 2. Redistributions in binary form must reproduce the above copyright 13c1e80940SXin LI * notice, this list of conditions and the following disclaimer in the 14c1e80940SXin LI * documentation and/or other materials provided with the distribution. 15c1e80940SXin LI * 16c1e80940SXin LI * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17c1e80940SXin LI * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18c1e80940SXin LI * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19c1e80940SXin LI * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20c1e80940SXin LI * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21c1e80940SXin LI * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22c1e80940SXin LI * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23c1e80940SXin LI * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24c1e80940SXin LI * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25c1e80940SXin LI * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26c1e80940SXin LI * SUCH DAMAGE. 27c1e80940SXin LI * 28c1e80940SXin LI * $FreeBSD$ 29c1e80940SXin LI */ 30c1e80940SXin LI 31c1e80940SXin LI #include <sys/cdefs.h> 32c1e80940SXin LI __FBSDID("$FreeBSD$"); 33c1e80940SXin LI 34c1e80940SXin LI #include <sys/types.h> 35c1e80940SXin LI #include <stdbool.h> 36c1e80940SXin LI #include <syslog.h> 37c1e80940SXin LI 38c1e80940SXin LI /* 39c1e80940SXin LI * The following functions were removed from OpenBSD for good reasons: 40c1e80940SXin LI * 41c1e80940SXin LI * - arc4random_stir() 42c1e80940SXin LI * - arc4random_addrandom() 43c1e80940SXin LI * 44c1e80940SXin LI * On FreeBSD, for backward ABI compatibility, we provide two wrapper which 45c1e80940SXin LI * logs this event and returns. 46c1e80940SXin LI */ 47c1e80940SXin LI 48c1e80940SXin LI void __arc4random_stir_fbsd11(void); 49c1e80940SXin LI void __arc4random_addrandom_fbsd11(u_char *, int); 50c1e80940SXin LI 51c1e80940SXin LI void 52c1e80940SXin LI __arc4random_stir_fbsd11(void) 53c1e80940SXin LI { 54c1e80940SXin LI static bool warned = false; 55c1e80940SXin LI 56c1e80940SXin LI if (!warned) 57c1e80940SXin LI syslog(LOG_DEBUG, "Deprecated function arc4random_stir() called"); 58c1e80940SXin LI warned = true; 59c1e80940SXin LI } 60c1e80940SXin LI 61c1e80940SXin LI void 62c1e80940SXin LI __arc4random_addrandom_fbsd11(u_char * dummy1 __unused, int dummy2 __unused) 63c1e80940SXin LI { 64c1e80940SXin LI static bool warned = false; 65c1e80940SXin LI 66c1e80940SXin LI if (!warned) 67c1e80940SXin LI syslog(LOG_DEBUG, "Deprecated function arc4random_addrandom() called"); 68c1e80940SXin LI warned = true; 69c1e80940SXin LI } 70c1e80940SXin LI 71c1e80940SXin LI __sym_compat(arc4random_stir, __arc4random_stir_fbsd11, FBSD_1.0); 72c1e80940SXin LI __sym_compat(arc4random_addrandom, __arc4random_addrandom_fbsd11, FBSD_1.0); 73