gra-projekt/Implementierung/lib/md2.h

36 lines
943 B
C

#ifndef MD2_H
#define MD2_H
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
/**
* @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
*/
void md2_hash(size_t len, const uint8_t buf[], uint8_t out[16]);
/**
* @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!
*/
void md2_checksum(size_t len, uint8_t* buf);
/**
* @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 encodeHash(uint8_t hash[16], char* stringHash);
#endif // MD2_H