Feedback from review.
parent
bb06f661fe
commit
04bd7c51d9
|
@ -32,7 +32,7 @@
|
|||
#define SALT_SIZE 8
|
||||
|
||||
/*
|
||||
* Makes a cyptographically secure key by stretching a user entered key
|
||||
* Makes a cryptographically secure key by stretching a user entered key
|
||||
*/
|
||||
int GenerateKey(RNG* rng, byte* key, int size, byte* salt, int pad)
|
||||
{
|
||||
|
@ -91,14 +91,14 @@ int Des3Encrypt(Des3* des3, byte* key, int size, FILE* inFile, FILE* outFile)
|
|||
return -1030;
|
||||
}
|
||||
|
||||
/* reads from inFile and wrties whatever is there to the input array */
|
||||
/* reads from inFile and writes whatever is there to the input array */
|
||||
ret = fread(input, 1, inputLength, inFile);
|
||||
if (ret == 0) {
|
||||
printf("Input file does not exist.\n");
|
||||
return -1010;
|
||||
}
|
||||
for (i = inputLength; i < length; i++) {
|
||||
/* padds the added characters with the number of pads */
|
||||
/* pads the added characters with the number of pads */
|
||||
input[i] = padCounter;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ int Des3Encrypt(Des3* des3, byte* key, int size, FILE* inFile, FILE* outFile)
|
|||
if (ret != 0)
|
||||
return -1001;
|
||||
|
||||
/* encrypts the message to the ouput based on input length + padding */
|
||||
/* encrypts the message to the output based on input length + padding */
|
||||
ret = wc_Des3_CbcEncrypt(des3, output, input, length);
|
||||
if (ret != 0)
|
||||
return -1005;
|
||||
|
@ -166,7 +166,7 @@ int Des3Decrypt(Des3* des3, byte* key, int size, FILE* inFile, FILE* outFile)
|
|||
|
||||
wc_InitRng(&rng);
|
||||
|
||||
/* reads from inFile and wrties whatever is there to the input array */
|
||||
/* reads from inFile and writes whatever is there to the input array */
|
||||
ret = fread(input, 1, length, inFile);
|
||||
if (ret == 0) {
|
||||
printf("Input file does not exist.\n");
|
||||
|
@ -237,7 +237,7 @@ void help()
|
|||
}
|
||||
|
||||
/*
|
||||
* temporarily deisables echoing in terminal for secure key input
|
||||
* temporarily disables echoing in terminal for secure key input
|
||||
*/
|
||||
int NoEcho(char* key, int size)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#define SALT_SIZE 8
|
||||
|
||||
/*
|
||||
* Makes a cyptographically secure key by stretching a user entered key
|
||||
* Makes a cryptographically secure key by stretching a user entered key
|
||||
*/
|
||||
int GenerateKey(RNG* rng, byte* key, int size, byte* salt, int pad)
|
||||
{
|
||||
|
@ -90,14 +90,14 @@ int AesEncrypt(Aes* aes, byte* key, int size, FILE* inFile, FILE* outFile)
|
|||
return -1030;
|
||||
}
|
||||
|
||||
/* reads from inFile and wrties whatever is there to the input array */
|
||||
/* reads from inFile and writes whatever is there to the input array */
|
||||
ret = fread(input, 1, inputLength, inFile);
|
||||
if (ret == 0) {
|
||||
printf("Input file does not exist.\n");
|
||||
return -1010;
|
||||
}
|
||||
for (i = inputLength; i < length; i++) {
|
||||
/* padds the added characters with the number of pads */
|
||||
/* pads the added characters with the number of pads */
|
||||
input[i] = padCounter;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ int AesEncrypt(Aes* aes, byte* key, int size, FILE* inFile, FILE* outFile)
|
|||
if (ret != 0)
|
||||
return -1001;
|
||||
|
||||
/* encrypts the message to the ouput based on input length + padding */
|
||||
/* encrypts the message to the output based on input length + padding */
|
||||
ret = wc_AesCbcEncrypt(aes, output, input, length);
|
||||
if (ret != 0)
|
||||
return -1005;
|
||||
|
@ -140,7 +140,7 @@ int AesEncrypt(Aes* aes, byte* key, int size, FILE* inFile, FILE* outFile)
|
|||
}
|
||||
|
||||
/*
|
||||
* Decryptsr a file using AES
|
||||
* Decrypts a file using AES
|
||||
*/
|
||||
int AesDecrypt(Aes* aes, byte* key, int size, FILE* inFile, FILE* outFile)
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ int AesDecrypt(Aes* aes, byte* key, int size, FILE* inFile, FILE* outFile)
|
|||
|
||||
wc_InitRng(&rng);
|
||||
|
||||
/* reads from inFile and wrties whatever is there to the input array */
|
||||
/* reads from inFile and writes whatever is there to the input array */
|
||||
ret = fread(input, 1, length, inFile);
|
||||
if (ret == 0) {
|
||||
printf("Input file does not exist.\n");
|
||||
|
@ -236,7 +236,7 @@ void help()
|
|||
}
|
||||
|
||||
/*
|
||||
* temporarily deisables echoing in terminal for secure key input
|
||||
* temporarily disables echoing in terminal for secure key input
|
||||
*/
|
||||
int NoEcho(char* key, int size)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#define SALT_SIZE 8
|
||||
|
||||
/*
|
||||
* Makes a cyptographically secure key by stretMDMching a user entered key
|
||||
* Makes a cryptographically secure key by stretMDMching a user entered key
|
||||
*/
|
||||
int GenerateKey(RNG* rng, byte* key, int size, byte* salt, int pad)
|
||||
{
|
||||
|
@ -91,14 +91,14 @@ int CamelliaEncrypt(Camellia* cam, byte* key, int size, FILE* inFile,
|
|||
return -1030;
|
||||
}
|
||||
|
||||
/* reads from inFile and wrties whatever is there to the input array */
|
||||
/* reads from inFile and writes whatever is there to the input array */
|
||||
ret = fread(input, 1, inputLength, inFile);
|
||||
if (ret == 0) {
|
||||
printf("Input file does not exist.\n");
|
||||
return -1010;
|
||||
}
|
||||
for (i = inputLength; i < length; i++) {
|
||||
/* padds the added characters with the number of pads */
|
||||
/* pads the added characters with the number of pads */
|
||||
input[i] = padCounter;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ int CamelliaEncrypt(Camellia* cam, byte* key, int size, FILE* inFile,
|
|||
if (ret != 0)
|
||||
return -1001;
|
||||
|
||||
/* encrypts the message to the ouput based on input length + padding */
|
||||
/* encrypts the message to the output based on input length + padding */
|
||||
wc_CamelliaCbcEncrypt(cam, output, input, length);
|
||||
|
||||
/* writes to outFile */
|
||||
|
@ -165,7 +165,7 @@ int CamelliaDecrypt(Camellia* cam, byte* key, int size, FILE* inFile,
|
|||
|
||||
wc_InitRng(&rng);
|
||||
|
||||
/* reads from inFile and wrties whatever is there to the input array */
|
||||
/* reads from inFile and writes whatever is there to the input array */
|
||||
ret = fread(input, 1, length, inFile);
|
||||
if (ret == 0) {
|
||||
printf("Input file does not exist.\n");
|
||||
|
@ -233,7 +233,7 @@ void help()
|
|||
}
|
||||
|
||||
/*
|
||||
* temporarily deisables echoing in terminal for secure key input
|
||||
* temporarily disables echoing in terminal for secure key input
|
||||
*/
|
||||
int NoEcho(char* key, int size)
|
||||
{
|
||||
|
|
|
@ -1,51 +1,52 @@
|
|||
This is an example to demonstrate how the custom IO callbacks can be used to
|
||||
facilitate a TLS connection using any medium. Here we chose the medium: "File System".
|
||||
This is an example to demonstrate how the custom IO callbacks can be used to</br>
|
||||
facilitate a TLS connection using any medium. Here we chose the medium: "File System".</br>
|
||||
|
||||
Other mediums might be:
|
||||
USB Serial connection
|
||||
Bluetooth
|
||||
RFID
|
||||
Wifi
|
||||
Ethernet
|
||||
|
||||
Just to name a few.
|
||||
|
||||
These examples use the wolfSSL Custom IO Callbacks to read and write to the file
|
||||
system and perform a successful handshake.
|
||||
|
||||
The configuration used for these examples was:
|
||||
./configure --enable-debug
|
||||
|
||||
Debug was enabled in case a user wishes to use the verbose flag to see what is
|
||||
happening in real time:
|
||||
|
||||
Usage examples:
|
||||
|
||||
From the file-server directory:
|
||||
./start-server
|
||||
./start-server -v
|
||||
./start-server -verbose
|
||||
|
||||
From the file-client directory:
|
||||
./start-client
|
||||
./start-client -v
|
||||
./start-client -verbose
|
||||
|
||||
(-v and -verbose accomplish the same thing)
|
||||
|
||||
|
||||
SCRIPTS: The scripts provided attempt to make testing easier.
|
||||
|
||||
file-server/check.sh
|
||||
- starts the server in a background shell and runs the client
|
||||
|
||||
USAGE:
|
||||
./check.sh
|
||||
./check.sh -v
|
||||
./check.sh -verbose
|
||||
|
||||
file-client/clean-io-files.sh
|
||||
- If something happens and there is leftover junk in the io files run this
|
||||
script to quickly cleanup before next round of testing.
|
||||
USAGE:
|
||||
./clean-io-files.sh
|
||||
Other mediums might be: </br>
|
||||
USB Serial connection </br>
|
||||
Bluetooth </br>
|
||||
RFID </br>
|
||||
Wifi </br>
|
||||
Ethernet </br>
|
||||
</br>
|
||||
Just to name a few.</br>
|
||||
</br>
|
||||
These examples use the wolfSSL Custom IO Callbacks to read and write to the file</br>
|
||||
system and perform a successful handshake.</br>
|
||||
</br>
|
||||
The configuration used for these examples was:</br>
|
||||
./configure --enable-debug</br>
|
||||
</br>
|
||||
Debug was enabled in case a user wishes to use the verbose flag to see what is</br>
|
||||
happening in real time:</br>
|
||||
</br>
|
||||
Usage examples:</br>
|
||||
</br>
|
||||
From the file-server directory:</br>
|
||||
./start-server</br>
|
||||
./start-server -v</br>
|
||||
./start-server -verbose</br>
|
||||
</br>
|
||||
From the file-client directory:</br>
|
||||
./start-client</br>
|
||||
./start-client -v</br>
|
||||
./start-client -verbose</br>
|
||||
</br>
|
||||
(-v and -verbose accomplish the same thing)</br>
|
||||
</br>
|
||||
</br>
|
||||
SCRIPTS: The scripts provided attempt to make testing easier.</br>
|
||||
</br>
|
||||
file-server/check.sh</br>
|
||||
- starts the server in a background shell and runs the client </br>
|
||||
</br>
|
||||
USAGE:</br>
|
||||
./check.sh</br>
|
||||
./check.sh -v</br>
|
||||
./check.sh -verbose</br>
|
||||
</br>
|
||||
file-client/clean-io-files.sh</br>
|
||||
- If something happens and there is leftover junk in the io files run this</br>
|
||||
script to quickly cleanup before next round of testing.</br>
|
||||
USAGE:</br>
|
||||
./clean-io-files.sh</br>
|
||||
</br>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#define MAX_LEN 1024
|
||||
|
||||
int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
||||
int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
||||
char* in, char* out, byte* iv, int block, int keyType)
|
||||
{
|
||||
#ifndef NO_AES
|
||||
|
@ -67,7 +67,7 @@ int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
|
||||
if ((outFile = fopen(out, "wb")) == NULL) {
|
||||
printf("Error creating output file.\n");
|
||||
return DECRYPT_ERROR;
|
||||
return DECRYPT_ERROR;
|
||||
}
|
||||
|
||||
/* find end of file for length */
|
||||
|
@ -75,8 +75,8 @@ int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
length = (int) ftell(inFile);
|
||||
fseek(inFile, 0, SEEK_SET);
|
||||
|
||||
/* if there is a remainder,
|
||||
* round up else no round
|
||||
/* if there is a remainder,
|
||||
* round up else no round
|
||||
*/
|
||||
if (length % MAX_LEN > 0) {
|
||||
lastLoopFlag = (length/MAX_LEN) + 1;
|
||||
|
@ -96,7 +96,7 @@ int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
wc_InitRng(&rng);
|
||||
|
||||
/* reads from inFile and writes whatever
|
||||
* is there to the input buffer
|
||||
* is there to the input buffer
|
||||
*/
|
||||
while ( length > 0 ) {
|
||||
|
||||
|
@ -112,7 +112,7 @@ int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
printf("Error reading salt.\n");
|
||||
wolfCLU_freeBins(input, output, NULL, NULL, NULL);
|
||||
return FREAD_ERROR;
|
||||
}
|
||||
}
|
||||
/* replicates old pwdKey if pwdKeys match */
|
||||
if (keyType == 1) {
|
||||
if (wc_PBKDF2(key, pwdKey, (int) strlen((const char*)pwdKey),
|
||||
|
@ -138,7 +138,7 @@ int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
printf("the key is all zero's or not set.\n");
|
||||
wolfCLU_freeBins(input, output, NULL, NULL, NULL);
|
||||
return ENCRYPT_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
}
|
||||
}
|
||||
|
||||
/* sets pwdKey decrypts the message to ouput from input length */
|
||||
/* sets pwdKey decrypts the message to output from input length */
|
||||
#ifndef NO_AES
|
||||
if (XSTRNCMP(alg, "aes", 3) == 0) {
|
||||
if (XSTRNCMP(mode, "cbc", 3) == 0) {
|
||||
|
@ -172,7 +172,7 @@ int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
wolfCLU_freeBins(input, output, NULL, NULL, NULL);
|
||||
return DECRYPT_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_AES_COUNTER
|
||||
else if (XSTRNCMP(mode, "ctr", 3) == 0) {
|
||||
/* if mode is ctr */
|
||||
|
@ -229,7 +229,7 @@ int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
XMEMSET(output, 0, tempMax);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* writes output to the outFile */
|
||||
fwrite(output, 1, tempMax, outFile);
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ int wolfCLU_encrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
}/* End feof check */
|
||||
}/* End fread check */
|
||||
|
||||
/* sets key encrypts the message to ouput from input */
|
||||
/* sets key encrypts the message to output from input */
|
||||
#ifndef NO_AES
|
||||
if (XSTRNCMP(alg, "aes", 3) == 0) {
|
||||
if (XSTRNCMP(mode, "cbc", 3) == 0) {
|
||||
|
|
Loading…
Reference in New Issue