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

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

Issue 936663005: Land https://codereview.chromium.org/889083003/ to update libsrtp to upstream 1.5.0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libsrtp/
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « srtp/crypto/test/rand_gen.c ('k') | srtp/crypto/test/sha1_driver.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
OLDNEW
(Empty)
1 /*
2 * Soak test the RNG for exhaustion failures
3 */
4
5 /*
6 *
7 * Copyright (c) 2001-2006, Cisco Systems, Inc.
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 *
17 * Redistributions in binary form must reproduce the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer in the documentation and/or other materials provided
20 * with the distribution.
21 *
22 * Neither the name of the Cisco Systems, Inc. nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
29 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
30 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
31 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
35 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
37 * OF THE POSSIBILITY OF SUCH DAMAGE.
38 *
39 */
40
41 #ifdef HAVE_CONFIG_H
42 #include <config.h>
43 #endif
44
45 #include <stdio.h> /* for printf() */
46 #include <unistd.h> /* for getopt() */
47 #include "crypto_kernel.h"
48
49 #define BUF_LEN (MAX_PRINT_STRING_LEN/2)
50
51 int main(int argc, char *argv[])
52 {
53 int q;
54 extern char *optarg;
55 int num_octets = 0;
56 err_status_t status;
57 uint32_t iterations = 0;
58 int print_values = 0;
59
60 if (argc == 1) {
61 exit(255);
62 }
63
64 status = crypto_kernel_init();
65 if (status) {
66 printf("error: crypto_kernel init failed\n");
67 exit(1);
68 }
69
70 while (1) {
71 q = getopt(argc, argv, "pvn:");
72 if (q == -1) {
73 break;
74 }
75 switch (q) {
76 case 'p':
77 print_values = 1;
78 break;
79 case 'n':
80 num_octets = atoi(optarg);
81 if (num_octets < 0 || num_octets > BUF_LEN) {
82 exit(255);
83 }
84 break;
85 case 'v':
86 num_octets = 30;
87 print_values = 0;
88 break;
89 default:
90 exit(255);
91 }
92 }
93
94 if (num_octets > 0) {
95 while (iterations < 300000) {
96 uint8_t buffer[BUF_LEN];
97
98 status = crypto_get_random(buffer, num_octets);
99 if (status) {
100 printf("iteration %d error: failure in random source\n", iterati ons);
101 exit(255);
102 } else if (print_values) {
103 printf("%s\n", octet_string_hex_string(buffer, num_octets));
104 }
105 iterations++;
106 }
107 }
108
109 status = crypto_kernel_shutdown();
110 if (status) {
111 printf("error: crypto_kernel shutdown failed\n");
112 exit(1);
113 }
114
115 return 0;
116 }
117
OLDNEW
« no previous file with comments | « srtp/crypto/test/rand_gen.c ('k') | srtp/crypto/test/sha1_driver.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698