| Index: srtp/crypto/test/rand_gen_soak.c
|
| diff --git a/srtp/crypto/test/kernel_driver.c b/srtp/crypto/test/rand_gen_soak.c
|
| similarity index 51%
|
| copy from srtp/crypto/test/kernel_driver.c
|
| copy to srtp/crypto/test/rand_gen_soak.c
|
| index 8ef8a5f4b35ca6a79706d0d3c86926e1acd20e72..a39aaa06eb8bd51feb24b33941849c5af32fb21b 100644
|
| --- a/srtp/crypto/test/kernel_driver.c
|
| +++ b/srtp/crypto/test/rand_gen_soak.c
|
| @@ -1,14 +1,10 @@
|
| /*
|
| - * kernel_driver.c
|
| - *
|
| - * a test driver for the crypto_kernel
|
| - *
|
| - * David A. McGrew
|
| - * Cisco Systems, Inc.
|
| + * Soak test the RNG for exhaustion failures
|
| */
|
| +
|
| /*
|
| *
|
| - * Copyright(c) 2001-2006 Cisco Systems, Inc.
|
| + * Copyright (c) 2001-2006, Cisco Systems, Inc.
|
| * All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| @@ -42,85 +38,80 @@
|
| *
|
| */
|
|
|
| +#ifdef HAVE_CONFIG_H
|
| + #include <config.h>
|
| +#endif
|
|
|
| #include <stdio.h> /* for printf() */
|
| #include <unistd.h> /* for getopt() */
|
| #include "crypto_kernel.h"
|
|
|
| -void
|
| -usage(char *prog_name) {
|
| - printf("usage: %s [ -v ][ -d debug_module ]*\n", prog_name);
|
| - exit(255);
|
| -}
|
| -
|
| -int
|
| -main (int argc, char *argv[]) {
|
| - extern char *optarg;
|
| - int q;
|
| - int do_validation = 0;
|
| - err_status_t status;
|
| -
|
| - if (argc == 1)
|
| - usage(argv[0]);
|
| +#define BUF_LEN (MAX_PRINT_STRING_LEN/2)
|
|
|
| - /* initialize kernel - we need to do this before anything else */
|
| - status = crypto_kernel_init();
|
| - if (status) {
|
| - printf("error: crypto_kernel init failed\n");
|
| - exit(1);
|
| - }
|
| - printf("crypto_kernel successfully initalized\n");
|
| +int main(int argc, char *argv[])
|
| +{
|
| + int q;
|
| + extern char *optarg;
|
| + int num_octets = 0;
|
| + err_status_t status;
|
| + uint32_t iterations = 0;
|
| + int print_values = 0;
|
|
|
| - /* process input arguments */
|
| - while (1) {
|
| - q = getopt(argc, argv, "vd:");
|
| - if (q == -1)
|
| - break;
|
| - switch (q) {
|
| - case 'v':
|
| - do_validation = 1;
|
| - break;
|
| - case 'd':
|
| - status = crypto_kernel_set_debug_module(optarg, 1);
|
| - if (status) {
|
| - printf("error: set debug module (%s) failed\n", optarg);
|
| - exit(1);
|
| - }
|
| - break;
|
| - default:
|
| - usage(argv[0]);
|
| - }
|
| - }
|
| + if (argc == 1) {
|
| + exit(255);
|
| + }
|
|
|
| - if (do_validation) {
|
| - printf("checking crypto_kernel status...\n");
|
| - status = crypto_kernel_status();
|
| + status = crypto_kernel_init();
|
| if (status) {
|
| - printf("failed\n");
|
| - exit(1);
|
| + printf("error: crypto_kernel init failed\n");
|
| + exit(1);
|
| }
|
| - printf("crypto_kernel passed self-tests\n");
|
| - }
|
|
|
| - status = crypto_kernel_shutdown();
|
| - if (status) {
|
| - printf("error: crypto_kernel shutdown failed\n");
|
| - exit(1);
|
| - }
|
| - printf("crypto_kernel successfully shut down\n");
|
| -
|
| - return 0;
|
| -}
|
| + while (1) {
|
| + q = getopt(argc, argv, "pvn:");
|
| + if (q == -1) {
|
| + break;
|
| + }
|
| + switch (q) {
|
| + case 'p':
|
| + print_values = 1;
|
| + break;
|
| + case 'n':
|
| + num_octets = atoi(optarg);
|
| + if (num_octets < 0 || num_octets > BUF_LEN) {
|
| + exit(255);
|
| + }
|
| + break;
|
| + case 'v':
|
| + num_octets = 30;
|
| + print_values = 0;
|
| + break;
|
| + default:
|
| + exit(255);
|
| + }
|
| + }
|
|
|
| -/*
|
| - * crypto_kernel_cipher_test() is a test of the cipher interface
|
| - * of the crypto_kernel
|
| - */
|
| + if (num_octets > 0) {
|
| + while (iterations < 300000) {
|
| + uint8_t buffer[BUF_LEN];
|
|
|
| -err_status_t
|
| -crypto_kernel_cipher_test(void) {
|
| + status = crypto_get_random(buffer, num_octets);
|
| + if (status) {
|
| + printf("iteration %d error: failure in random source\n", iterations);
|
| + exit(255);
|
| + } else if (print_values) {
|
| + printf("%s\n", octet_string_hex_string(buffer, num_octets));
|
| + }
|
| + iterations++;
|
| + }
|
| + }
|
|
|
| - /* not implemented yet! */
|
| + status = crypto_kernel_shutdown();
|
| + if (status) {
|
| + printf("error: crypto_kernel shutdown failed\n");
|
| + exit(1);
|
| + }
|
|
|
| - return err_status_ok;
|
| + return 0;
|
| }
|
| +
|
|
|