projects
/
mobile-com.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
garbage collect and fix bad parameter in Squeeze()
[mobile-com.git]
/
DH-Keccak
/
assets
/
KremKeccak
/
krem_keccak.c
diff --git
a/DH-Keccak/assets/KremKeccak/krem_keccak.c
b/DH-Keccak/assets/KremKeccak/krem_keccak.c
index 7a64c052ee15dc6fe874556bf07884fef19972e4..08b8e529e0e5f72670fe406044f35d3064ea5342 100644
(file)
--- a/
DH-Keccak/assets/KremKeccak/krem_keccak.c
+++ b/
DH-Keccak/assets/KremKeccak/krem_keccak.c
@@
-55,8
+55,8
@@
int main(int argc, char *argv[]) {
exit(1);
}
exit(1);
}
- input_buf = calloc(
1, (size_t) input_stat.st_size
);
- output_buf = 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))) {
if( ! (input_bytes_read = fread(input_buf, 1, (size_t)input_stat.st_size, input))) {
@@
-66,12
+66,12
@@
int main(int argc, char *argv[]) {
fclose(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);
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("decryption failure\n");
exit(1);
@@
-82,6
+82,8
@@
int main(int argc, char *argv[]) {
printf("%x%x", HI_NIBBLE(output_buf[i]), LO_NIBBLE(output_buf[i]));
free(state);
printf("%x%x", HI_NIBBLE(output_buf[i]), LO_NIBBLE(output_buf[i]));
free(state);
+ free(input_buf);
+ free(output_buf);
return 0;
}
return 0;
}