summaryrefslogtreecommitdiff
path: root/bsd-misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'bsd-misc.c')
-rw-r--r--bsd-misc.c68
1 files changed, 32 insertions, 36 deletions
diff --git a/bsd-misc.c b/bsd-misc.c
index dd1f6a476..3186c86d8 100644
--- a/bsd-misc.c
+++ b/bsd-misc.c
@@ -1,38 +1,31 @@
1/* 1/*
2** 2 * Copyright (c) 1999-2000 Damien Miller. All rights reserved.
3** OpenBSD replacement routines 3 *
4** 4 * Redistribution and use in source and binary forms, with or without
5** Damien Miller <djm@ibs.com.au> 5 * modification, are permitted provided that the following conditions
6** 6 * are met:
7** Copyright 1999 Damien Miller 7 * 1. Redistributions of source code must retain the above copyright
8** Copyright 1999 Internet Business Solutions 8 * notice, this list of conditions and the following disclaimer.
9** 9 * 2. Redistributions in binary form must reproduce the above copyright
10** Permission is hereby granted, free of charge, to any person 10 * notice, this list of conditions and the following disclaimer in the
11** obtaining a copy of this software and associated documentation 11 * documentation and/or other materials provided with the distribution.
12** files (the "Software"), to deal in the Software without 12 * 3. All advertising materials mentioning features or use of this software
13** restriction, including without limitation the rights to use, copy, 13 * must display the following acknowledgement:
14** modify, merge, publish, distribute, sublicense, and/or sell copies 14 * This product includes software developed by Markus Friedl.
15** of the Software, and to permit persons to whom the Software is 15 * 4. The name of the author may not be used to endorse or promote products
16** furnished to do so, subject to the following conditions: 16 * derived from this software without specific prior written permission.
17** 17 *
18** The above copyright notice and this permission notice shall be 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19** included in all copies or substantial portions of the Software. 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20** 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22** KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23** WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24** AND NONINFRINGEMENT. IN NO EVENT SHALL DAMIEN MILLER OR INTERNET 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25** BUSINESS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28** OR OTHER DEALINGS IN THE SOFTWARE. 28 */
29**
30** Except as contained in this notice, the name of Internet Business
31** Solutions shall not be used in advertising or otherwise to promote
32** the sale, use or other dealings in this Software without prior
33** written authorization from Internet Business Solutions.
34**
35*/
36 29
37#include "config.h" 30#include "config.h"
38 31
@@ -52,7 +45,7 @@
52#include "xmalloc.h" 45#include "xmalloc.h"
53#include "ssh.h" 46#include "ssh.h"
54#include "bsd-misc.h" 47#include "bsd-misc.h"
55#include "random.h" 48#include "entropy.h"
56 49
57#ifndef HAVE_ARC4RANDOM 50#ifndef HAVE_ARC4RANDOM
58 51
@@ -125,8 +118,11 @@ void arc4random_stir(void)
125 118
126 if (rc4 == NULL) 119 if (rc4 == NULL)
127 rc4 = xmalloc(sizeof(*rc4)); 120 rc4 = xmalloc(sizeof(*rc4));
121
122 seed_rng();
123 RAND_bytes(rand_buf, sizeof(rand_buf));
124 seed_rng();
128 125
129 get_random_bytes(rand_buf, sizeof(rand_buf));
130 rc4_key(rc4, rand_buf, sizeof(rand_buf)); 126 rc4_key(rc4, rand_buf, sizeof(rand_buf));
131 memset(rand_buf, 0, sizeof(rand_buf)); 127 memset(rand_buf, 0, sizeof(rand_buf));
132} 128}