/** * \file * * * \brief MD2 Message-Digest algorithm. * * The algorithm takes as input a message of arbitrary length and produces * as output a 128-bit message digest of the input. * It is conjectured that it is computationally infeasible to produce * two messages having the same message digest, or to produce any * message having a given prespecified target message digest. * * * \author Daniele Basile * * $WIZ$ module_name = "md2" * $WIZ$ module_configuration = "bertos/cfg/cfg_md2.h" */ #ifndef ALGO_MD2_H #define ALGO_MD2_H #include "cfg/cfg_md2.h" #include #define NUM_COMPUTE_ROUNDS 18 ///< Number of compute rounds. #define COMPUTE_ARRAY_LEN CONFIG_MD2_BLOCK_LEN * 3 ///< Lenght of compute array. #define MD2_DIGEST_LEN CONFIG_MD2_BLOCK_LEN /** * Context for MD2 computation. */ typedef struct Md2Context { uint8_t buffer[CONFIG_MD2_BLOCK_LEN]; ///< Input buffer. uint8_t state[CONFIG_MD2_BLOCK_LEN]; ///< Current state buffer. uint8_t checksum[CONFIG_MD2_BLOCK_LEN]; ///< Checksum. size_t counter; ///< Counter of remaining bytes. } Md2Context; void md2_init(Md2Context *context); void md2_update(Md2Context *context, const void *block_in, size_t block_len); uint8_t *md2_end(Md2Context *context); bool md2_test(void); #endif /* ALGO_MD2_H */