gra-projekt/Implementierung/lib/md2.h

50 lines
1.3 KiB
C
Raw Normal View History

2022-06-29 10:58:49 +02:00
#ifndef MD2_H
#define MD2_H
2022-07-04 18:02:34 +02:00
#include <stdbool.h>
2022-06-29 10:58:49 +02:00
#include <stdint.h>
2022-06-29 15:41:56 +02:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
2022-06-29 11:08:31 +02:00
#include <sys/types.h>
2022-07-06 20:35:27 +02:00
typedef void (*md2_hash_func)(size_t len, const uint8_t buf[len],
uint8_t out[16]);
2022-07-04 18:02:34 +02:00
typedef void (*md2_checksum_func)(size_t len, uint8_t* buf);
2022-06-29 11:08:31 +02:00
/**
* @brief Calculates checksum of buf and stores it in out
2022-06-29 11:12:35 +02:00
*
2022-06-29 11:08:31 +02:00
* @param len Length of the data at buf
* @param buf Location of the data
* @param out Destination array of for the checksum
*/
2022-07-04 18:02:34 +02:00
extern md2_hash_func md2_hash;
2022-06-29 11:08:31 +02:00
/**
* @brief Calculates checksum of buf and appends it to buf
2022-06-29 11:12:35 +02:00
*
2022-06-29 11:08:31 +02:00
* @param len Length of data which the checksum should be calculated of
2022-06-29 11:12:35 +02:00
* @param buf Location of the data. Make sure to reserve 16 bytes more so the
* chechsum fits!
2022-06-29 11:08:31 +02:00
*/
2022-07-04 18:02:34 +02:00
extern md2_checksum_func md2_checksum;
/**
* @brief Choose the implementation to use
*
* @param i the implementation
* @return true when the implemenatation was changed
* @return false when the implementation does not exist
*/
bool md2_choose_implementation(int i);
2022-06-29 10:58:49 +02:00
2022-06-29 22:02:18 +02:00
/**
* @brief Takes a uint8_t array and converts it into a string
*
* @param hash the array containing the hash
* @param stringHash pointer to store the string, has to have 32 bytes space
*/
2022-07-04 18:02:34 +02:00
void md2_encode_hash(uint8_t hash[16], char* string_hash);
2022-06-29 19:03:12 +02:00
2022-06-29 11:12:35 +02:00
#endif // MD2_H