1- /* $NetBSD: arc4random.c,v 1.13 2012/03/05 19:40:08 christos Exp $ */
1+ /* $NetBSD: arc4random.c,v 1.14 2012/07/29 14:44:13 dsl Exp $ */
22/* $OpenBSD: arc4random.c,v 1.6 2001/06/05 05:05:38 pvalchev Exp $ */
33
44/*
2727
2828#include <sys/cdefs.h>
2929#if defined(LIBC_SCCS ) && !defined(lint )
30- __RCSID ("$NetBSD: arc4random.c,v 1.13 2012/03/05 19:40:08 christos Exp $" );
30+ __RCSID ("$NetBSD: arc4random.c,v 1.14 2012/07/29 14:44:13 dsl Exp $" );
3131#endif /* LIBC_SCCS and not lint */
3232
3333#include "namespace.h"
@@ -65,7 +65,8 @@ static inline uint32_t arc4_getword(struct arc4_stream *);
6565static inline void
6666arc4_init (struct arc4_stream * as )
6767{
68- for (int n = 0 ; n < RSIZE ; n ++ )
68+ int n ;
69+ for (n = 0 ; n < RSIZE ; n ++ )
6970 as -> s [n ] = n ;
7071 as -> i = 0 ;
7172 as -> j = 0 ;
@@ -78,9 +79,10 @@ static inline void
7879arc4_addrandom (struct arc4_stream * as , u_char * dat , int datlen )
7980{
8081 uint8_t si ;
82+ int n ;
8183
8284 as -> i -- ;
83- for (int n = 0 ; n < RSIZE ; n ++ ) {
85+ for (n = 0 ; n < RSIZE ; n ++ ) {
8486 as -> i = (as -> i + 1 );
8587 si = as -> s [as -> i ];
8688 as -> j = (as -> j + si + dat [n % datlen ]);
@@ -94,8 +96,9 @@ static void
9496arc4_stir (struct arc4_stream * as )
9597{
9698 int rdat [32 ];
97- static const int mib [] = { CTL_KERN , KERN_URND };
99+ int mib [] = { CTL_KERN , KERN_URND };
98100 size_t len ;
101+ size_t i , j ;
99102
100103 /*
101104 * This code once opened and read /dev/urandom on each
@@ -106,7 +109,7 @@ arc4_stir(struct arc4_stream *as)
106109 * for us but much friendlier to other entropy consumers.
107110 */
108111
109- for (size_t i = 0 ; i < __arraycount (rdat ); i ++ ) {
112+ for (i = 0 ; i < __arraycount (rdat ); i ++ ) {
110113 len = sizeof (rdat [i ]);
111114 if (sysctl (mib , 2 , & rdat [i ], & len , NULL , 0 ) == -1 )
112115 abort ();
@@ -119,7 +122,7 @@ arc4_stir(struct arc4_stream *as)
119122 * paper "Weaknesses in the Key Scheduling Algorithm of RC4"
120123 * by Fluher, Mantin, and Shamir. (N = 256 in our case.)
121124 */
122- for (size_t j = 0 ; j < RSIZE * 4 ; j ++ )
125+ for (j = 0 ; j < RSIZE * 4 ; j ++ )
123126 arc4_getbyte (as );
124127}
125128
0 commit comments