From 31e5ddbfe8fa84d7b9656a1c8404e696d24ca54b Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Tue, 8 Sep 2015 14:36:05 -0600 Subject: [PATCH] clu updates for long arguments --- clu/include/wolfssl.h | 4 +- clu/src/tools/wolfsslFuncs.c | 60 ++++++++++---------- clu/src/wolfsslMain.c | 6 +- clu/tests/nistTest.sh | 4 +- clu/tests/testEncDec/test_aescbc_3des_cam.sh | 36 ++++++------ 5 files changed, 57 insertions(+), 53 deletions(-) diff --git a/clu/include/wolfssl.h b/clu/include/wolfssl.h index 2eea955f..8e206bc5 100644 --- a/clu/include/wolfssl.h +++ b/clu/include/wolfssl.h @@ -90,7 +90,8 @@ enum { ALL, SIZE, TIME, - VERIFY + VERIFY, + VERBOSE }; /* Structure for holding long arguments */ @@ -109,6 +110,7 @@ static struct option long_options[] = { {"size", required_argument, 0, SIZE }, {"time", required_argument, 0, TIME }, {"verify", 0, 0, VERIFY }, + {"verbose", 0, 0, VERBOSE }, {"v", 0, 0, 'v' }, {"version", 0, 0, 'v' }, {0, 0, 0, 0} diff --git a/clu/src/tools/wolfsslFuncs.c b/clu/src/tools/wolfsslFuncs.c index 6156b440..8850a8b9 100644 --- a/clu/src/tools/wolfsslFuncs.c +++ b/clu/src/tools/wolfsslFuncs.c @@ -38,28 +38,28 @@ int i = 0; /* loop variable */ printf("-help Help, print out this help menu\n"); printf("\n"); printf("Only set one of the following.\n\n"); - printf("-e Encrypt a file or some user input\n"); - printf("-d Decrypt an encrypted file\n"); - printf("-h Hash a file or input\n"); - printf("-b Benchmark one of the algorithms\n"); + printf("-encrypt Encrypt a file or some user input\n"); + printf("-decrypt Decrypt an encrypted file\n"); + printf("-hash Hash a file or input\n"); + printf("-bench Benchmark one of the algorithms\n"); printf("\n"); /*optional flags*/ printf("Optional Flags.\n\n"); - printf("-i input file to manage\n"); - printf("-o file to output as a result of option\n"); - printf("-p user custom password\n"); - printf("-V user custom IV (hex input only)\n"); - printf("-K user custom key(hex input only)\n"); - printf("-x when using -V and -k this will print result of\n" + printf("-in input file to manage\n"); + printf("-out file to output as a result of option\n"); + printf("-pwd user custom password\n"); + printf("-iv user custom IV (hex input only)\n"); + printf("-key user custom key(hex input only)\n"); + printf("-verify when using -iv and -key this will print result of\n" " encryption for user verification.\n" " This flag takes no arguments.\n"); - printf("-t used by Benchmark, set time in seconds to run.\n"); - printf("-v display a more verbose help menu\n"); + printf("-time used by Benchmark, set time in seconds to run.\n"); + printf("-verbose display a more verbose help menu\n"); - printf("\nFor encryption: wolfssl -e -help\n"); - printf("For decryption: wolfssl -d -help\n"); - printf("For hashing: wolfssl -h -help\n"); - printf("For benchmarking: wolfssl -b -help\n\n"); + printf("\nFor encryption: wolfssl -encrypt -help\n"); + printf("For decryption: wolfssl -decrypt -help\n"); + printf("For hashing: wolfssl -hash -help\n"); + printf("For benchmarking: wolfssl -bench -help\n\n"); } /* @@ -175,11 +175,11 @@ void wolfsslEncryptHelp() "camellia-cbc-256\n\n"); #endif printf("***************************************************************\n"); - printf("\nENCRYPT USAGE: wolfssl -e <-algorithm> -i " - "-p -o \n\n"); + printf("\nENCRYPT USAGE: wolfssl -encrypt <-algorithm> -in " + "-pwd -out \n\n"); printf("***************************************************************\n"); - printf("\nEXAMPLE: \n\nwolfssl -e aes-cbc-128 -p Thi$i$myPa$$w0rd" - " -i somefile.txt -o encryptedfile.txt\n\n"); + printf("\nEXAMPLE: \n\nwolfssl -encrypt aes-cbc-128 -pwd Thi$i$myPa$$w0rd" + " -in somefile.txt -out encryptedfile.txt\n\n"); } /* @@ -203,11 +203,11 @@ void wolfsslDecryptHelp() "camellia-cbc-256\n\n"); #endif printf("***************************************************************\n"); - printf("\nDECRYPT USAGE: wolfssl -d <-algorithm> -i " - "-p -o \n\n"); + printf("\nDECRYPT USAGE: wolfssl -decrypt -in " + "-pwd -out \n\n"); printf("***************************************************************\n"); - printf("\nEXAMPLE: \n\nwolfssl -d aes-cbc-128 -p Thi$i$myPa$$w0rd" - " -i encryptedfile.txt -o decryptedfile.txt\n\n"); + printf("\nEXAMPLE: \n\nwolfssl -decrypt aes-cbc-128 -pwd Thi$i$myPa$$w0rd" + " -in encryptedfile.txt -out decryptedfile.txt\n\n"); } /* @@ -244,9 +244,9 @@ void wolfsslHashHelp() } /* encryption/decryption help lists options */ printf("***************************************************************\n"); - printf("\nUSAGE: wolfssl -h <-algorithm> -i \n"); + printf("\nUSAGE: wolfssl -hash <-algorithm> -in \n"); printf("***************************************************************\n"); - printf("\nEXAMPLE: \n\nwolfssl -h sha -i \n\n"); + printf("\nEXAMPLE: \n\nwolfssl -hash sha -in \n\n"); } /* @@ -296,11 +296,11 @@ void wolfsslBenchHelp() printf("\n"); /* encryption/decryption help lists options */ printf("***************************************************************\n"); - printf("USAGE: wolfssl -b [alg] -t [time in seconds [1-10]]\n" - " or\n wolfssl -b -t 10 -a (to test all)\n"); + printf("USAGE: wolfssl -bench [alg] -time [time in seconds [1-10]]\n" + " or\n wolfssl -bench -time 10 -all (to test all)\n"); printf("***************************************************************\n"); - printf("\nEXAMPLE: \n\nwolfssl -b aes-cbc -t 10" - " -i encryptedfile.txt -o decryptedfile.txt\n\n"); + printf("\nEXAMPLE: \n\nwolfssl -bench aes-cbc -time 10" + " -in encryptedfile.txt -out decryptedfile.txt\n\n"); } /* diff --git a/clu/src/wolfsslMain.c b/clu/src/wolfsslMain.c index bd6be29c..7e15a1ec 100644 --- a/clu/src/wolfsslMain.c +++ b/clu/src/wolfsslMain.c @@ -71,9 +71,11 @@ int main(int argc, char** argv) /* Time to benchmark for 1-10 seconds optional default: 3s */ case TIME: break; /* Verify results, used with -iv and -key */ - case VERIFY: break; + case VERIFY: break; /* which version of clu am I using */ - + case VERBOSE: + wolfsslVerboseHelp(); + return 0; /*End of ignored arguments */ case 'v': wolfsslVersion(); diff --git a/clu/tests/nistTest.sh b/clu/tests/nistTest.sh index baf70d4f..c3d9f325 100755 --- a/clu/tests/nistTest.sh +++ b/clu/tests/nistTest.sh @@ -11,7 +11,7 @@ function hashtest() { fail=0 i=0 total=0 - + # -r options causes the "\" to be read while read -r md; do #if $i < 10 @@ -35,7 +35,7 @@ function hashtest() { #converts to lowercase # md=${md,,} md="$(tr [A-Z] [a-z] <<< "$md")" - cipher="$(wolfssl -h $2 -i $FILE)" + cipher="$(wolfssl -hash $2 -in $FILE)" echo "$cipher $md" #compare result of hash to line in file byte-hashes.sha1 if test "$cipher" != "$md"; then diff --git a/clu/tests/testEncDec/test_aescbc_3des_cam.sh b/clu/tests/testEncDec/test_aescbc_3des_cam.sh index 1035d087..3be352b3 100755 --- a/clu/tests/testEncDec/test_aescbc_3des_cam.sh +++ b/clu/tests/testEncDec/test_aescbc_3des_cam.sh @@ -1,30 +1,30 @@ ###### AES CBC ###### -wolfssl -e aes-cbc-128 -p hello128 -i ../somejunk/somejunk_100000.txt -o enc_aes_cbc_128.txt -wolfssl -d aes-cbc-128 -i enc_aes_cbc_128.txt -o dec_aes_cbc_128.txt -p hello128 +wolfssl -encrypt aes-cbc-128 -pwd hello128 -in ../somejunk/somejunk_100000.txt -out enc_aes_cbc_128.txt +wolfssl -decrypt aes-cbc-128 -in enc_aes_cbc_128.txt -out dec_aes_cbc_128.txt -pwd hello128 -wolfssl -e aes-cbc-192 -p hello192 -i ../somejunk/somejunk_100000.txt -o enc_aes_cbc_192.txt -wolfssl -d aes-cbc-192 -i enc_aes_cbc_192.txt -o dec_aes_cbc_192.txt -p hello192 +wolfssl -encrypt aes-cbc-192 -pwd hello192 -in ../somejunk/somejunk_100000.txt -out enc_aes_cbc_192.txt +wolfssl -decrypt aes-cbc-192 -in enc_aes_cbc_192.txt -out dec_aes_cbc_192.txt -pwd hello192 -wolfssl -e aes-cbc-256 -p hello256 -i ../somejunk/somejunk_100000.txt -o enc_aes_cbc_256.txt -wolfssl -d aes-cbc-256 -i enc_aes_cbc_256.txt -o dec_aes_cbc_256.txt -p hello256 +wolfssl -encrypt aes-cbc-256 -pwd hello256 -in ../somejunk/somejunk_100000.txt -out enc_aes_cbc_256.txt +wolfssl -decrypt aes-cbc-256 -in enc_aes_cbc_256.txt -out dec_aes_cbc_256.txt -pwd hello256 ###### DES CBC ###### -wolfssl -e 3des-cbc-056 -p hello056 -i ../somejunk/somejunk_100000.txt -o enc_3des_cbc_056.txt -wolfssl -d 3des-cbc-056 -i enc_3des_cbc_056.txt -o dec_3des_cbc_056.txt -p hello056 +wolfssl -encrypt 3des-cbc-056 -pwd hello056 -in ../somejunk/somejunk_100000.txt -out enc_3des_cbc_056.txt +wolfssl -decrypt 3des-cbc-056 -in enc_3des_cbc_056.txt -out dec_3des_cbc_056.txt -pwd hello056 -wolfssl -e 3des-cbc-112 -p hello112 -i ../somejunk/somejunk_100000.txt -o enc_3des_cbc_112.txt -wolfssl -d 3des-cbc-112 -i enc_3des_cbc_112.txt -o dec_3des_cbc_112.txt -p hello112 +wolfssl -encrypt 3des-cbc-112 -pwd hello112 -in ../somejunk/somejunk_100000.txt -out enc_3des_cbc_112.txt +wolfssl -decrypt 3des-cbc-112 -in enc_3des_cbc_112.txt -out dec_3des_cbc_112.txt -pwd hello112 -wolfssl -e 3des-cbc-168 -p hello168 -i ../somejunk/somejunk_100000.txt -o enc_3des_cbc_168.txt -wolfssl -d 3des-cbc-168 -i enc_3des_cbc_168.txt -o dec_3des_cbc_168.txt -p hello168 +wolfssl -encrypt 3des-cbc-168 -pwd hello168 -in ../somejunk/somejunk_100000.txt -out enc_3des_cbc_168.txt +wolfssl -decrypt 3des-cbc-168 -in enc_3des_cbc_168.txt -out dec_3des_cbc_168.txt -pwd hello168 ###### CAMELLIA CBC ###### -wolfssl -e camellia-cbc-128 -p hello128 -i ../somejunk/somejunk_100000.txt -o enc_camellia_cbc_128.txt -wolfssl -d camellia-cbc-128 -i enc_camellia_cbc_128.txt -o dec_camellia_cbc_128.txt -p hello128 +wolfssl -encrypt camellia-cbc-128 -pwd hello128 -in ../somejunk/somejunk_100000.txt -out enc_camellia_cbc_128.txt +wolfssl -decrypt camellia-cbc-128 -in enc_camellia_cbc_128.txt -out dec_camellia_cbc_128.txt -pwd hello128 -wolfssl -e camellia-cbc-192 -p hello192 -i ../somejunk/somejunk_100000.txt -o enc_camellia_cbc_192.txt -wolfssl -d camellia-cbc-192 -i enc_camellia_cbc_192.txt -o dec_camellia_cbc_192.txt -p hello192 +wolfssl -encrypt camellia-cbc-192 -pwd hello192 -in ../somejunk/somejunk_100000.txt -out enc_camellia_cbc_192.txt +wolfssl -decrypt camellia-cbc-192 -in enc_camellia_cbc_192.txt -out dec_camellia_cbc_192.txt -pwd hello192 -wolfssl -e camellia-cbc-256 -p hello256 -i ../somejunk/somejunk_100000.txt -o enc_camellia_cbc_256.txt -wolfssl -d camellia-cbc-256 -i enc_camellia_cbc_256.txt -o dec_camellia_cbc_256.txt -p hello256 +wolfssl -encrypt camellia-cbc-256 -pwd hello256 -in ../somejunk/somejunk_100000.txt -out enc_camellia_cbc_256.txt +wolfssl -decrypt camellia-cbc-256 -in enc_camellia_cbc_256.txt -out dec_camellia_cbc_256.txt -pwd hello256