Feedback from review.

pull/139/head
David Garske 2019-03-27 10:35:21 -07:00
parent bb06f661fe
commit 04bd7c51d9
6 changed files with 81 additions and 80 deletions

View File

@ -32,7 +32,7 @@
#define SALT_SIZE 8 #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) 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; 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); ret = fread(input, 1, inputLength, inFile);
if (ret == 0) { if (ret == 0) {
printf("Input file does not exist.\n"); printf("Input file does not exist.\n");
return -1010; return -1010;
} }
for (i = inputLength; i < length; i++) { 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; input[i] = padCounter;
} }
@ -116,7 +116,7 @@ int Des3Encrypt(Des3* des3, byte* key, int size, FILE* inFile, FILE* outFile)
if (ret != 0) if (ret != 0)
return -1001; 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); ret = wc_Des3_CbcEncrypt(des3, output, input, length);
if (ret != 0) if (ret != 0)
return -1005; return -1005;
@ -166,7 +166,7 @@ int Des3Decrypt(Des3* des3, byte* key, int size, FILE* inFile, FILE* outFile)
wc_InitRng(&rng); 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); ret = fread(input, 1, length, inFile);
if (ret == 0) { if (ret == 0) {
printf("Input file does not exist.\n"); 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) int NoEcho(char* key, int size)
{ {

View File

@ -31,7 +31,7 @@
#define SALT_SIZE 8 #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) 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; 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); ret = fread(input, 1, inputLength, inFile);
if (ret == 0) { if (ret == 0) {
printf("Input file does not exist.\n"); printf("Input file does not exist.\n");
return -1010; return -1010;
} }
for (i = inputLength; i < length; i++) { 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; input[i] = padCounter;
} }
@ -115,7 +115,7 @@ int AesEncrypt(Aes* aes, byte* key, int size, FILE* inFile, FILE* outFile)
if (ret != 0) if (ret != 0)
return -1001; 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); ret = wc_AesCbcEncrypt(aes, output, input, length);
if (ret != 0) if (ret != 0)
return -1005; 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) 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); 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); ret = fread(input, 1, length, inFile);
if (ret == 0) { if (ret == 0) {
printf("Input file does not exist.\n"); 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) int NoEcho(char* key, int size)
{ {

View File

@ -31,7 +31,7 @@
#define SALT_SIZE 8 #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) 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; 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); ret = fread(input, 1, inputLength, inFile);
if (ret == 0) { if (ret == 0) {
printf("Input file does not exist.\n"); printf("Input file does not exist.\n");
return -1010; return -1010;
} }
for (i = inputLength; i < length; i++) { 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; input[i] = padCounter;
} }
@ -116,7 +116,7 @@ int CamelliaEncrypt(Camellia* cam, byte* key, int size, FILE* inFile,
if (ret != 0) if (ret != 0)
return -1001; 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); wc_CamelliaCbcEncrypt(cam, output, input, length);
/* writes to outFile */ /* writes to outFile */
@ -165,7 +165,7 @@ int CamelliaDecrypt(Camellia* cam, byte* key, int size, FILE* inFile,
wc_InitRng(&rng); 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); ret = fread(input, 1, length, inFile);
if (ret == 0) { if (ret == 0) {
printf("Input file does not exist.\n"); 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) int NoEcho(char* key, int size)
{ {

View File

@ -1,51 +1,52 @@
This is an example to demonstrate how the custom IO callbacks can be used to 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". facilitate a TLS connection using any medium. Here we chose the medium: "File System".</br>
Other mediums might be: Other mediums might be: </br>
USB Serial connection USB Serial connection </br>
Bluetooth Bluetooth </br>
RFID RFID </br>
Wifi Wifi </br>
Ethernet Ethernet </br>
</br>
Just to name a few. Just to name a few.</br>
</br>
These examples use the wolfSSL Custom IO Callbacks to read and write to the file These examples use the wolfSSL Custom IO Callbacks to read and write to the file</br>
system and perform a successful handshake. system and perform a successful handshake.</br>
</br>
The configuration used for these examples was: The configuration used for these examples was:</br>
./configure --enable-debug ./configure --enable-debug</br>
</br>
Debug was enabled in case a user wishes to use the verbose flag to see what is Debug was enabled in case a user wishes to use the verbose flag to see what is</br>
happening in real time: happening in real time:</br>
</br>
Usage examples: Usage examples:</br>
</br>
From the file-server directory: From the file-server directory:</br>
./start-server ./start-server</br>
./start-server -v ./start-server -v</br>
./start-server -verbose ./start-server -verbose</br>
</br>
From the file-client directory: From the file-client directory:</br>
./start-client ./start-client</br>
./start-client -v ./start-client -v</br>
./start-client -verbose ./start-client -verbose</br>
</br>
(-v and -verbose accomplish the same thing) (-v and -verbose accomplish the same thing)</br>
</br>
</br>
SCRIPTS: The scripts provided attempt to make testing easier. SCRIPTS: The scripts provided attempt to make testing easier.</br>
</br>
file-server/check.sh file-server/check.sh</br>
- starts the server in a background shell and runs the client - starts the server in a background shell and runs the client </br>
</br>
USAGE: USAGE:</br>
./check.sh ./check.sh</br>
./check.sh -v ./check.sh -v</br>
./check.sh -verbose ./check.sh -verbose</br>
</br>
file-client/clean-io-files.sh file-client/clean-io-files.sh</br>
- If something happens and there is leftover junk in the io files run this - If something happens and there is leftover junk in the io files run this</br>
script to quickly cleanup before next round of testing. script to quickly cleanup before next round of testing.</br>
USAGE: USAGE:</br>
./clean-io-files.sh ./clean-io-files.sh</br>
</br>

View File

@ -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 #ifndef NO_AES
if (XSTRNCMP(alg, "aes", 3) == 0) { if (XSTRNCMP(alg, "aes", 3) == 0) {
if (XSTRNCMP(mode, "cbc", 3) == 0) { if (XSTRNCMP(mode, "cbc", 3) == 0) {

View File

@ -190,7 +190,7 @@ int wolfCLU_encrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
}/* End feof check */ }/* End feof check */
}/* End fread 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 #ifndef NO_AES
if (XSTRNCMP(alg, "aes", 3) == 0) { if (XSTRNCMP(alg, "aes", 3) == 0) {
if (XSTRNCMP(mode, "cbc", 3) == 0) { if (XSTRNCMP(mode, "cbc", 3) == 0) {