From 67bd35cd63738c2ae434f393f1d2caa43b79456b Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Wed, 20 Jul 2022 22:27:16 +0200 Subject: [PATCH] Fix: replace unsigned int with size_t --- Implementierung/Makefile | 5 +++-- Implementierung/benchmarks.csv | 8 ++------ .../md2_impls/md2_reference/md2_reference.h | 20 +++++++++---------- .../md2_impls/md2_reference/md2_reference.c | 20 +++++++++---------- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/Implementierung/Makefile b/Implementierung/Makefile index 205f196..a0fd98e 100644 --- a/Implementierung/Makefile +++ b/Implementierung/Makefile @@ -5,7 +5,8 @@ OBJ = ${subst src,build,${SRC:.c=.o}} CC = gcc CFLAGS = -Ilib -ggdb -std=c11 -g -Wall -Wextra -no-pie -O3 LDFLAGS = -pthread -TESTFILES = t/1 t/2 t/5 t/10 t/20 t/50 t/100 t/1000 t/2000 t/5000 t/10000 +#TESTFILES = t/1 t/2 t/5 t/7 t/10 t/25 t/50 t/75 t/100 t/250 t/500 t/750 t/1000 t/1500 t/2000 t/2500 t/3000 t/3500 t/4000 t/4500 t/5000 t/5500 +TESTFILES = t/6000 t/6500 t/7000 t/7500 t/8000 t/8500 t/9000 t/9500 t/10000 TESTFILES_SIZES = ${subst t/,,${TESTFILES}} BLUE=\033[1;36m RED=\033[1;31m @@ -49,7 +50,7 @@ benchmarks.csv: md2 ${TESTFILES} done @echo "" >> $@ - @for i in 0 1 2 3 4; do \ + @for i in 4; do \ echo ;\ echo -e "${BLUE}=== Testing implementation $$i ===${NC}";\ echo -n "Implementierung-$$i" >> $@; \ diff --git a/Implementierung/benchmarks.csv b/Implementierung/benchmarks.csv index fd1c7ad..7782f3e 100644 --- a/Implementierung/benchmarks.csv +++ b/Implementierung/benchmarks.csv @@ -1,6 +1,2 @@ -Implementierung;1;2;5;10;20;50;100 -Implementierung-0;0.092604;0.172133;0.422083;0.845732;1.687540;4.232703;8.501036 -Implementierung-1;0.084314;0.167799;0.431772;0.843568;1.708024;5.208127;10.147011 -Implementierung-2;0.097700;0.203661;0.567091;1.062895;2.141933;5.440520;10.342529 -Implementierung-3;0.099547;0.206932;0.546978;1.017148;2.077730;5.067994;9.962873 -Implementierung-4;0.117680;0.239349;0.616783;1.200482;2.356915;5.856234;11.647842 +Implementierung;1;2;5;7;10;25;50;75;100;250;500;750;1000;1500;2000;2500;3000;3500;4000;4500;5000;5500 +Implementierung-4;0.179950;0.308132;0.768091;1.077839;1.793499;3.786488;7.788925;11.049307;15.051300;37.564573;74.324851;112.160912;150.740498;225.111342;305.938520;381.063308;463.611798;533.670234;614.535749;63.418839;137.076754;292.555679 diff --git a/Implementierung/lib/md2_impls/md2_reference/md2_reference.h b/Implementierung/lib/md2_impls/md2_reference/md2_reference.h index 962004a..8166af9 100644 --- a/Implementierung/lib/md2_impls/md2_reference/md2_reference.h +++ b/Implementierung/lib/md2_impls/md2_reference/md2_reference.h @@ -8,6 +8,13 @@ * Quelle: https://datatracker.ietf.org/doc/html/rfc1319 **********************************************************/ +#include +#include +#include +#include +#include +#include + #ifndef PROTOTYPES #define PROTOTYPES 0 #endif @@ -34,21 +41,14 @@ typedef unsigned long int UINT4; typedef struct { unsigned char state[16]; /* state */ unsigned char checksum[16]; /* checksum */ - unsigned int count; /* number of bytes, modulo 16 */ + size_t count; /* number of bytes, modulo 16 */ unsigned char buffer[16]; /* input buffer */ } MD2_CTX; void MD2Init PROTO_LIST((MD2_CTX *)); -void MD2Update PROTO_LIST((MD2_CTX *, unsigned char *, unsigned int)); +void MD2Update PROTO_LIST((MD2_CTX *, unsigned char *, size_t)); void MD2Final PROTO_LIST((unsigned char[16], MD2_CTX *)); -#include -#include -#include -#include -#include -#include - 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 +#endif // MD2_REF_H diff --git a/Implementierung/src/md2_impls/md2_reference/md2_reference.c b/Implementierung/src/md2_impls/md2_reference/md2_reference.c index b679797..742e212 100644 --- a/Implementierung/src/md2_impls/md2_reference/md2_reference.c +++ b/Implementierung/src/md2_impls/md2_reference/md2_reference.c @@ -30,8 +30,8 @@ static void MD2Transform PROTO_LIST((unsigned char[16], unsigned char[16], unsigned char[16])); -static void MD2_memcpy PROTO_LIST((POINTER, POINTER, unsigned int)); -static void MD2_memset PROTO_LIST((POINTER, int, unsigned int)); +static void MD2_memcpy PROTO_LIST((POINTER, POINTER, size_t)); +static void MD2_memset PROTO_LIST((POINTER, int, size_t)); /* Permutation of 0..255 constructed from the digits of pi. It gives a "random" nonlinear byte substitution operation. @@ -100,9 +100,9 @@ void MD2Init(context) MD2_CTX *context; /* context */ */ void MD2Update(context, input, inputLen) MD2_CTX *context; /* context */ unsigned char *input; /* input block */ -unsigned int inputLen; /* length of input block */ +size_t inputLen; /* length of input block */ { - unsigned int i, index, partLen; + size_t i, index, partLen; /* Update number of bytes mod 16 */ index = context->count; @@ -136,7 +136,7 @@ void MD2Final(digest, context) unsigned char digest[16]; /* message digest */ MD2_CTX *context; /* context */ { - unsigned int index, padLen; + size_t index, padLen; /* Pad out to multiple of 16. */ @@ -162,7 +162,7 @@ static void MD2Transform(state, checksum, block) unsigned char state[16]; unsigned char checksum[16]; unsigned char block[16]; { - unsigned int i, j, t; + size_t i, j, t; unsigned char x[48]; /* Form encryption block from state, block, state ^ block. @@ -196,9 +196,9 @@ unsigned char block[16]; */ static void MD2_memcpy(output, input, len) POINTER output; POINTER input; -unsigned int len; +size_t len; { - unsigned int i; + size_t i; for (i = 0; i < len; i++) output[i] = input[i]; } @@ -207,9 +207,9 @@ unsigned int len; */ static void MD2_memset(output, value, len) POINTER output; int value; -unsigned int len; +size_t len; { - unsigned int i; + size_t i; for (i = 0; i < len; i++) ((char *)output)[i] = (char)value; }