1/* $OpenBSD: md5.h,v 1.15 2004/05/03 17:30:14 millert Exp $ */
2
3/*
4 * This code implements the MD5 message-digest algorithm.
5 * The algorithm is due to Ron Rivest. This code was
6 * written by Colin Plumb in 1993, no copyright is claimed.
7 * This code is in the public domain; do with it what you wish.
8 *
9 * Equivalent code is available from RSA Data Security, Inc.
10 * This code has been tested against that, and is equivalent,
11 * except that you don't need to include two pages of legalese
12 * with every copy.
13 */
14
15#ifndef _MD5_H_
16#define _MD5_H_
17
18#include <sys/types.h>
19
20#include <stdint.h>
21
22#define MD5_BLOCK_LENGTH 64
23#define MD5_DIGEST_LENGTH 16
24#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1)
25
26typedef struct MD5Context {
27 uint32_t state[4]; /* state */
28 uint64_t count; /* number of bits, mod 2^64 */
29 uint8_t buffer[MD5_BLOCK_LENGTH]; /* input buffer */
30} MD5_CTX;
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36void MD5Init(MD5_CTX *);
37void MD5Update(MD5_CTX *, const uint8_t *, size_t);
38void MD5Pad(MD5_CTX *);
39void MD5Final(uint8_t [MD5_DIGEST_LENGTH], MD5_CTX *);
40void MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH]);
41char *MD5End(MD5_CTX *, char *);
42char *MD5File(const char *, char *);
43char *MD5FileChunk(const char *, char *, off_t, off_t);
44char *MD5Data(const uint8_t *, size_t, char *);
45
46#ifdef __cplusplus
47}
48#endif
49
50/* Avoid polluting the namespace. Even though this makes this usage
51 * implementation-specific, defining it unconditionally should not be
52 * a problem, and better than possibly breaking unexpecting code. */
53#ifdef LIBMD_MD5_ALADDIN
54
55/*
56 * Interface compatibility with Aladdin Enterprises independent
57 * implementation from RFC 1321.
58 */
59
60typedef uint8_t md5_byte_t;
61typedef uint32_t md5_word_t;
62typedef MD5_CTX md5_state_t;
63
64#define md5_init(pms) MD5Init(pms)
65#define md5_append(pms, data, nbytes) MD5Update(pms, data, nbytes)
66#define md5_finish(pms, digest) MD5Final(digest, pms)
67
68#endif /* LIBMD_MD5_ALADDIN */
69
70#endif /* _MD5_H_ */
71

source code of include/md5.h