Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net use arc4random



details:   https://anonhg.NetBSD.org/src/rev/37c7a97442ca
branches:  trunk
changeset: 547192:37c7a97442ca
user:      itojun <itojun%NetBSD.org@localhost>
date:      Wed May 14 23:16:44 2003 +0000

description:
use arc4random

diffstat:

 sys/net/if_bridge.c   |  16 +++-------------
 sys/net/if_spppsubr.c |  25 +++++++++++--------------
 2 files changed, 14 insertions(+), 27 deletions(-)

diffs (128 lines):

diff -r 262997e2b2bd -r 37c7a97442ca sys/net/if_bridge.c
--- a/sys/net/if_bridge.c       Wed May 14 22:45:02 2003 +0000
+++ b/sys/net/if_bridge.c       Wed May 14 23:16:44 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bridge.c,v 1.11 2003/03/19 10:34:34 bouyer Exp $    */
+/*     $NetBSD: if_bridge.c,v 1.12 2003/05/14 23:18:29 itojun Exp $    */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -82,11 +82,10 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.11 2003/03/19 10:34:34 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.12 2003/05/14 23:18:29 itojun Exp $");
 
 #include "opt_bridge_ipf.h"
 #include "bpfilter.h"
-#include "rnd.h"
 
 #include <sys/param.h> 
 #include <sys/kernel.h>
@@ -98,10 +97,6 @@
 #include <sys/proc.h> 
 #include <sys/pool.h>
 
-#if NRND > 0
-#include <sys/rnd.h>
-#endif
-
 #if NBPFILTER > 0
 #include <net/bpf.h>
 #endif 
@@ -1764,12 +1759,7 @@
        for (i = 0; i < BRIDGE_RTHASH_SIZE; i++)
                LIST_INIT(&sc->sc_rthash[i]);
 
-#if NRND > 0
-       rnd_extract_data(&sc->sc_rthash_key, sizeof(sc->sc_rthash_key),
-           RND_EXTRACT_ANY);
-#else
-       sc->sc_rthash_key = random();
-#endif /* NRND > 0 */
+       sc->sc_rthash_key = arc4random();
 
        LIST_INIT(&sc->sc_rtlist);
 
diff -r 262997e2b2bd -r 37c7a97442ca sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c     Wed May 14 22:45:02 2003 +0000
+++ b/sys/net/if_spppsubr.c     Wed May 14 23:16:44 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_spppsubr.c,v 1.64 2003/05/14 22:41:40 itojun Exp $   */
+/*     $NetBSD: if_spppsubr.c,v 1.65 2003/05/14 23:16:44 itojun Exp $   */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.64 2003/05/14 22:41:40 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.65 2003/05/14 23:16:44 itojun Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipx.h"
@@ -1241,7 +1241,7 @@
                        ++sp->pp_loopcnt;
 
                        /* Generate new local sequence number */
-                       sp->pp_seq[IDX_LCP] = random();
+                       sp->pp_seq[IDX_LCP] = arc4random();
                        break;
                }
                sp->pp_loopcnt = 0;
@@ -2459,7 +2459,7 @@
                                if (magic == ~sp->lcp.magic) {
                                        if (debug)
                                                addlog(" magic glitch");
-                                       sp->lcp.magic = random();
+                                       sp->lcp.magic = arc4random();
                                } else {
                                        sp->lcp.magic = magic;
                                        if (debug)
@@ -2642,7 +2642,7 @@
 
        if (sp->lcp.opts & (1 << LCP_OPT_MAGIC)) {
                if (! sp->lcp.magic)
-                       sp->lcp.magic = random();
+                       sp->lcp.magic = arc4random();
                opt[i++] = LCP_OPT_MAGIC;
                opt[i++] = 6;
                opt[i++] = sp->lcp.magic >> 24;
@@ -4124,7 +4124,7 @@
                 * Compute the re-challenge timeout.  This will yield
                 * a number between 300 and 810 seconds.
                 */
-               i = 300 + ((unsigned)(random() & 0xff00) >> 7);
+               i = 300 + ((unsigned)(arc4random() & 0xff00) >> 7);
 
                callout_reset(&sp->ch[IDX_CHAP], i * hz, chap.TO, sp);
        }
@@ -4180,8 +4180,7 @@
 static void
 sppp_chap_scr(struct sppp *sp)
 {
-       struct timeval tv;
-       u_int32_t *ch, seed;
+       u_int32_t *ch;
        u_char clen;
 
        if (sp->myauth.name == NULL) {
@@ -4193,12 +4192,10 @@
 
        /* Compute random challenge. */
        ch = (u_int32_t *)sp->myauth.challenge;
-       microtime(&tv);
-       seed = tv.tv_sec ^ tv.tv_usec;
-       ch[0] = seed ^ random();
-       ch[1] = seed ^ random();
-       ch[2] = seed ^ random();
-       ch[3] = seed ^ random();
+       ch[0] = arc4random();
+       ch[1] = arc4random();
+       ch[2] = arc4random();
+       ch[3] = arc4random();
        clen = 16;      /* 4 * sizeof(u_int32_t) */
 
        sp->confid[IDX_CHAP] = ++sp->pp_seq[IDX_CHAP];



Home | Main Index | Thread Index | Old Index