Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-17 09:55:48

0001 /*  $OpenBSD: md5.h,v 1.15 2004/05/03 17:30:14 millert Exp $    */
0002 
0003 /*
0004  * This code implements the MD5 message-digest algorithm.
0005  * The algorithm is due to Ron Rivest.  This code was
0006  * written by Colin Plumb in 1993, no copyright is claimed.
0007  * This code is in the public domain; do with it what you wish.
0008  *
0009  * Equivalent code is available from RSA Data Security, Inc.
0010  * This code has been tested against that, and is equivalent,
0011  * except that you don't need to include two pages of legalese
0012  * with every copy.
0013  */
0014 
0015 #ifndef _MD5_H_
0016 #define _MD5_H_
0017 
0018 #include <sys/types.h>
0019 
0020 #include <stdint.h>
0021 
0022 #define MD5_BLOCK_LENGTH        64
0023 #define MD5_DIGEST_LENGTH       16
0024 #define MD5_DIGEST_STRING_LENGTH    (MD5_DIGEST_LENGTH * 2 + 1)
0025 
0026 typedef struct MD5Context {
0027     uint32_t state[4];          /* state */
0028     uint64_t count;             /* number of bits, mod 2^64 */
0029     uint8_t buffer[MD5_BLOCK_LENGTH];   /* input buffer */
0030 } MD5_CTX;
0031 
0032 #ifdef __cplusplus
0033 extern "C" {
0034 #endif
0035 
0036 void     MD5Init(MD5_CTX *);
0037 void     MD5Update(MD5_CTX *, const uint8_t *, size_t);
0038 void     MD5Pad(MD5_CTX *);
0039 void     MD5Final(uint8_t [MD5_DIGEST_LENGTH], MD5_CTX *);
0040 void     MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH]);
0041 char    *MD5End(MD5_CTX *, char *);
0042 char    *MD5File(const char *, char *);
0043 char    *MD5FileChunk(const char *, char *, off_t, off_t);
0044 char    *MD5Data(const uint8_t *, size_t, char *);
0045 
0046 #ifdef __cplusplus
0047 }
0048 #endif
0049 
0050 /* Avoid polluting the namespace. Even though this makes this usage
0051  * implementation-specific, defining it unconditionally should not be
0052  * a problem, and better than possibly breaking unexpecting code. */
0053 #ifdef LIBMD_MD5_ALADDIN
0054 
0055 /*
0056  * Interface compatibility with Aladdin Enterprises independent
0057  * implementation from RFC 1321.
0058  */
0059 
0060 typedef uint8_t md5_byte_t;
0061 typedef uint32_t md5_word_t;
0062 typedef MD5_CTX md5_state_t;
0063 
0064 #define md5_init(pms) MD5Init(pms)
0065 #define md5_append(pms, data, nbytes) MD5Update(pms, data, nbytes)
0066 #define md5_finish(pms, digest) MD5Final(digest, pms)
0067 
0068 #endif /* LIBMD_MD5_ALADDIN */
0069 
0070 #endif /* _MD5_H_ */