Doxygen annotations for config files.
[tools/librpm-tizen.git] / lib / md5.h
1 #ifndef MD5_H
2 #define MD5_H
3
4 /**
5  * \file lib/md5.h
6  * @todo Eliminate, use rpmio version instead.
7  */
8
9 #include <sys/types.h>
10
11 typedef unsigned int uint32;
12
13 /**
14  * MD5 private data.
15  */
16 struct MD5Context {
17         uint32 buf[4];
18         uint32 bits[2];
19         unsigned char in[64];
20         int doByteReverse;
21 };
22
23 /*
24  * This is needed to make RSAREF happy on some MS-DOS compilers.
25  */
26 typedef /*@abstract@*/ struct MD5Context MD5_CTX;
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 /**
33  * Initialize MD5 hash.
34  * Set bit count to 0 and buffer to mysterious initialization constants.
35  * @param context       MD5 private data
36  * @param brokenEndian  calculate broken MD5 sum?
37  */
38 void rpmMD5Init( /*@out@*/ struct MD5Context *context, int brokenEndian);
39
40 /**
41  * Update context to reflect the concatenation of another buffer full
42  * of bytes.
43  * @param context       MD5 private data
44  * @param data          next data buffer
45  * @param len           no. bytes of data
46  */
47 void rpmMD5Update(struct MD5Context *context, unsigned char const *buf,
48                unsigned len);
49 /**
50  * Return MD5 digest, and reset context.
51  * @retval              MD5 digest
52  * @param context       MD5 private data
53  */
54 void rpmMD5Final(unsigned char digest[16], struct MD5Context *context);
55
56 /**
57  * The core of the MD5 algorithm.
58  * This alters an existing MD5 hash to reflect the addition of 16 longwords
59  * of new data.
60  * @param buf           current MD5 variables
61  * @param in            next block of data to add
62  */
63 void rpmMD5Transform(uint32 buf[4], uint32 const in[16]);
64
65 /**
66  * Return MD5 sum of file as ASCII string.
67  * @param fn            file name
68  * @retval digest       MD5 digest
69  * @return              0 on success, 1 on error
70  */
71 int mdfile(const char *fn, unsigned char *digest);
72
73 /**
74  * Return MD5 sum of file as binary data.
75  * @param fn            file name
76  * @retval bindigest    MD5 digest
77  * @return              0 on success, 1 on error
78  */
79 int mdbinfile(const char *fn, unsigned char *bindigest);
80
81 /* These assume a little endian machine and return incorrect results!
82    They are here for compatibility with old (broken) versions of RPM */
83
84 /**
85  * Return (broken!) MD5 sum of file as ASCII string.
86  * @deprecated Here for compatibility with old (broken) versions of RPM.
87  * @param fn            file name
88  * @retval digest       MD5 digest
89  * @return              0 on success, 1 on error
90  */
91 int mdfileBroken(const char *fn, unsigned char *digest);
92
93 /**
94  * Return (broken!) MD5 sum of file as binary data.
95  * @deprecated Here for compatibility with old (broken) versions of RPM.
96  * @param fn            file name
97  * @retval bindigest    MD5 digest
98  * @return              0 on success, 1 on error
99  */
100 int mdbinfileBroken(const char *fn, unsigned char *bindigest);
101
102 #ifdef __cplusplus
103 }
104 #endif
105
106 #endif  /* MD5_H */