| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Soak test the RNG for exhaustion failures | 2 * Soak test the RNG for exhaustion failures |
| 3 */ | 3 */ |
| 4 | 4 |
| 5 /* | 5 /* |
| 6 * | 6 * |
| 7 * Copyright (c) 2001-2006, Cisco Systems, Inc. | 7 * Copyright (c) 2001-2006, Cisco Systems, Inc. |
| 8 * All rights reserved. | 8 * All rights reserved. |
| 9 * | 9 * |
| 10 * Redistribution and use in source and binary forms, with or without | 10 * Redistribution and use in source and binary forms, with or without |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 37 * OF THE POSSIBILITY OF SUCH DAMAGE. | 37 * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 38 * | 38 * |
| 39 */ | 39 */ |
| 40 | 40 |
| 41 #ifdef HAVE_CONFIG_H | 41 #ifdef HAVE_CONFIG_H |
| 42 #include <config.h> | 42 #include <config.h> |
| 43 #endif | 43 #endif |
| 44 | 44 |
| 45 #include <stdio.h> /* for printf() */ | 45 #include <stdio.h> /* for printf() */ |
| 46 #include <unistd.h> /* for getopt() */ | 46 #include "getopt_s.h" |
| 47 #include "crypto_kernel.h" | 47 #include "crypto_kernel.h" |
| 48 | 48 |
| 49 #define BUF_LEN (MAX_PRINT_STRING_LEN/2) | 49 #define BUF_LEN (MAX_PRINT_STRING_LEN/2) |
| 50 | 50 |
| 51 int main(int argc, char *argv[]) | 51 int main(int argc, char *argv[]) |
| 52 { | 52 { |
| 53 int q; | 53 int q; |
| 54 extern char *optarg; | |
| 55 int num_octets = 0; | 54 int num_octets = 0; |
| 56 err_status_t status; | 55 err_status_t status; |
| 57 uint32_t iterations = 0; | 56 uint32_t iterations = 0; |
| 58 int print_values = 0; | 57 int print_values = 0; |
| 59 | 58 |
| 60 if (argc == 1) { | 59 if (argc == 1) { |
| 61 exit(255); | 60 exit(255); |
| 62 } | 61 } |
| 63 | 62 |
| 64 status = crypto_kernel_init(); | 63 status = crypto_kernel_init(); |
| 65 if (status) { | 64 if (status) { |
| 66 printf("error: crypto_kernel init failed\n"); | 65 printf("error: crypto_kernel init failed\n"); |
| 67 exit(1); | 66 exit(1); |
| 68 } | 67 } |
| 69 | 68 |
| 70 while (1) { | 69 while (1) { |
| 71 q = getopt(argc, argv, "pvn:"); | 70 q = getopt_s(argc, argv, "pvn:"); |
| 72 if (q == -1) { | 71 if (q == -1) { |
| 73 break; | 72 break; |
| 74 } | 73 } |
| 75 switch (q) { | 74 switch (q) { |
| 76 case 'p': | 75 case 'p': |
| 77 print_values = 1; | 76 print_values = 1; |
| 78 break; | 77 break; |
| 79 case 'n': | 78 case 'n': |
| 80 num_octets = atoi(optarg); | 79 num_octets = atoi(optarg_s); |
| 81 if (num_octets < 0 || num_octets > BUF_LEN) { | 80 if (num_octets < 0 || num_octets > BUF_LEN) { |
| 82 exit(255); | 81 exit(255); |
| 83 } | 82 } |
| 84 break; | 83 break; |
| 85 case 'v': | 84 case 'v': |
| 86 num_octets = 30; | 85 num_octets = 30; |
| 87 print_values = 0; | 86 print_values = 0; |
| 88 break; | 87 break; |
| 89 default: | 88 default: |
| 90 exit(255); | 89 exit(255); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 108 | 107 |
| 109 status = crypto_kernel_shutdown(); | 108 status = crypto_kernel_shutdown(); |
| 110 if (status) { | 109 if (status) { |
| 111 printf("error: crypto_kernel shutdown failed\n"); | 110 printf("error: crypto_kernel shutdown failed\n"); |
| 112 exit(1); | 111 exit(1); |
| 113 } | 112 } |
| 114 | 113 |
| 115 return 0; | 114 return 0; |
| 116 } | 115 } |
| 117 | 116 |
| OLD | NEW |