Merge branch 'master' of gitlab-gepasp.in.tum.de:gra22s/team199

This commit is contained in:
Dorian Zedler 2022-07-20 22:29:07 +02:00
commit e2825eeae7
Signed by: dorian
GPG key ID: 989DE36109AFA354
4 changed files with 25 additions and 30 deletions

View file

@ -9,7 +9,8 @@ ifeq ($(DETAILED_BENCHMARK), true)
CFLAGS += -DMD2_DETAILED_BENCHMARK
endif
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
@ -56,7 +57,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" >> $@; \

View file

@ -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

1 Implementierung 1 2 5 7 20 10 25 50 75 100 250 500 750 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500
2 Implementierung-0 Implementierung-4 0.092604 0.179950 0.172133 0.308132 0.422083 0.768091 1.077839 1.687540 0.845732 1.793499 3.786488 4.232703 7.788925 11.049307 8.501036 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
Implementierung-1 0.084314 0.167799 0.431772 1.708024 0.843568 5.208127 10.147011
Implementierung-2 0.097700 0.203661 0.567091 2.141933 1.062895 5.440520 10.342529
Implementierung-3 0.099547 0.206932 0.546978 2.077730 1.017148 5.067994 9.962873
Implementierung-4 0.117680 0.239349 0.616783 2.356915 1.200482 5.856234 11.647842

View file

@ -8,6 +8,13 @@
* Quelle: https://datatracker.ietf.org/doc/html/rfc1319
**********************************************************/
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifndef PROTOTYPES
#define PROTOTYPES 0
#endif
@ -34,23 +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 <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "../md2_common.h"
void md2_hash_ref(size_t len, const uint8_t buf[len], uint8_t out[16]);
#endif // MD2_REF_H
#endif // MD2_REF_H

View file

@ -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.
@ -101,9 +101,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;
@ -137,7 +137,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.
*/
@ -163,7 +163,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.
@ -203,9 +203,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];
}
@ -214,9 +214,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;
}