OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 #include <stdio.h> | 5 #include <stdio.h> |
6 #include <string.h> | 6 #include <string.h> |
7 #include <signal.h> | 7 #include <signal.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 #include <limits.h> | 9 #include <limits.h> |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 RNG_RandomUpdate(&si, sizeof(si)); | 186 RNG_RandomUpdate(&si, sizeof(si)); |
187 | 187 |
188 si = sysconf(_SC_OPEN_MAX); | 188 si = sysconf(_SC_OPEN_MAX); |
189 RNG_RandomUpdate(&si, sizeof(si)); | 189 RNG_RandomUpdate(&si, sizeof(si)); |
190 } | 190 } |
191 #endif | 191 #endif |
192 | 192 |
193 #if defined(__sun) | 193 #if defined(__sun) |
194 #if defined(__svr4) || defined(SVR4) | 194 #if defined(__svr4) || defined(SVR4) |
195 #include <sys/systeminfo.h> | 195 #include <sys/systeminfo.h> |
196 #include <sys/times.h> | |
197 #include <wait.h> | |
198 | |
199 int gettimeofday(struct timeval *); | |
200 int gethostname(char *, int); | |
201 | 196 |
202 #define getdtablesize() sysconf(_SC_OPEN_MAX) | 197 #define getdtablesize() sysconf(_SC_OPEN_MAX) |
203 | 198 |
204 static void | 199 static void |
205 GiveSystemInfo(void) | 200 GiveSystemInfo(void) |
206 { | 201 { |
207 int rv; | 202 int rv; |
208 char buf[2000]; | 203 char buf[2000]; |
209 | 204 |
210 rv = sysinfo(SI_MACHINE, buf, sizeof(buf)); | 205 rv = sysinfo(SI_MACHINE, buf, sizeof(buf)); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 351 |
357 static size_t | 352 static size_t |
358 GetHighResClock(void *buf, size_t maxbytes) | 353 GetHighResClock(void *buf, size_t maxbytes) |
359 { | 354 { |
360 return 0; | 355 return 0; |
361 } | 356 } |
362 | 357 |
363 static void | 358 static void |
364 GiveSystemInfo(void) | 359 GiveSystemInfo(void) |
365 { | 360 { |
| 361 #ifndef NO_SYSINFO |
366 struct sysinfo si; | 362 struct sysinfo si; |
367 if (sysinfo(&si) == 0) { | 363 if (sysinfo(&si) == 0) { |
368 RNG_RandomUpdate(&si, sizeof(si)); | 364 RNG_RandomUpdate(&si, sizeof(si)); |
369 } | 365 } |
| 366 #endif |
370 } | 367 } |
371 #endif /* LINUX */ | 368 #endif /* LINUX */ |
372 | 369 |
373 #if defined(NCR) | 370 #if defined(NCR) |
374 | 371 |
375 #include <sys/utsname.h> | 372 #include <sys/utsname.h> |
376 #include <sys/systeminfo.h> | 373 #include <sys/systeminfo.h> |
377 | 374 |
378 #define getdtablesize() sysconf(_SC_OPEN_MAX) | 375 #define getdtablesize() sysconf(_SC_OPEN_MAX) |
379 | 376 |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 | 662 |
666 size_t RNG_GetNoise(void *buf, size_t maxbytes) | 663 size_t RNG_GetNoise(void *buf, size_t maxbytes) |
667 { | 664 { |
668 struct timeval tv; | 665 struct timeval tv; |
669 int n = 0; | 666 int n = 0; |
670 int c; | 667 int c; |
671 | 668 |
672 n = GetHighResClock(buf, maxbytes); | 669 n = GetHighResClock(buf, maxbytes); |
673 maxbytes -= n; | 670 maxbytes -= n; |
674 | 671 |
675 #if defined(__sun) && (defined(_svr4) || defined(SVR4)) || defined(sony) | |
676 (void)gettimeofday(&tv); | |
677 #else | |
678 (void)gettimeofday(&tv, 0); | 672 (void)gettimeofday(&tv, 0); |
679 #endif | |
680 c = CopyLowBits((char*)buf+n, maxbytes, &tv.tv_usec, sizeof(tv.tv_usec)); | 673 c = CopyLowBits((char*)buf+n, maxbytes, &tv.tv_usec, sizeof(tv.tv_usec)); |
681 n += c; | 674 n += c; |
682 maxbytes -= c; | 675 maxbytes -= c; |
683 c = CopyLowBits((char*)buf+n, maxbytes, &tv.tv_sec, sizeof(tv.tv_sec)); | 676 c = CopyLowBits((char*)buf+n, maxbytes, &tv.tv_sec, sizeof(tv.tv_sec)); |
684 n += c; | 677 n += c; |
685 return n; | 678 return n; |
686 } | 679 } |
687 | 680 |
688 #define SAFE_POPEN_MAXARGS 10 /* must be at least 2 */ | 681 #define SAFE_POPEN_MAXARGS 10 /* must be at least 2 */ |
689 | 682 |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 fileBytes += bytes; | 1142 fileBytes += bytes; |
1150 buffer += bytes; | 1143 buffer += bytes; |
1151 } | 1144 } |
1152 fclose(file); | 1145 fclose(file); |
1153 if (fileBytes != maxLen) { | 1146 if (fileBytes != maxLen) { |
1154 PORT_SetError(SEC_ERROR_NEED_RANDOM); /* system RNG failed */ | 1147 PORT_SetError(SEC_ERROR_NEED_RANDOM); /* system RNG failed */ |
1155 fileBytes = 0; | 1148 fileBytes = 0; |
1156 } | 1149 } |
1157 return fileBytes; | 1150 return fileBytes; |
1158 } | 1151 } |
OLD | NEW |