diff --git a/clu/src/wolfsslBenchmark.c b/clu/src/wolfsslBenchmark.c index fa8f2559..d4ffdc3f 100644 --- a/clu/src/wolfsslBenchmark.c +++ b/clu/src/wolfsslBenchmark.c @@ -35,7 +35,7 @@ int wolfsslBenchmark(int timer, int* option) int i = 0; /* A looping variable */ int loop = 1; /* benchmarking loop */ - int64_t blocks = 0; /* blocks used during benchmarking */ + int64_t blocks = 0; /* blocks used during benchmarking */ #ifndef NO_AES Aes aes; /* aes declaration */ #endif @@ -46,7 +46,7 @@ int wolfsslBenchmark(int timer, int* option) RNG rng; /* random number generator */ - int ret = 0; /* return variable */ + int ret = 0; /* return variable */ double stop = 0.0; /* stop breaks loop */ double start; /* start time */ double currTime; /* current time*/ diff --git a/clu/src/wolfsslDecrypt.c b/clu/src/wolfsslDecrypt.c index 414ad7ed..f68abc9c 100644 --- a/clu/src/wolfsslDecrypt.c +++ b/clu/src/wolfsslDecrypt.c @@ -43,17 +43,18 @@ int wolfsslDecrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size, FILE* outFile; /* output file */ RNG rng; /* random number generator */ - byte* input; /* input buffer */ - byte* output; /* output buffer */ + byte* input = NULL; /* input buffer */ + byte* output = NULL; /* output buffer */ byte salt[SALT_SIZE] = {0}; /* salt variable */ int currLoopFlag = 1; /* flag to track the loop */ int lastLoopFlag = 0; /* flag for last loop */ int ret = 0; /* return variable */ + int keyVerify = 0; /* verify the key is set */ + int i = 0; /* loop variable */ + int pad = 0; /* the length to pad */ int length; /* length of message */ int tempMax = MAX; /* equal to MAX until feof */ - int keyVerify = 0; /* verify the key is set */ - int i = 0; /* loop variable */ int sbSize = SALT_SIZE + block; /* size of salt and iv together */ /* opens input file */ @@ -208,7 +209,7 @@ int wolfsslDecrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size, if (currLoopFlag == lastLoopFlag) { if (salt[0] != 0) { /* reduces length based on number of padded elements */ - int pad = output[tempMax-1]; + pad = output[tempMax-1]; /* adjust length for padded bytes and salt size */ length -= pad + sbSize; /* reset tempMax for smaller decryption */ diff --git a/clu/src/wolfsslEncrypt.c b/clu/src/wolfsslEncrypt.c index 3fcb9c99..658ae67c 100644 --- a/clu/src/wolfsslEncrypt.c +++ b/clu/src/wolfsslEncrypt.c @@ -264,10 +264,20 @@ int wolfsslEncrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size, if (ferror(outFile)) { printf("failed to write to file.\n"); + if (input != NULL) + XMEMSET(input, 0, tempMax); + if (output != NULL) + XMEMSET(output, 0, tempMax); + wolfsslFreeBins(input, output, NULL, NULL, NULL); return FWRITE_ERROR; } if (ret > MAX) { printf("Wrote too much to file.\n"); + if (input != NULL) + XMEMSET(input, 0, tempMax); + if (output != NULL) + XMEMSET(output, 0, tempMax); + wolfsslFreeBins(input, output, NULL, NULL, NULL); return FWRITE_ERROR; } /* close the outFile */