gra-projekt/Implementierung/lib/md2_impls/md2_reference/md2_reference.h
2022-07-20 22:27:16 +02:00

54 lines
1.4 KiB
C

#ifndef MD2_REF_H
#define MD2_REF_H
/***********************************************************
* WICHTIG:
* Diese Implementierung wurde nicht von uns geschrieben,
* sondern zu vergleichszwechen von der Referenz übernommen.
* 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
/* POINTER defines a generic pointer type */
typedef unsigned char *POINTER;
/* UINT2 defines a two byte word */
typedef unsigned short int UINT2;
/* UINT4 defines a four byte word */
typedef unsigned long int UINT4;
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
returns an empty list.
*/
#if PROTOTYPES
#define PROTO_LIST(list) list
#else
#define PROTO_LIST(list) ()
#endif
typedef struct {
unsigned char state[16]; /* state */
unsigned char checksum[16]; /* checksum */
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 *, size_t));
void MD2Final PROTO_LIST((unsigned char[16], MD2_CTX *));
void md2_hash_ref(size_t len, const uint8_t buf[len], uint8_t out[16]);
#endif // MD2_REF_H