gra-projekt/Implementierung/lib/md2.h

50 lines
No EOL
1.3 KiB
C

#ifndef MD2_H
#define MD2_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
typedef void (*md2_hash_func)(size_t len, const uint8_t buf[len],
uint8_t out[16]);
typedef void (*md2_checksum_func)(size_t len, uint8_t* buf);
/**
* @brief Calculates checksum of buf and stores it in out
*
* @param len Length of the data at buf
* @param buf Location of the data
* @param out Destination array of for the checksum
*/
extern md2_hash_func md2_hash;
/**
* @brief Calculates checksum of buf and appends it to buf
*
* @param len Length of data which the checksum should be calculated of
* @param buf Location of the data. Make sure to reserve 16 bytes more so the
* chechsum fits!
*/
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);
/**
* @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
*/
void md2_encode_hash(uint8_t hash[16], char* string_hash);
#endif // MD2_H