Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 1 | #ifndef MD5_H |
| 2 | #define MD5_H |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | |
| 6 | #define MD5_DIGEST_SIZE 16 |
| 7 | #define MD5_HMAC_BLOCK_SIZE 64 |
| 8 | #define MD5_BLOCK_WORDS 16 |
| 9 | #define MD5_HASH_WORDS 4 |
| 10 | |
| 11 | #define F1(x, y, z) (z ^ (x & (y ^ z))) |
| 12 | #define F2(x, y, z) F1(z, x, y) |
| 13 | #define F3(x, y, z) (x ^ y ^ z) |
| 14 | #define F4(x, y, z) (y ^ (x | ~z)) |
| 15 | |
| 16 | #define MD5STEP(f, w, x, y, z, in, s) \ |
| 17 | (w += f(x, y, z) + in, w = (w<<s | w>>(32-s)) + x) |
| 18 | |
Jens Axboe | 25dfa84 | 2012-02-29 10:01:34 +0100 | [diff] [blame] | 19 | struct fio_md5_ctx { |
Jens Axboe | 8c43232 | 2007-07-27 13:16:24 +0200 | [diff] [blame] | 20 | uint32_t *hash; |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 21 | uint32_t block[MD5_BLOCK_WORDS]; |
| 22 | uint64_t byte_count; |
| 23 | }; |
| 24 | |
Jens Axboe | 25dfa84 | 2012-02-29 10:01:34 +0100 | [diff] [blame] | 25 | extern void fio_md5_update(struct fio_md5_ctx *, const uint8_t *, unsigned int); |
Jens Axboe | 89cce05 | 2014-09-23 14:08:21 -0600 | [diff] [blame] | 26 | extern void fio_md5_final(struct fio_md5_ctx *); |
Jens Axboe | 25dfa84 | 2012-02-29 10:01:34 +0100 | [diff] [blame] | 27 | extern void fio_md5_init(struct fio_md5_ctx *); |
Jens Axboe | ebac465 | 2005-12-08 15:25:21 +0100 | [diff] [blame] | 28 | |
| 29 | #endif |