Ditch libuuid. Switch to using a md5 sum of each frame in the segment for the UID.
[libmkv.git] / src / md5.h
blob8d9d876ff24cdfdb6072d82f73be263898a9f527
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
13 unsigned long total[2]; /*!< number of bytes processed */
14 unsigned long state[4]; /*!< intermediate digest state */
15 unsigned char buffer[64]; /*!< data block being processed */
17 unsigned char ipad[64]; /*!< HMAC: inner padding */
18 unsigned char opad[64]; /*!< HMAC: outer padding */
20 md5_context;
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
26 /**
27 * \brief MD5 context setup
29 * \param ctx context to be initialized
31 void md5_starts( md5_context *ctx );
33 /**
34 * \brief MD5 process buffer
36 * \param ctx MD5 context
37 * \param input buffer holding the data
38 * \param ilen length of the input data
40 void md5_update( md5_context *ctx, unsigned char *input, int ilen );
42 /**
43 * \brief MD5 final digest
45 * \param ctx MD5 context
46 * \param output MD5 checksum result
48 void md5_finish( md5_context *ctx, unsigned char output[16] );
50 /**
51 * \brief Output = MD5( input buffer )
53 * \param input buffer holding the data
54 * \param ilen length of the input data
55 * \param output MD5 checksum result
57 void md5( unsigned char *input, int ilen, unsigned char output[16] );
59 /**
60 * \brief Output = MD5( file contents )
62 * \param path input file name
63 * \param output MD5 checksum result
65 * \return 0 if successful, 1 if fopen failed,
66 * or 2 if fread failed
68 int md5_file( char *path, unsigned char output[16] );
70 /**
71 * \brief MD5 HMAC context setup
73 * \param ctx HMAC context to be initialized
74 * \param key HMAC secret key
75 * \param keylen length of the HMAC key
77 void md5_hmac_starts( md5_context *ctx, unsigned char *key, int keylen );
79 /**
80 * \brief MD5 HMAC process buffer
82 * \param ctx HMAC context
83 * \param input buffer holding the data
84 * \param ilen length of the input data
86 void md5_hmac_update( md5_context *ctx, unsigned char *input, 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
120 #endif /* md5.h */