Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: srtp/crypto/test/rand_gen_soak.c

Issue 889083003: Update libsrtp to upstream 1.5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libsrtp@master
Patch Set: Minimal changes against upstream 1.5.0 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Soak test the RNG for exhaustion failures
3 */
4 #ifdef HAVE_CONFIG_H
5 #include <config.h>
6 #endif
7
8 #include <stdio.h> /* for printf() */
9 #include <unistd.h> /* for getopt() */
10 #include "crypto_kernel.h"
11
12 #define BUF_LEN (MAX_PRINT_STRING_LEN/2)
13
14 int main(int argc, char *argv[])
15 {
16 int q;
17 extern char *optarg;
18 int num_octets = 0;
19 err_status_t status;
20 uint32_t iterations = 0;
21 int print_values = 0;
22
23 if (argc == 1) {
24 exit(255);
25 }
26
27 status = crypto_kernel_init();
28 if (status) {
29 printf("error: crypto_kernel init failed\n");
30 exit(1);
31 }
32
33 while (1) {
34 q = getopt(argc, argv, "pvn:");
35 if (q == -1) {
36 break;
37 }
38 switch (q) {
39 case 'p':
40 print_values = 1;
41 break;
42 case 'n':
43 num_octets = atoi(optarg);
44 if (num_octets < 0 || num_octets > BUF_LEN) {
45 exit(255);
46 }
47 break;
48 case 'v':
49 num_octets = 30;
50 print_values = 0;
51 break;
52 default:
53 exit(255);
54 }
55 }
56
57 if (num_octets > 0) {
58 while (iterations < 300000) {
59 uint8_t buffer[BUF_LEN];
60
61 status = crypto_get_random(buffer, num_octets);
62 if (status) {
63 printf("iteration %d error: failure in random source\n", iterati ons);
64 exit(255);
65 } else if (print_values) {
66 printf("%s\n", octet_string_hex_string(buffer, num_octets));
67 }
68 iterations++;
69 }
70 }
71
72 status = crypto_kernel_shutdown();
73 if (status) {
74 printf("error: crypto_kernel shutdown failed\n");
75 exit(1);
76 }
77
78 return 0;
79 }
80
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698