Mercurial > hg > th-libs
view th_crypto.h @ 135:1b39682de64f
Add "crypto" module, only silly MD5 calculation in it now.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 24 Sep 2014 23:45:39 +0300 |
parents | |
children | d9f1d1c977ff |
line wrap: on
line source
/* * MD5 implementation, modified for th-libs from * Colin Plumb's implementation by Matti 'ccr' Hämäläinen. * * This code implements the MD5 message-digest algorithm. * The algorithm is due to Ron Rivest. This code was * written by Colin Plumb in 1993, no copyright is claimed. * This code is in the public domain; do with it what you wish. */ #ifndef TH_CRYPTO_H #define TH_CRYPTO_H 1 #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "th_endian.h" #ifdef __cplusplus extern "C" { #endif typedef struct { uint32_t bits[2]; // Message length in bits, lsw first uint32_t buf[4]; // Digest buffer uint8_t in[64]; // Accumulate block } th_md5state_t; #define TH_MD5HASH_LENGTH (16) #define TH_MD5HASH_LENGTH_CH (TH_MD5HASH_LENGTH * 2) typedef uint8_t th_md5hash_t[TH_MD5HASH_LENGTH]; void th_md5_init(th_md5state_t *ctx); void th_md5_append(th_md5state_t *ctx, const uint8_t *buf, size_t len); void th_md5_finish(th_md5state_t *ctx, th_md5hash_t digest); void th_md5_print(FILE *, const th_md5hash_t digest); #ifdef __cplusplus } #endif #endif /* TH_CRYPTO_H */