arc4random.c (50476) | arc4random.c (55837) |
---|---|
1/* $FreeBSD: head/lib/libc/gen/arc4random.c 50476 1999-08-28 00:22:10Z peter $ */ | 1/* $FreeBSD: head/lib/libc/gen/arc4random.c 55837 2000-01-12 09:23:48Z jasone $ */ |
2 3/* 4 * Arc4 random number generator for OpenBSD. 5 * Copyright 1996 David Mazieres <dm@lcs.mit.edu>. 6 * 7 * Modification and redistribution in source and binary forms is 8 * permitted provided that due credit is given to the author and the 9 * OpenBSD project (for instance by leaving this copyright notice --- 69 unchanged lines hidden (view full) --- 79 struct { 80 struct timeval tv; 81 pid_t pid; 82 u_int8_t rnd[128 - sizeof(struct timeval) - sizeof(pid_t)]; 83 } rdat; 84 85 gettimeofday(&rdat.tv, NULL); 86 rdat.pid = getpid(); | 2 3/* 4 * Arc4 random number generator for OpenBSD. 5 * Copyright 1996 David Mazieres <dm@lcs.mit.edu>. 6 * 7 * Modification and redistribution in source and binary forms is 8 * permitted provided that due credit is given to the author and the 9 * OpenBSD project (for instance by leaving this copyright notice --- 69 unchanged lines hidden (view full) --- 79 struct { 80 struct timeval tv; 81 pid_t pid; 82 u_int8_t rnd[128 - sizeof(struct timeval) - sizeof(pid_t)]; 83 } rdat; 84 85 gettimeofday(&rdat.tv, NULL); 86 rdat.pid = getpid(); |
87 fd = open("/dev/urandom", O_RDONLY, 0); | 87 fd = _libc_open("/dev/urandom", O_RDONLY, 0); |
88 if (fd >= 0) { | 88 if (fd >= 0) { |
89 (void) read(fd, rdat.rnd, sizeof(rdat.rnd)); 90 close(fd); | 89 (void) _libc_read(fd, rdat.rnd, sizeof(rdat.rnd)); 90 _libc_close(fd); |
91 } 92 /* fd < 0? Ah, what the heck. We'll just take whatever was on the 93 * stack... */ 94 95 arc4_addrandom(as, (void *) &rdat, sizeof(rdat)); 96} 97 98static inline u_int8_t --- 74 unchanged lines hidden --- | 91 } 92 /* fd < 0? Ah, what the heck. We'll just take whatever was on the 93 * stack... */ 94 95 arc4_addrandom(as, (void *) &rdat, sizeof(rdat)); 96} 97 98static inline u_int8_t --- 74 unchanged lines hidden --- |