summaryrefslogtreecommitdiff
path: root/lib/md5.h
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2015-11-25 14:24:35 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2015-11-25 14:24:35 +0100
commit04ae8ddaa15b72c265dc7cf038b733d235198754 (patch)
treeeadc4dfee9a0f0eba3446538129608dffbde4625 /lib/md5.h
parentd44e686e9bcae5850115c0e1adfe24523dce61ee (diff)
parent33b4f40acce02c90b4b7766c5c94ebf2d22765c6 (diff)
Merge branch 'master' into int-new
Diffstat (limited to 'lib/md5.h')
-rw-r--r--lib/md5.h55
1 files changed, 43 insertions, 12 deletions
diff --git a/lib/md5.h b/lib/md5.h
index 12586357..034d764c 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -1,16 +1,47 @@
-#ifndef MD5_H
-#define MD5_H
+/*
+ * BIRD Library -- MD5 Hash Function and HMAC-MD5 Function
+ *
+ * (c) 2015 CZ.NIC z.s.p.o.
+ *
+ * Adapted for BIRD by Martin Mares <mj@ucw.cz>
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
-struct MD5Context {
- u32 buf[4];
- u32 bits[2];
- unsigned char in[64];
+#ifndef _BIRD_MD5_H_
+#define _BIRD_MD5_H_
+
+#include "nest/bird.h"
+
+
+#define MD5_SIZE 16
+#define MD5_HEX_SIZE 33
+#define MD5_BLOCK_SIZE 64
+
+
+struct md5_context {
+ u32 buf[4];
+ u32 bits[2];
+ byte in[64];
};
-void MD5Init(struct MD5Context *context);
-void MD5Update(struct MD5Context *context, unsigned char const *buf,
- unsigned len);
-void MD5Final(unsigned char digest[16], struct MD5Context *context);
-void MD5Transform(u32 buf[4], u32 const in[16]);
+void md5_init(struct md5_context *ctx);
+void md5_update(struct md5_context *ctx, const byte *buf, uint len);
+byte *md5_final(struct md5_context *ctx);
+
+
+/*
+ * HMAC-MD5
+ */
+
+struct md5_hmac_context {
+ struct md5_context ictx;
+ struct md5_context octx;
+};
+
+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);
+
-#endif /* !MD5_H */
+#endif /* _BIRD_MD5_H_ */