diff --git a/Implementierung/Makefile b/Implementierung/Makefile index 5362c73..1c7ed9f 100644 --- a/Implementierung/Makefile +++ b/Implementierung/Makefile @@ -3,7 +3,7 @@ SRC = src/main.c src/helper.c src/io.c src/md2.c src/md2_impls/md2_common.c src/md2_impls/md2_0.c OBJ = ${subst src,build,${SRC:.c=.o}} CC = gcc -CFLAGS = -Ilib -ggdb -std=c11 +CFLAGS = -Ilib -ggdb -std=c11 -g -Wall -Wextra -no-pie -O3 LDFLAGS = all: md2 diff --git a/Implementierung/lib/md2.h b/Implementierung/lib/md2.h index f0dc597..5fe72ab 100644 --- a/Implementierung/lib/md2.h +++ b/Implementierung/lib/md2.h @@ -8,7 +8,8 @@ #include #include -typedef void (*md2_hash_func)(size_t len, const uint8_t buf[], uint8_t out[16]); +typedef void (*md2_hash_func)(size_t len, const uint8_t buf[len], + uint8_t out[16]); typedef void (*md2_checksum_func)(size_t len, uint8_t* buf); /** diff --git a/Implementierung/lib/md2_impls/md2_0.h b/Implementierung/lib/md2_impls/md2_0.h index 0b0172a..5bb2df7 100644 --- a/Implementierung/lib/md2_impls/md2_0.h +++ b/Implementierung/lib/md2_impls/md2_0.h @@ -8,7 +8,7 @@ #include #include -void md2_hash_0(size_t len, const uint8_t buf[], uint8_t out[16]); +void md2_hash_0(size_t len, const uint8_t buf[len], uint8_t out[16]); void md2_checksum_0(size_t len, uint8_t* buf); #endif // MD2_0_H \ No newline at end of file diff --git a/Implementierung/src/md2_impls/md2_0.c b/Implementierung/src/md2_impls/md2_0.c index 0bf59a6..eeb4354 100644 --- a/Implementierung/src/md2_impls/md2_0.c +++ b/Implementierung/src/md2_impls/md2_0.c @@ -5,7 +5,7 @@ void md2_checksum_0(size_t len, uint8_t* buf) { uint8_t l = 0; - for (int i = 0; i < len / 16; i++) { + for (size_t i = 0; i < len / 16; i++) { for (int j = 0; j < 16; j++) { u_int8_t c = buf[i * 16 + j]; // reference is wrong. It says: Set C[j] to S[c xor L]. But it should be: @@ -49,7 +49,7 @@ void md2_hash_0(size_t len, const uint8_t buf[len], uint8_t out[16]) { // === step 4 === // <= because we need to hash the last block too - for (int i = 0; i <= (len + 16) / 16 - 1; i++) { + for (size_t i = 0; i <= (len + 16) / 16 - 1; i++) { for (int j = 0; j < 16; j++) { messageDigestBuf[16 + j] = newBuf[i * 16 + j]; messageDigestBuf[32 + j] = diff --git a/Implementierung/src/md2_impls/md2_common.c b/Implementierung/src/md2_impls/md2_common.c index 6d2598d..1fa9cb6 100644 --- a/Implementierung/src/md2_impls/md2_common.c +++ b/Implementierung/src/md2_impls/md2_common.c @@ -22,7 +22,7 @@ unsigned char MD2_PI_SUBST[256] = { 20}; void md2_print_buf(size_t len, uint8_t buf[len]) { - for (int i = 0; i < len; i++) { + for (size_t i = 0; i < len; i++) { printf("'%02x',", buf[i]); } printf("\n");