commit
cde614c4aa
|
@ -19,6 +19,9 @@ recipient of the encrypted file.
|
||||||
`--enable-opensslextra` provides utility for a hex to binary conversion of
|
`--enable-opensslextra` provides utility for a hex to binary conversion of
|
||||||
hexidecimal values.
|
hexidecimal values.
|
||||||
|
|
||||||
|
`--enable-base64encode` enables Base64 encoding (not on by default)
|
||||||
|
|
||||||
|
|
||||||
Additional features that can be included when configuring wolfssl for
|
Additional features that can be included when configuring wolfssl for
|
||||||
encryption or decryption are:
|
encryption or decryption are:
|
||||||
|
|
||||||
|
@ -44,4 +47,26 @@ Now you should be able to use the wolfssl command line tool. To verify type:
|
||||||
|
|
||||||
If everything worked, you should see the wolfssl help page.
|
If everything worked, you should see the wolfssl help page.
|
||||||
|
|
||||||
Thank you and have fun!
|
## Examples
|
||||||
|
|
||||||
|
### Base64
|
||||||
|
|
||||||
|
#### Encode
|
||||||
|
|
||||||
|
```
|
||||||
|
./wolfssl -hash base64enc -in README.md > README_encoded.md
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Decode
|
||||||
|
|
||||||
|
```
|
||||||
|
./wolfssl -hash base64dec -in README_encoded.md
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contacts
|
||||||
|
|
||||||
|
Please contact support@wolfssl.com with any questions or comments
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Copyright (c) 2006-2015 wolfSSL Inc.
|
||||||
|
|
|
@ -65,6 +65,8 @@
|
||||||
#include <wolfssl/wolfcrypt/camellia.h>
|
#include <wolfssl/wolfcrypt/camellia.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <wolfssl/wolfcrypt/coding.h>
|
||||||
|
|
||||||
#ifndef UTIL_H_INCLUDED
|
#ifndef UTIL_H_INCLUDED
|
||||||
#define UTIL_H_INCLUDED
|
#define UTIL_H_INCLUDED
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,7 @@ int wolfsslHash(char* in, char* out, char* alg, int size)
|
||||||
int i = 0; /* loop variable */
|
int i = 0; /* loop variable */
|
||||||
int ret = -1; /* return variable */
|
int ret = -1; /* return variable */
|
||||||
int length; /* length of hash */
|
int length; /* length of hash */
|
||||||
|
int outputAsHexString = 1;
|
||||||
output = malloc(size);
|
|
||||||
XMEMSET(output, 0, size);
|
|
||||||
|
|
||||||
/* opens input file */
|
/* opens input file */
|
||||||
inFile = fopen(in, "rb");
|
inFile = fopen(in, "rb");
|
||||||
|
@ -76,6 +74,15 @@ int wolfsslHash(char* in, char* out, char* alg, int size)
|
||||||
ret = (int) fread(input, 1, length, inFile);
|
ret = (int) fread(input, 1, length, inFile);
|
||||||
fclose(inFile);
|
fclose(inFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if size not provided then use input length */
|
||||||
|
if (size == 0) {
|
||||||
|
size = length * 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
output = malloc(size);
|
||||||
|
XMEMSET(output, 0, size);
|
||||||
|
|
||||||
/* hashes using accepted algorithm */
|
/* hashes using accepted algorithm */
|
||||||
#ifndef NO_MD5
|
#ifndef NO_MD5
|
||||||
if (strcmp(alg, "md5") == 0) {
|
if (strcmp(alg, "md5") == 0) {
|
||||||
|
@ -109,6 +116,20 @@ int wolfsslHash(char* in, char* out, char* alg, int size)
|
||||||
ret = wc_Blake2bFinal(&hash, output, size);
|
ret = wc_Blake2bFinal(&hash, output, size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NO_CODING
|
||||||
|
#ifdef WOLFSSL_BASE64_ENCODE
|
||||||
|
else if (strcmp(alg, "base64enc") == 0) {
|
||||||
|
ret = Base64_Encode(input, length, output, (word32*)&size);
|
||||||
|
outputAsHexString = 0;
|
||||||
|
}
|
||||||
|
#endif /* WOLFSSL_BASE64_ENCODE */
|
||||||
|
else if (strcmp(alg, "base64dec") == 0) {
|
||||||
|
ret = Base64_Decode(input, length, output, (word32*)&size);
|
||||||
|
outputAsHexString = 0;
|
||||||
|
}
|
||||||
|
#endif /* !NO_CODING */
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* if no errors so far */
|
/* if no errors so far */
|
||||||
if (out != NULL) {
|
if (out != NULL) {
|
||||||
|
@ -118,7 +139,10 @@ int wolfsslHash(char* in, char* out, char* alg, int size)
|
||||||
/* if outFile exists */
|
/* if outFile exists */
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
/* writes hashed output to outFile */
|
/* writes hashed output to outFile */
|
||||||
|
if (outputAsHexString)
|
||||||
fprintf(outFile, "%02x", output[i]);
|
fprintf(outFile, "%02x", output[i]);
|
||||||
|
else
|
||||||
|
fprintf(outFile, "%c", output[i]);
|
||||||
}
|
}
|
||||||
fclose(outFile);
|
fclose(outFile);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +151,10 @@ int wolfsslHash(char* in, char* out, char* alg, int size)
|
||||||
/* if no output file */
|
/* if no output file */
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
/* write hashed output to terminal */
|
/* write hashed output to terminal */
|
||||||
|
if (outputAsHexString)
|
||||||
printf("%02x", output[i]);
|
printf("%02x", output[i]);
|
||||||
|
else
|
||||||
|
printf("%c", output[i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,12 @@ int wolfsslHashSetup(int argc, char** argv)
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_BLAKE2
|
#ifdef HAVE_BLAKE2
|
||||||
, "blake2b"
|
, "blake2b"
|
||||||
|
#endif
|
||||||
|
#ifndef NO_CODING
|
||||||
|
#ifdef WOLFSSL_BASE64_ENCODE
|
||||||
|
, "base64enc"
|
||||||
|
#endif
|
||||||
|
, "base64dec"
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -146,7 +152,7 @@ int wolfsslHashSetup(int argc, char** argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* hashing function */
|
/* hashing function */
|
||||||
wolfsslHash(in, out, alg, size);
|
ret = wolfsslHash(in, out, alg, size);
|
||||||
|
|
||||||
free(in);
|
free(in);
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ int i = 0; /* loop variable */
|
||||||
void wolfsslVerboseHelp()
|
void wolfsslVerboseHelp()
|
||||||
{
|
{
|
||||||
printf("\nwolfssl Command Line Utility version %3.1f\n\n", VERSION);
|
printf("\nwolfssl Command Line Utility version %3.1f\n\n", VERSION);
|
||||||
|
|
||||||
/* hash options */
|
/* hash options */
|
||||||
const char* algsenc[] = { /* list of acceptable algorithms */
|
const char* algsenc[] = { /* list of acceptable algorithms */
|
||||||
#ifndef NO_MD5
|
#ifndef NO_MD5
|
||||||
|
@ -87,6 +88,12 @@ void wolfsslVerboseHelp()
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_BLAKE2
|
#ifdef HAVE_BLAKE2
|
||||||
,"blake2b"
|
,"blake2b"
|
||||||
|
#endif
|
||||||
|
#ifndef NO_CODING
|
||||||
|
#ifdef WOLFSSL_BASE64_ENCODE
|
||||||
|
,"base64enc"
|
||||||
|
#endif
|
||||||
|
,"base64dec"
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -123,6 +130,7 @@ void wolfsslVerboseHelp()
|
||||||
, "blake2b"
|
, "blake2b"
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
wolfsslHelp();
|
wolfsslHelp();
|
||||||
|
|
||||||
printf("Available En/De crypt Algorithms with current configure "
|
printf("Available En/De crypt Algorithms with current configure "
|
||||||
|
@ -235,6 +243,12 @@ void wolfsslHashHelp()
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_BLAKE2
|
#ifdef HAVE_BLAKE2
|
||||||
,"blake2b"
|
,"blake2b"
|
||||||
|
#endif
|
||||||
|
#ifndef NO_CODING
|
||||||
|
#ifdef WOLFSSL_BASE64_ENCODE
|
||||||
|
,"base64enc"
|
||||||
|
#endif
|
||||||
|
,"base64dec"
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -255,6 +269,7 @@ void wolfsslHashHelp()
|
||||||
void wolfsslBenchHelp()
|
void wolfsslBenchHelp()
|
||||||
{
|
{
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
/* benchmark options */
|
/* benchmark options */
|
||||||
const char* algsother[] = { /* list of acceptable algorithms */
|
const char* algsother[] = { /* list of acceptable algorithms */
|
||||||
#ifndef NO_AES
|
#ifndef NO_AES
|
||||||
|
@ -288,6 +303,7 @@ void wolfsslBenchHelp()
|
||||||
, "blake2b"
|
, "blake2b"
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
printf("\nAvailable tests: (-a to test all)\n");
|
printf("\nAvailable tests: (-a to test all)\n");
|
||||||
printf("Available tests with current configure settings:\n");
|
printf("Available tests with current configure settings:\n");
|
||||||
for(i = 0; i < (int) sizeof(algsother)/(int) sizeof(algsother[0]); i++) {
|
for(i = 0; i < (int) sizeof(algsother)/(int) sizeof(algsother[0]); i++) {
|
||||||
|
@ -312,6 +328,7 @@ int wolfsslGetAlgo(char* name, char** alg, char** mode, int* size)
|
||||||
int nameCheck = 0; /* check for acceptable name */
|
int nameCheck = 0; /* check for acceptable name */
|
||||||
int modeCheck = 0; /* check for acceptable mode */
|
int modeCheck = 0; /* check for acceptable mode */
|
||||||
char* sz = 0; /* key size provided */
|
char* sz = 0; /* key size provided */
|
||||||
|
|
||||||
const char* acceptAlgs[] = { /* list of acceptable algorithms */
|
const char* acceptAlgs[] = { /* list of acceptable algorithms */
|
||||||
#ifndef NO_AES
|
#ifndef NO_AES
|
||||||
"aes"
|
"aes"
|
||||||
|
@ -323,6 +340,7 @@ int wolfsslGetAlgo(char* name, char** alg, char** mode, int* size)
|
||||||
, "camellia"
|
, "camellia"
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* acceptMode[] = {"cbc"
|
const char* acceptMode[] = {"cbc"
|
||||||
#ifdef WOLFSSL_AES_COUNTER
|
#ifdef WOLFSSL_AES_COUNTER
|
||||||
, "ctr"
|
, "ctr"
|
||||||
|
|
Loading…
Reference in New Issue