vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

ripemd.h (2432B)


      1 /* mhash_ripemd.h
      2  *
      3  * RIPEMD-160 is a 160-bit cryptographic hash function, designed by Hans
      4  * Dobbertin, Antoon Bosselaers, and Bart Preneel. It is intended to be
      5  * used as a secure replacement for the 128-bit hash functions MD4, MD5,
      6  * and RIPEMD
      7  * See also: http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html
      8  *
      9  * RIPEMD-128 is a plug-in substitute for RIPEMD (or MD4 and MD5, for
     10  * that matter) with a 128-bit result. 128-bit hash results do not
     11  * offer sufficient protection for the next ten years, and
     12  * applications using 128-bit hash functions should consider upgrading
     13  * to a 160-bit hash function.
     14  *
     15  * RIPEMD-256 and RIPEMD-320 are optional extensions of, respectively,
     16  * RIPEMD-128 and RIPEMD-160, and are intended for applications of
     17  * hash functions that require a longer hash result without needing a
     18  * larger security level.
     19  */
     20 
     21 /* The following code was written by Nikos Mavroyanopoulos and B. 
     22  * Poettering for the mhash library.
     23  */
     24 
     25 #if !defined(__MHASH_RIPEMD_H)
     26 #define __MHASH_RIPEMD_H
     27 
     28 
     29 #include <stdint.h>
     30 
     31 typedef uint8_t mutils_word8;
     32 typedef uint16_t mutils_word16;
     33 typedef uint32_t mutils_word32;
     34 typedef uint64_t mutils_word64;
     35 
     36 
     37 /* The RIPEMD block sizes and message digest sizes, in bytes */
     38 
     39 #define RIPEMD_DATASIZE    64
     40 #define RIPEMD_DATALEN     16
     41 
     42 #define RIPEMD128_DIGESTSIZE  16
     43 #define RIPEMD160_DIGESTSIZE  20
     44 #define RIPEMD256_DIGESTSIZE  32
     45 #define RIPEMD320_DIGESTSIZE  40
     46 
     47 #define RIPEMD_STATESIZE      10 /* state size in 32 bit words */
     48 
     49 
     50 /* The structure for storing RIPEMD info */
     51 
     52 typedef struct ripemd_ctx {
     53   mutils_word32 digest[RIPEMD_STATESIZE];     /* chaining varialbles */
     54   mutils_word64 bitcount;                     /* 64-bit bit counter */
     55   mutils_word8 block[RIPEMD_DATASIZE];        /* RIPEMD data buffer */
     56   mutils_word32 index;                        /* index into buffer */
     57   mutils_word32 digest_len;                   /* determines the algorithm to use */
     58 } RIPEMD_CTX;
     59 
     60 void ripemd128_init(struct ripemd_ctx *ctx);
     61 void ripemd160_init(struct ripemd_ctx *ctx);
     62 void ripemd256_init(struct ripemd_ctx *ctx);
     63 void ripemd320_init(struct ripemd_ctx *ctx);
     64 void ripemd_update(struct ripemd_ctx *ctx, mutils_word8 *buffer, mutils_word32 len);
     65 void ripemd_final(struct ripemd_ctx *ctx);
     66 void ripemd_digest(struct ripemd_ctx *ctx, mutils_word8 *s);
     67 
     68 #endif /* __MHASH_RIPEMD_H */