#include <sys/types.h>
#include <sys/stat.h>
-#include "../keccak-ref/Sources/KeccakSponge.c"
-#include "../keccak-ref/Sources/KeccakF-1600-reference.c"
-#include "../keccak-ref/Sources/displayIntermediateValues.c"
+#include "KeccakSponge.c"
+#include "KeccakF-1600-reference.c"
+#include "displayIntermediateValues.c"
#define HI_NIBBLE(b) (((b) >> 4) & 0x0F)
#define LO_NIBBLE(b) ((b) & 0x0F)
r = 576;
c = 1024;
- state = (spongeState*) calloc(1, sizeof(spongeState));
+ state = calloc(1, sizeof(spongeState));
if(stat(argv[1], &input_stat) || input_stat.st_size <= 0) {
exit(1);
}
- input_buf = (unsigned char *) calloc(1, (size_t) input_stat.st_size);
- output_buf = (unsigned char *) calloc(1, (size_t) 64);
+ input_buf = calloc(input_stat.st_size, sizeof(unsigned char));
+ output_buf = calloc(64, sizeof(unsigned char));
if( ! (input_bytes_read = fread(input_buf, 1, (size_t)input_stat.st_size, input))) {
fclose(input);
- if(Absorb(state, input_buf, (unsigned long long) (8 * input_stat.st_size))) {
+ if(Absorb(state, input_buf, 8 * (unsigned long long) input_stat.st_size)) {
printf("encryption failure\n");
exit(1);
- } else if(Squeeze(state, output_buf, (unsigned long long) (8 * input_stat.st_size))) {
+ } else if(Squeeze(state, output_buf, 512)) {
printf("decryption failure\n");
exit(1);
printf("%x%x", HI_NIBBLE(output_buf[i]), LO_NIBBLE(output_buf[i]));
free(state);
+ free(input_buf);
+ free(output_buf);
return 0;
}