Merge branch 'wolfCLU_project' of https://github.com/connerwolfssl/wolfssl-examples into wolfCLU_project
commit
0fd1aff4b3
|
@ -6,7 +6,8 @@ This is the wolfSSL: Command Line Utility (wolfCLU).
|
|||
|
||||
To use this feature, please configure and install wolfssl with the following commands:
|
||||
|
||||
./configure --enable-pwdbased --enable-opensslextra --enable-keygen && make && make check
|
||||
./configure --enable-pwdbased --enable-opensslextra --enable-keygen --enable-ed25519
|
||||
&& make && make check
|
||||
|
||||
If that succeeds, run:
|
||||
|
||||
|
@ -36,7 +37,6 @@ encryption or decryption are:
|
|||
Additional features that can be included when configuring wolfssl for
|
||||
key generation are:
|
||||
|
||||
--enable-ed25519
|
||||
|
||||
|
||||
##wolfCLU Install
|
||||
|
|
|
@ -49,7 +49,7 @@ enum {
|
|||
VERBOSE,
|
||||
INKEY,
|
||||
PUBIN,
|
||||
SIGNATURE,
|
||||
SIGFILE,
|
||||
INFORM,
|
||||
OUTFORM,
|
||||
NOOUT,
|
||||
|
@ -91,7 +91,7 @@ static struct option long_options[] = {
|
|||
{"pubin", no_argument, 0, PUBIN },
|
||||
{"inform", required_argument, 0, INFORM },
|
||||
{"outform", required_argument, 0, OUTFORM },
|
||||
{"signature", required_argument, 0, SIGNATURE },
|
||||
{"sigfile", required_argument, 0, SIGFILE },
|
||||
{"noout", no_argument, 0, NOOUT },
|
||||
{"text", no_argument, 0, TEXT_OUT },
|
||||
{"silent", no_argument, 0, SILENT },
|
||||
|
|
|
@ -95,7 +95,7 @@ int main(int argc, char** argv)
|
|||
case INFILE: /* File passed in by user */
|
||||
case OUTFILE: /* Output file */
|
||||
case INKEY:
|
||||
case SIGNATURE:
|
||||
case SIGFILE:
|
||||
|
||||
/* do nothing. */
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#ifdef HAVE_ED25519
|
||||
int wolfCLU_genKey_ED25519(WC_RNG* rng, char* fOutNm, int directive, int format)
|
||||
{
|
||||
int ret = -1; /* return value */
|
||||
int ret; /* return value */
|
||||
int fOutNmSz = XSTRLEN(fOutNm); /* file name without append */
|
||||
int fOutNmAppendSz = 6; /* # of bytes to append to file name */
|
||||
int flag_outputPub = 0; /* set if outputting both priv/pub */
|
||||
|
|
|
@ -173,7 +173,7 @@ int wolfCLU_genKeySetup(int argc, char** argv)
|
|||
return NOT_COMPILED_IN;
|
||||
#endif /* HAVE_ECC */
|
||||
} else if (XSTRNCMP(keyType, "rsa", 3) == 0) {
|
||||
#if defined(NO_RSA) && defined(WOLFSSL_KEY_GEN)
|
||||
#if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN)
|
||||
/* RSA flags */
|
||||
int directiveArg;
|
||||
int sizeArg;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "clu_include/clu_header_main.h"
|
||||
|
||||
int wolfCLU_sign_data(char* in, char* out, char* privKey, int keyType) {
|
||||
int ret = -1;
|
||||
int ret;
|
||||
int fSz;
|
||||
FILE* f = fopen(in,"rb");
|
||||
|
||||
|
@ -52,6 +52,9 @@ int wolfCLU_sign_data(char* in, char* out, char* privKey, int keyType) {
|
|||
ret = wolfCLU_sign_data_ed25519(data, out, fSz, privKey);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("No valid sign algorithm selected.\n");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -123,7 +123,7 @@ int wolfCLU_sign_verify_setup(int argc, char** argv)
|
|||
inCheck = 1;
|
||||
}
|
||||
|
||||
ret = wolfCLU_checkForArg("-signature", 10, argc, argv);
|
||||
ret = wolfCLU_checkForArg("-sigfile", 8, argc, argv);
|
||||
if (ret > 0) {
|
||||
sig = XMALLOC(strlen(argv[ret+1]), HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (sig == NULL) {
|
||||
|
@ -138,7 +138,7 @@ int wolfCLU_sign_verify_setup(int argc, char** argv)
|
|||
sigCheck = 1;
|
||||
}
|
||||
else if (verifyCheck == 1) {
|
||||
printf("Please specify -signature <sig> when verifying.\n");
|
||||
printf("Please specify -sigfile <sig> when verifying.\n");
|
||||
wolfCLU_verifyHelp(algCheck);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ int wolfCLU_verify_signature(char* sig, char* hash,
|
|||
|
||||
int hSz;
|
||||
int fSz;
|
||||
int ret = -1;
|
||||
int ret;
|
||||
|
||||
FILE* h;
|
||||
FILE* f = fopen(sig,"rb");
|
||||
|
@ -158,7 +158,6 @@ int wolfCLU_verify_signature(char* sig, char* hash,
|
|||
break;
|
||||
|
||||
case ECC_SIG_VER:
|
||||
hSz;
|
||||
h = fopen(hash,"rb");
|
||||
|
||||
fseek(h, 0, SEEK_END);
|
||||
|
@ -173,8 +172,6 @@ int wolfCLU_verify_signature(char* sig, char* hash,
|
|||
break;
|
||||
|
||||
case ED25519_SIG_VER:
|
||||
#ifdef HAVE_ED25519
|
||||
hSz;
|
||||
h = fopen(hash,"rb");
|
||||
|
||||
fseek(h, 0, SEEK_END);
|
||||
|
@ -185,9 +182,12 @@ int wolfCLU_verify_signature(char* sig, char* hash,
|
|||
fseek(h, 0, SEEK_SET);
|
||||
fread(h_mssg, 1, hSz, h);
|
||||
fclose(h);
|
||||
ret = wolfCLU_verify_signature_ed25519(data, ED25519_SIG_SIZE, h_mssg, hSz, keyPath, pubIn);
|
||||
#endif
|
||||
ret = wolfCLU_verify_signature_ed25519(data, fSz, h_mssg, hSz, keyPath, pubIn);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("No valid verify algorithm selected.\n");
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -374,10 +374,10 @@ void wolfCLU_genKeyHelp() {
|
|||
}
|
||||
printf("\n\n");
|
||||
printf("***************************************************************\n");
|
||||
printf("\ngenkey USAGE:\nwolfssl -genkey <keytype> -out <filename> -outform"
|
||||
" <PEM or DER> -output <PUB/PRIV/KEYPAIR> \n\n");
|
||||
printf("\ngenkey USAGE:\nwolfssl -genkey <keytype> -size(optional) <bits> "
|
||||
"-out <filename> -outform <PEM or DER> -output <PUB/PRIV/KEYPAIR> \n\n");
|
||||
printf("***************************************************************\n");
|
||||
printf("\nEXAMPLE: \n\nwolfssl -genkey ed25519 -out mykey -outform der "
|
||||
printf("\nEXAMPLE: \n\nwolfssl -genkey rsa -size 2048 -out mykey -outform der "
|
||||
" -output KEYPAIR"
|
||||
"\n\nThe above command would output the files: mykey.priv "
|
||||
" and mykey.pub\nChanging the -output option to just PRIV would only"
|
||||
|
@ -457,11 +457,11 @@ void wolfCLU_verifyHelp(int keyType) {
|
|||
case RSA_SIG_VER:
|
||||
printf("RSA Verify with Private Key:\n"
|
||||
"wolfssl -rsa -verify -inkey <priv_key>"
|
||||
" -signature <filename> -out <filename>\n\n");
|
||||
" -sigfile <filename> -out <filename>\n\n");
|
||||
printf("***************************************************************\n");
|
||||
printf("RSA Verify with Public Key\n"
|
||||
"wolfssl -rsa -verify -inkey <pub_key>"
|
||||
" -signature <filename> -out <filename> -pubin\n\n");
|
||||
" -sigfile <filename> -out <filename> -pubin\n\n");
|
||||
printf("***************************************************************\n");
|
||||
break;
|
||||
#endif
|
||||
|
@ -469,12 +469,12 @@ void wolfCLU_verifyHelp(int keyType) {
|
|||
case ED25519_SIG_VER:
|
||||
printf("ED25519 Verifiy with Private Key\n"
|
||||
"wolfssl -ed25519 -verify -inkey "
|
||||
"<priv_key> -signature <filename> -in <original>"
|
||||
"<priv_key> -sigfile <filename> -in <original>"
|
||||
"\n\n");
|
||||
printf("***************************************************************\n");
|
||||
printf("ED25519 Verifiy with Public Key\n"
|
||||
"wolfssl -ed25519 -verify -inkey "
|
||||
"<pub_key> -signature <filename> -in <original> -pubin"
|
||||
"<pub_key> -sigfile <filename> -in <original> -pubin"
|
||||
"\n\n");
|
||||
printf("***************************************************************\n");
|
||||
break;
|
||||
|
@ -483,7 +483,7 @@ void wolfCLU_verifyHelp(int keyType) {
|
|||
case ECC_SIG_VER:
|
||||
printf("ECC Verify with Public Key\n"
|
||||
"wolfssl -ecc -verify -inkey <pub_key>"
|
||||
" -signature <signature> -in <original>\n\n");
|
||||
" -sigfile <signature> -in <original>\n\n");
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -555,7 +555,7 @@ int wolfCLU_getAlgo(char* name, char** alg, char** mode, int* size)
|
|||
*size = atoi(sz);
|
||||
|
||||
/* checks key sizes for acceptability */
|
||||
if (strcmp(*alg, "aes") == 0) {
|
||||
if (XSTRNCMP(*alg, "aes", 3) == 0) {
|
||||
#ifdef NO_AES
|
||||
printf("AES not compiled in.\n");
|
||||
return NOT_COMPILED_IN;
|
||||
|
@ -568,7 +568,7 @@ int wolfCLU_getAlgo(char* name, char** alg, char** mode, int* size)
|
|||
#endif
|
||||
}
|
||||
|
||||
else if (strcmp(*alg, "3des") == 0) {
|
||||
else if (XSTRNCMP(*alg, "3des", 4) == 0) {
|
||||
#ifdef NO_DES3
|
||||
printf("3DES not compiled in.\n");
|
||||
return NOT_COMPILED_IN;
|
||||
|
@ -581,7 +581,7 @@ int wolfCLU_getAlgo(char* name, char** alg, char** mode, int* size)
|
|||
#endif
|
||||
}
|
||||
|
||||
else if (strcmp(*alg, "camellia") == 0) {
|
||||
else if (XSTRNCMP(*alg, "camellia", 8) == 0) {
|
||||
#ifndef HAVE_CAMELIA
|
||||
printf("CAMELIA not compiled in.\n");
|
||||
return NOT_COMPILED_IN;
|
||||
|
|
|
@ -65,6 +65,7 @@ int wolfCLU_inderOutder(char* infile, char* outfile, int silent_flag)
|
|||
int wolfCLU_inpemOuttext(char* infile, char* outfile, int silent_flag) {
|
||||
int ret;
|
||||
ret = wolfCLU_parseFile(infile, PEM, outfile, TEXT, silent_flag);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wolfCLU_parseFile(char* infile, int inform, char* outfile, int outform,
|
||||
|
|
Loading…
Reference in New Issue