replaced libart with new polygon code
[swftools.git] / lib / MD5.c
index d1544ab..9e60f50 100644 (file)
--- a/lib/MD5.c
+++ b/lib/MD5.c
@@ -33,6 +33,7 @@
 #include "../config.h"
 
 #include <string.h>
+#include <memory.h>
 
 #ifndef _NETINET6_MD5_H_
 #define _NETINET6_MD5_H_
@@ -175,6 +176,24 @@ void hash_md5(const unsigned char*buf, int len, unsigned char*dest)
     MD5Final(dest, &ctx);
 }
 
+void* init_md5()
+{
+    MD5_CTX* ctx = malloc(sizeof(MD5_CTX));
+    memset(ctx, 0, sizeof(MD5_CTX));
+    MD5Init(ctx);
+    return ctx;
+}
+void update_md5(void*ctx, unsigned char*data, int len)
+{
+    MD5Update(ctx, data, len);
+}
+void finish_md5(void*ctx, unsigned char*dest)
+{
+    MD5Final(dest, ctx);
+    free(ctx);
+}
+
+
 char * crypt_md5(const char *pw, const char *salt)
 {
        MD5_CTX ctx,ctx1;
@@ -408,8 +427,7 @@ static const u_int8_t md5_paddat[MD5_BUFLEN] = {
 
 static void md5_calc(u_int8_t *, md5_ctxt *);
 
-static void md5_init(ctxt)
-       md5_ctxt *ctxt;
+static void md5_init(md5_ctxt *ctxt)
 {
        ctxt->md5_n = 0;
        ctxt->md5_i = 0;
@@ -420,10 +438,7 @@ static void md5_init(ctxt)
        bzero(ctxt->md5_buf, sizeof(ctxt->md5_buf));
 }
 
-static void md5_loop(ctxt, input, len)
-       md5_ctxt *ctxt;
-       const u_int8_t *input;
-       u_int len; /* number of bytes */
+static void md5_loop(md5_ctxt *ctxt, const u_int8_t *input, u_int len)
 {
        u_int gap, i;
 
@@ -448,8 +463,7 @@ static void md5_loop(ctxt, input, len)
        }
 }
 
-static void md5_pad(ctxt)
-       md5_ctxt *ctxt;
+static void md5_pad(md5_ctxt *ctxt)
 {
        u_int gap;
 
@@ -487,9 +501,7 @@ static void md5_pad(ctxt)
        md5_calc(ctxt->md5_buf, ctxt);
 }
 
-static void md5_result(digest, ctxt)
-       u_int8_t *digest;
-       md5_ctxt *ctxt;
+static void md5_result(u_int8_t *digest, md5_ctxt *ctxt)
 {
        /* 4 byte words */
 #if BYTE_ORDER == LITTLE_ENDIAN
@@ -507,9 +519,7 @@ static void md5_result(digest, ctxt)
 #endif
 }
 
-static void md5_calc(b64, ctxt)
-       u_int8_t *b64;
-       md5_ctxt *ctxt;
+static void md5_calc(u_int8_t *b64, md5_ctxt *ctxt)
 {
        u_int32_t A = ctxt->md5_sta;
        u_int32_t B = ctxt->md5_stb;