diff --git a/wolfCLU/clu_src/benchmark/clu_bench_setup.c b/wolfCLU/clu_src/benchmark/clu_bench_setup.c index 9c8f788d..dde4188f 100644 --- a/wolfCLU/clu_src/benchmark/clu_bench_setup.c +++ b/wolfCLU/clu_src/benchmark/clu_bench_setup.c @@ -63,7 +63,8 @@ int wolfCLU_benchSetup(int argc, char** argv) int optionCheck = 0; /* acceptable option check */ for (i = 2; i < argc; i++) { - if (XSTRNCMP(argv[i], "-help", 5) == 0) { + if (XSTRNCMP(argv[i], "-help", 5) == 0 || XSTRNCMP(argv[i], "-h", 2) + == 0) { /* help checking */ wolfCLU_benchHelp(); return 0; diff --git a/wolfCLU/clu_src/clu_main.c b/wolfCLU/clu_src/clu_main.c index f70bd6d0..db8cdb55 100644 --- a/wolfCLU/clu_src/clu_main.c +++ b/wolfCLU/clu_src/clu_main.c @@ -94,6 +94,20 @@ int main(int argc, char** argv) case NOOUT: break; case TEXT_OUT: break; case SILENT: break; + case HELP1: + if (argc == 2) { + printf("Main help menu:\n"); + wolfCLU_help(); + return 0; + } + break; + case HELP2: + if (argc == 2) { + printf("Main help menu:\n"); + wolfCLU_help(); + return 0; + } + break; /* which version of clu am I using */ case VERBOSE: wolfCLU_verboseHelp(); diff --git a/wolfCLU/clu_src/crypto/clu_crypto_setup.c b/wolfCLU/clu_src/crypto/clu_crypto_setup.c index 29c22bc3..0197b422 100644 --- a/wolfCLU/clu_src/crypto/clu_crypto_setup.c +++ b/wolfCLU/clu_src/crypto/clu_crypto_setup.c @@ -61,7 +61,8 @@ int wolfCLU_setup(int argc, char** argv, char action) dCheck = 1; for (i = 2; i < argc; i++) { - if (XSTRNCMP(argv[i], "-help", 5) == 0) { + if (XSTRNCMP(argv[i], "-help", 5) == 0 || XSTRNCMP(argv[i], "-h", 2) + == 0) { if (eCheck == 1) { /*wolfCLU_encryptHelp*/ wolfCLU_encryptHelp(); diff --git a/wolfCLU/clu_src/hash/clu_hash_setup.c b/wolfCLU/clu_src/hash/clu_hash_setup.c index f10ef904..a306d7f9 100644 --- a/wolfCLU/clu_src/hash/clu_hash_setup.c +++ b/wolfCLU/clu_src/hash/clu_hash_setup.c @@ -67,12 +67,9 @@ int wolfCLU_hashSetup(int argc, char** argv) #endif /* help checking */ - if (argc == 2) { - wolfCLU_hashHelp(); - return 0; - } for (i = 2; i < argc; i++) { - if (strcmp(argv[i], "-help") == 0) { + if (XSTRNCMP(argv[i], "-help", 5) == 0 || XSTRNCMP(argv[i], "-h", 2) + == 0) { wolfCLU_hashHelp(); return 0; } @@ -80,11 +77,12 @@ int wolfCLU_hashSetup(int argc, char** argv) for (i = 0; i < (int) sizeof(algs)/(int) sizeof(algs[0]); i++) { /* checks for acceptable algorithms */ - if (strcmp(argv[2], algs[i]) == 0) { + if (XSTRNCMP(argv[2], algs[i], XSTRLEN(algs[i])) == 0) { alg = argv[2]; algCheck = 1; } } + if (algCheck == 0) { printf("Invalid algorithm\n"); return FATAL_ERROR; @@ -159,7 +157,6 @@ int wolfCLU_hashSetup(int argc, char** argv) ret = wolfCLU_hash(in, out, alg, size); XFREE(in, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); - free(in); return ret; } diff --git a/wolfCLU/clu_src/tools/clu_funcs.c b/wolfCLU/clu_src/tools/clu_funcs.c index a340a8f9..8c546197 100644 --- a/wolfCLU/clu_src/tools/clu_funcs.c +++ b/wolfCLU/clu_src/tools/clu_funcs.c @@ -42,6 +42,7 @@ int i = 0; /* loop variable */ printf("-decrypt Decrypt an encrypted file\n"); printf("-hash Hash a file or input\n"); printf("-bench Benchmark one of the algorithms\n"); + printf("-x509 X509 certificate processing\n"); printf("\n"); /*optional flags*/ printf("Optional Flags.\n\n"); @@ -55,11 +56,14 @@ int i = 0; /* loop variable */ " This flag takes no arguments.\n"); printf("-time used by Benchmark, set time in seconds to run.\n"); printf("-verbose display a more verbose help menu\n"); + printf("-inform input format of the certificate file [PEM/DER]\n"); + printf("-outform format to output [PEM/DER]\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"); + printf("For benchmarking: wolfssl -bench -help\n"); + printf("For x509: wolfssl -x509 -help\n\n"); } /* @@ -319,6 +323,19 @@ void wolfCLU_benchHelp() " -in encryptedfile.txt -out decryptedfile.txt\n\n"); } +void wolfCLU_certHelp() +{ + printf("\n\n"); + printf("***************************************************************\n"); + printf("\nX509 USAGE: wolfssl -x509 -inform -in " + "-outform -out \n\n"); + printf("***************************************************************\n"); + printf("\nEXAMPLE: \n\nwolfssl -x509 -inform pem -in testing-certs/" + "ca-cert.pem -outform der -out testing-certs/ca-cert-converted.der" + "\n\n"); +} + + /* * finds algorithm for encryption/decryption */ diff --git a/wolfCLU/clu_src/x509/clu_cert_setup.c b/wolfCLU/clu_src/x509/clu_cert_setup.c index 598c4416..27be434b 100644 --- a/wolfCLU/clu_src/x509/clu_cert_setup.c +++ b/wolfCLU/clu_src/x509/clu_cert_setup.c @@ -53,7 +53,6 @@ int wolfCLU_certSetup(int argc, char** argv) char* outform; /* the output format */ - printf("In x509 loop\n"); for (i = 2; i < argc; i++) { /*---------------------------------------------------------------------------*/ /* help */ @@ -189,31 +188,26 @@ int wolfCLU_certSetup(int argc, char** argv) switch (ret) { case INPEM_OUTPEM: ret = 0; - printf("run inpem outpem\n"); if (infile_flag) wolfCLU_inpemOutpem(infile, outfile, silent_flag); else return INPUT_FILE_ERROR; break; case INPEM_OUTDER: ret = 0; - printf("run inpem outder\n"); if (infile_flag) wolfCLU_inpemOutder(infile, outfile, silent_flag); else return INPUT_FILE_ERROR; break; case INDER_OUTPEM: ret = 0; - printf("run inder outpem\n"); if (infile_flag) wolfCLU_inderOutpem(infile, outfile, silent_flag); else return INPUT_FILE_ERROR; break; case INDER_OUTDER: ret = 0; - printf("run inder outder\n"); if (infile_flag) wolfCLU_inderOutder(infile, outfile, silent_flag); else return INPUT_FILE_ERROR; break; case NOOUT_SET: ret = 0; - printf("noout set\n"); break; default: printf("Error case\n"); @@ -223,12 +217,6 @@ int wolfCLU_certSetup(int argc, char** argv) return ret; } - -void wolfCLU_certHelp() -{ - printf("\n\n\nThis would be the certificate help.\n\n\n"); -} - /* * @arg inpem_flag: is inform set to pem * @arg inder_flag: is inform set to der @@ -253,7 +241,6 @@ int error_check(int inpem_flag, int inder_flag, int outpem_flag, printf("ERROR: noout set when output format is specified"); return USER_INPUT_ERROR; } - printf("input is pem format, output is pem format\n"); return INPEM_OUTPEM; } ret = (inpem_flag & outder_flag); @@ -264,7 +251,6 @@ int error_check(int inpem_flag, int inder_flag, int outpem_flag, printf("ERROR: noout set when output format is specified"); return USER_INPUT_ERROR; } - printf("input is pem format, output is der format\n"); return INPEM_OUTDER; } ret = (inder_flag & outpem_flag); @@ -275,7 +261,6 @@ int error_check(int inpem_flag, int inder_flag, int outpem_flag, printf("ERROR: noout set when output format is specified"); return USER_INPUT_ERROR; } - printf("input is der format, output is pem format\n"); return INDER_OUTPEM; } ret = (inder_flag & outder_flag);