2015-05-13 07:27:44 +00:00
|
|
|
/*
|
2015-05-19 07:57:10 +00:00
|
|
|
* BIRD Library -- MD5 Hash Function and HMAC-MD5 Function
|
2015-05-13 07:27:44 +00:00
|
|
|
*
|
|
|
|
* (c) 2015 CZ.NIC z.s.p.o.
|
|
|
|
*
|
|
|
|
* Adapted for BIRD by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
|
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
1998-05-03 16:43:39 +00:00
|
|
|
|
2015-05-13 07:32:00 +00:00
|
|
|
#ifndef _BIRD_MD5_H_
|
|
|
|
#define _BIRD_MD5_H_
|
|
|
|
|
|
|
|
#define MD5_SIZE 16
|
|
|
|
#define MD5_HEX_SIZE 33
|
|
|
|
#define MD5_BLOCK_SIZE 64
|
|
|
|
|
2015-05-19 07:57:10 +00:00
|
|
|
struct md5_context
|
2015-05-13 08:55:02 +00:00
|
|
|
{
|
2015-05-13 07:32:00 +00:00
|
|
|
u32 buf[4];
|
|
|
|
u32 bits[2];
|
2015-05-19 06:14:04 +00:00
|
|
|
byte in[64];
|
2015-05-19 07:57:10 +00:00
|
|
|
};
|
2015-05-13 07:32:00 +00:00
|
|
|
|
2015-05-19 07:57:10 +00:00
|
|
|
void md5_init(struct md5_context *context);
|
|
|
|
void md5_update(struct md5_context *context, byte const *buf, uint len);
|
|
|
|
byte *md5_final(struct md5_context *context);
|
2015-05-13 08:55:02 +00:00
|
|
|
|
2015-05-19 07:57:10 +00:00
|
|
|
/*
|
2015-05-13 09:14:11 +00:00
|
|
|
* HMAC-MD5
|
|
|
|
*/
|
2015-05-19 07:57:10 +00:00
|
|
|
struct md5_hmac_context
|
2015-05-13 09:14:11 +00:00
|
|
|
{
|
2015-05-19 07:57:10 +00:00
|
|
|
struct md5_context ictx;
|
|
|
|
struct md5_context octx;
|
|
|
|
};
|
2015-05-13 09:14:11 +00:00
|
|
|
|
2015-05-19 07:57:10 +00:00
|
|
|
void md5_hmac_init(struct md5_hmac_context *ctx, const byte *key, size_t keylen);
|
|
|
|
void md5_hmac_update(struct md5_hmac_context *ctx, const byte *buf, size_t buflen);
|
|
|
|
byte *md5_hmac_final(struct md5_hmac_context *ctx);
|
1998-05-03 16:43:39 +00:00
|
|
|
|
2015-05-13 07:27:44 +00:00
|
|
|
#endif /* _BIRD_MD5_H_ */
|