clu updates for long arguments

pull/12/head
kaleb-himes 2015-09-08 14:36:05 -06:00
parent 92a68db046
commit 31e5ddbfe8
5 changed files with 57 additions and 53 deletions

View File

@ -90,7 +90,8 @@ enum {
ALL, ALL,
SIZE, SIZE,
TIME, TIME,
VERIFY VERIFY,
VERBOSE
}; };
/* Structure for holding long arguments */ /* Structure for holding long arguments */
@ -109,6 +110,7 @@ static struct option long_options[] = {
{"size", required_argument, 0, SIZE }, {"size", required_argument, 0, SIZE },
{"time", required_argument, 0, TIME }, {"time", required_argument, 0, TIME },
{"verify", 0, 0, VERIFY }, {"verify", 0, 0, VERIFY },
{"verbose", 0, 0, VERBOSE },
{"v", 0, 0, 'v' }, {"v", 0, 0, 'v' },
{"version", 0, 0, 'v' }, {"version", 0, 0, 'v' },
{0, 0, 0, 0} {0, 0, 0, 0}

View File

@ -38,28 +38,28 @@ int i = 0; /* loop variable */
printf("-help Help, print out this help menu\n"); printf("-help Help, print out this help menu\n");
printf("\n"); printf("\n");
printf("Only set one of the following.\n\n"); printf("Only set one of the following.\n\n");
printf("-e Encrypt a file or some user input\n"); printf("-encrypt Encrypt a file or some user input\n");
printf("-d Decrypt an encrypted file\n"); printf("-decrypt Decrypt an encrypted file\n");
printf("-h Hash a file or input\n"); printf("-hash Hash a file or input\n");
printf("-b Benchmark one of the algorithms\n"); printf("-bench Benchmark one of the algorithms\n");
printf("\n"); printf("\n");
/*optional flags*/ /*optional flags*/
printf("Optional Flags.\n\n"); printf("Optional Flags.\n\n");
printf("-i input file to manage\n"); printf("-in input file to manage\n");
printf("-o file to output as a result of option\n"); printf("-out file to output as a result of option\n");
printf("-p user custom password\n"); printf("-pwd user custom password\n");
printf("-V user custom IV (hex input only)\n"); printf("-iv user custom IV (hex input only)\n");
printf("-K user custom key(hex input only)\n"); printf("-key user custom key(hex input only)\n");
printf("-x when using -V and -k this will print result of\n" printf("-verify when using -iv and -key this will print result of\n"
" encryption for user verification.\n" " encryption for user verification.\n"
" This flag takes no arguments.\n"); " This flag takes no arguments.\n");
printf("-t used by Benchmark, set time in seconds to run.\n"); printf("-time used by Benchmark, set time in seconds to run.\n");
printf("-v display a more verbose help menu\n"); printf("-verbose display a more verbose help menu\n");
printf("\nFor encryption: wolfssl -e -help\n"); printf("\nFor encryption: wolfssl -encrypt -help\n");
printf("For decryption: wolfssl -d -help\n"); printf("For decryption: wolfssl -decrypt -help\n");
printf("For hashing: wolfssl -h -help\n"); printf("For hashing: wolfssl -hash -help\n");
printf("For benchmarking: wolfssl -b -help\n\n"); printf("For benchmarking: wolfssl -bench -help\n\n");
} }
/* /*
@ -175,11 +175,11 @@ void wolfsslEncryptHelp()
"camellia-cbc-256\n\n"); "camellia-cbc-256\n\n");
#endif #endif
printf("***************************************************************\n"); printf("***************************************************************\n");
printf("\nENCRYPT USAGE: wolfssl -e <-algorithm> -i <filename> " printf("\nENCRYPT USAGE: wolfssl -encrypt <-algorithm> -in <filename> "
"-p <password> -o <output file name>\n\n"); "-pwd <password> -out <output file name>\n\n");
printf("***************************************************************\n"); printf("***************************************************************\n");
printf("\nEXAMPLE: \n\nwolfssl -e aes-cbc-128 -p Thi$i$myPa$$w0rd" printf("\nEXAMPLE: \n\nwolfssl -encrypt aes-cbc-128 -pwd Thi$i$myPa$$w0rd"
" -i somefile.txt -o encryptedfile.txt\n\n"); " -in somefile.txt -out encryptedfile.txt\n\n");
} }
/* /*
@ -203,11 +203,11 @@ void wolfsslDecryptHelp()
"camellia-cbc-256\n\n"); "camellia-cbc-256\n\n");
#endif #endif
printf("***************************************************************\n"); printf("***************************************************************\n");
printf("\nDECRYPT USAGE: wolfssl -d <-algorithm> -i <encrypted file name> " printf("\nDECRYPT USAGE: wolfssl -decrypt <algorithm> -in <encrypted file> "
"-p <password> -o <output file name>\n\n"); "-pwd <password> -out <output file name>\n\n");
printf("***************************************************************\n"); printf("***************************************************************\n");
printf("\nEXAMPLE: \n\nwolfssl -d aes-cbc-128 -p Thi$i$myPa$$w0rd" printf("\nEXAMPLE: \n\nwolfssl -decrypt aes-cbc-128 -pwd Thi$i$myPa$$w0rd"
" -i encryptedfile.txt -o decryptedfile.txt\n\n"); " -in encryptedfile.txt -out decryptedfile.txt\n\n");
} }
/* /*
@ -244,9 +244,9 @@ void wolfsslHashHelp()
} }
/* encryption/decryption help lists options */ /* encryption/decryption help lists options */
printf("***************************************************************\n"); printf("***************************************************************\n");
printf("\nUSAGE: wolfssl -h <-algorithm> -i <file to hash>\n"); printf("\nUSAGE: wolfssl -hash <-algorithm> -in <file to hash>\n");
printf("***************************************************************\n"); printf("***************************************************************\n");
printf("\nEXAMPLE: \n\nwolfssl -h sha -i <some file>\n\n"); printf("\nEXAMPLE: \n\nwolfssl -hash sha -in <some file>\n\n");
} }
/* /*
@ -296,11 +296,11 @@ void wolfsslBenchHelp()
printf("\n"); printf("\n");
/* encryption/decryption help lists options */ /* encryption/decryption help lists options */
printf("***************************************************************\n"); printf("***************************************************************\n");
printf("USAGE: wolfssl -b [alg] -t [time in seconds [1-10]]\n" printf("USAGE: wolfssl -bench [alg] -time [time in seconds [1-10]]\n"
" or\n wolfssl -b -t 10 -a (to test all)\n"); " or\n wolfssl -bench -time 10 -all (to test all)\n");
printf("***************************************************************\n"); printf("***************************************************************\n");
printf("\nEXAMPLE: \n\nwolfssl -b aes-cbc -t 10" printf("\nEXAMPLE: \n\nwolfssl -bench aes-cbc -time 10"
" -i encryptedfile.txt -o decryptedfile.txt\n\n"); " -in encryptedfile.txt -out decryptedfile.txt\n\n");
} }
/* /*

View File

@ -71,9 +71,11 @@ int main(int argc, char** argv)
/* Time to benchmark for 1-10 seconds optional default: 3s */ /* Time to benchmark for 1-10 seconds optional default: 3s */
case TIME: break; case TIME: break;
/* Verify results, used with -iv and -key */ /* Verify results, used with -iv and -key */
case VERIFY: break; case VERIFY: break;
/* which version of clu am I using */ /* which version of clu am I using */
case VERBOSE:
wolfsslVerboseHelp();
return 0;
/*End of ignored arguments */ /*End of ignored arguments */
case 'v': wolfsslVersion(); case 'v': wolfsslVersion();

View File

@ -11,7 +11,7 @@ function hashtest() {
fail=0 fail=0
i=0 i=0
total=0 total=0
# -r options causes the "\" to be read # -r options causes the "\" to be read
while read -r md; do while read -r md; do
#if $i < 10 #if $i < 10
@ -35,7 +35,7 @@ function hashtest() {
#converts to lowercase #converts to lowercase
# md=${md,,} # md=${md,,}
md="$(tr [A-Z] [a-z] <<< "$md")" md="$(tr [A-Z] [a-z] <<< "$md")"
cipher="$(wolfssl -h $2 -i $FILE)" cipher="$(wolfssl -hash $2 -in $FILE)"
echo "$cipher $md" echo "$cipher $md"
#compare result of hash to line in file byte-hashes.sha1 #compare result of hash to line in file byte-hashes.sha1
if test "$cipher" != "$md"; then if test "$cipher" != "$md"; then

View File

@ -1,30 +1,30 @@
###### AES CBC ###### ###### AES CBC ######
wolfssl -e aes-cbc-128 -p hello128 -i ../somejunk/somejunk_100000.txt -o enc_aes_cbc_128.txt wolfssl -encrypt aes-cbc-128 -pwd hello128 -in ../somejunk/somejunk_100000.txt -out 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 -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 -encrypt aes-cbc-192 -pwd hello192 -in ../somejunk/somejunk_100000.txt -out 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 -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 -encrypt aes-cbc-256 -pwd hello256 -in ../somejunk/somejunk_100000.txt -out 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 -decrypt aes-cbc-256 -in enc_aes_cbc_256.txt -out dec_aes_cbc_256.txt -pwd hello256
###### DES CBC ###### ###### DES CBC ######
wolfssl -e 3des-cbc-056 -p hello056 -i ../somejunk/somejunk_100000.txt -o enc_3des_cbc_056.txt wolfssl -encrypt 3des-cbc-056 -pwd hello056 -in ../somejunk/somejunk_100000.txt -out 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 -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 -encrypt 3des-cbc-112 -pwd hello112 -in ../somejunk/somejunk_100000.txt -out 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 -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 -encrypt 3des-cbc-168 -pwd hello168 -in ../somejunk/somejunk_100000.txt -out 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 -decrypt 3des-cbc-168 -in enc_3des_cbc_168.txt -out dec_3des_cbc_168.txt -pwd hello168
###### CAMELLIA CBC ###### ###### CAMELLIA CBC ######
wolfssl -e camellia-cbc-128 -p hello128 -i ../somejunk/somejunk_100000.txt -o enc_camellia_cbc_128.txt wolfssl -encrypt camellia-cbc-128 -pwd hello128 -in ../somejunk/somejunk_100000.txt -out 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 -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 -encrypt camellia-cbc-192 -pwd hello192 -in ../somejunk/somejunk_100000.txt -out 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 -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 -encrypt camellia-cbc-256 -pwd hello256 -in ../somejunk/somejunk_100000.txt -out 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 -decrypt camellia-cbc-256 -in enc_camellia_cbc_256.txt -out dec_camellia_cbc_256.txt -pwd hello256