From d54e10fbe3be93631331308de94a9d256b480302 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Wed, 20 Jul 2022 22:26:43 +0200 Subject: [PATCH] Feat: add detailed benchmar to reference impl --- .../lib/md2_impls/md2_reference/md2_reference.h | 2 ++ .../src/md2_impls/md2_reference/md2_reference.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/Implementierung/lib/md2_impls/md2_reference/md2_reference.h b/Implementierung/lib/md2_impls/md2_reference/md2_reference.h index 962004a..06170dc 100644 --- a/Implementierung/lib/md2_impls/md2_reference/md2_reference.h +++ b/Implementierung/lib/md2_impls/md2_reference/md2_reference.h @@ -49,6 +49,8 @@ void MD2Final PROTO_LIST((unsigned char[16], MD2_CTX *)); #include #include +#include "../md2_common.h" + void md2_hash_ref(size_t len, const uint8_t buf[len], uint8_t out[16]); #endif // MD2_REF_H \ No newline at end of file diff --git a/Implementierung/src/md2_impls/md2_reference/md2_reference.c b/Implementierung/src/md2_impls/md2_reference/md2_reference.c index b679797..5dab73a 100644 --- a/Implementierung/src/md2_impls/md2_reference/md2_reference.c +++ b/Implementierung/src/md2_impls/md2_reference/md2_reference.c @@ -83,6 +83,7 @@ void md2_hash_ref(size_t len, const uint8_t buf[len], uint8_t out[16]) { MD2Init(&context); MD2Update(&context, buf, len); MD2Final(out, &context); + END_MARK } /* MD2 initialization. Begins an MD2 operation, writing a new context. @@ -169,23 +170,29 @@ unsigned char block[16]; */ MD2_memcpy((POINTER)x, (POINTER)state, 16); MD2_memcpy((POINTER)x + 16, (POINTER)block, 16); + FIRST_LOOP_START_MARK for (i = 0; i < 16; i++) x[i + 32] = state[i] ^ block[i]; + FIRST_LOOP_END_MARK /* Encrypt block (18 rounds). */ t = 0; + SECOND_LOOP_START_MARK for (i = 0; i < 18; i++) { for (j = 0; j < 48; j++) t = x[j] ^= PI_SUBST[t]; t = (t + i) & 0xff; } + SECOND_LOOP_END_MARK /* Save new state */ MD2_memcpy((POINTER)state, (POINTER)x, 16); /* Update checksum. */ + CHECKSUM_START_MARK t = checksum[15]; for (i = 0; i < 16; i++) t = checksum[i] ^= PI_SUBST[block[i] ^ t]; + CHECKSUM_END_MARK /* Zeroize sensitive information. */