Bump version to 0.6.4.1
[libmkv.git] / src / md5.h
blob724ded2368cd9bc4f459ea59e72b84924a1a6455
1 /**
2 * \file md5.h
3 * This implementation of MD5 comes from the XYSSL project.
4 */
5 #ifndef LIBMKV_MD5_H
6 #define LIBMKV_MD5_H
8 /**
9 * \brief MD5 context structure
11 typedef struct {
12 unsigned long total[2]; /*!< number of bytes processed */
13 unsigned long state[4]; /*!< intermediate digest state */
14 unsigned char buffer[64]; /*!< data block being processed */
16 unsigned char ipad[64]; /*!< HMAC: inner padding */
17 unsigned char opad[64]; /*!< HMAC: outer padding */
18 } md5_context;
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
24 /**
25 * \brief MD5 context setup
27 * \param ctx context to be initialized
29 void md5_starts(md5_context * ctx);
31 /**
32 * \brief MD5 process buffer
34 * \param ctx MD5 context
35 * \param input buffer holding the data
36 * \param ilen length of the input data
38 void md5_update(md5_context * ctx, unsigned char *input, int ilen);
40 /**
41 * \brief MD5 final digest
43 * \param ctx MD5 context
44 * \param output MD5 checksum result
46 void md5_finish(md5_context * ctx, unsigned char output[16]);
48 /**
49 * \brief Output = MD5( input buffer )
51 * \param input buffer holding the data
52 * \param ilen length of the input data
53 * \param output MD5 checksum result
55 void md5(unsigned char *input, int ilen, unsigned char output[16]);
57 /**
58 * \brief Output = MD5( file contents )
60 * \param path input file name
61 * \param output MD5 checksum result
63 * \return 0 if successful, 1 if fopen failed,
64 * or 2 if fread failed
66 int md5_file(char *path, unsigned char output[16]);
68 /**
69 * \brief MD5 HMAC context setup
71 * \param ctx HMAC context to be initialized
72 * \param key HMAC secret key
73 * \param keylen length of the HMAC key
75 void md5_hmac_starts(md5_context * ctx, unsigned char *key,
76 int keylen);
78 /**
79 * \brief MD5 HMAC process buffer
81 * \param ctx HMAC context
82 * \param input buffer holding the data
83 * \param ilen length of the input data
85 void md5_hmac_update(md5_context * ctx, unsigned char *input,
86 int ilen);
88 /**
89 * \brief MD5 HMAC final digest
91 * \param ctx HMAC context
92 * \param output MD5 HMAC checksum result
94 void md5_hmac_finish(md5_context * ctx, unsigned char output[16]);
96 /**
97 * \brief Output = HMAC-MD5( hmac key, input buffer )
99 * \param key HMAC secret key
100 * \param keylen length of the HMAC key
101 * \param input buffer holding the data
102 * \param ilen length of the input data
103 * \param output HMAC-MD5 result
105 void md5_hmac(unsigned char *key, int keylen,
106 unsigned char *input, int ilen,
107 unsigned char output[16]);
110 * \brief Checkup routine
112 * \return 0 if successful, or 1 if the test failed
114 int md5_self_test(int verbose);
116 #ifdef __cplusplus
118 #endif
119 #endif /* md5.h */