< prev index next >

src/java.desktop/share/native/liblcms/cmsmd5.c

Print this page

        

@@ -28,11 +28,11 @@
 // file:
 //
 //---------------------------------------------------------------------------------
 //
 //  Little Color Management System
-//  Copyright (c) 1998-2017 Marti Maria Saguer
+//  Copyright (c) 1998-2020 Marti Maria Saguer
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the "Software"),
 // to deal in the Software without restriction, including without limitation
 // the rights to use, copy, modify, merge, publish, distribute, sublicense,

@@ -92,14 +92,13 @@
 #define STEP(f, w, x, y, z, data, s) \
     ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
 
 
 static
-void MD5_Transform(cmsUInt32Number buf[4], cmsUInt32Number in[16])
-
+void cmsMD5_Transform(cmsUInt32Number buf[4], cmsUInt32Number in[16])
 {
-    register cmsUInt32Number a, b, c, d;
+    CMSREGISTER cmsUInt32Number a, b, c, d;
 
     a = buf[0];
     b = buf[1];
     c = buf[2];
     d = buf[3];

@@ -178,12 +177,12 @@
     buf[3] += d;
 }
 
 
 // Create a MD5 object
-static
-cmsHANDLE  MD5alloc(cmsContext ContextID)
+
+cmsHANDLE CMSEXPORT cmsMD5alloc(cmsContext ContextID)
 {
     _cmsMD5* ctx = (_cmsMD5*) _cmsMallocZero(ContextID, sizeof(_cmsMD5));
     if (ctx == NULL) return NULL;
 
     ctx ->ContextID = ContextID;

@@ -197,13 +196,11 @@
     ctx->bits[1] = 0;
 
     return (cmsHANDLE) ctx;
 }
 
-
-static
-void MD5add(cmsHANDLE Handle, cmsUInt8Number* buf, cmsUInt32Number len)
+void CMSEXPORT cmsMD5add(cmsHANDLE Handle, const cmsUInt8Number* buf, cmsUInt32Number len)
 {
     _cmsMD5* ctx = (_cmsMD5*) Handle;
     cmsUInt32Number t;
 
     t = ctx->bits[0];

@@ -225,29 +222,28 @@
         }
 
         memmove(p, buf, t);
         byteReverse(ctx->in, 16);
 
-        MD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
+        cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
         buf += t;
         len -= t;
     }
 
     while (len >= 64) {
         memmove(ctx->in, buf, 64);
         byteReverse(ctx->in, 16);
-        MD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
+        cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
         buf += 64;
         len -= 64;
     }
 
     memmove(ctx->in, buf, len);
 }
 
 // Destroy the object and return the checksum
-static
-void MD5finish(cmsProfileID* ProfileID,  cmsHANDLE Handle)
+void CMSEXPORT cmsMD5finish(cmsProfileID* ProfileID,  cmsHANDLE Handle)
 {
     _cmsMD5* ctx = (_cmsMD5*) Handle;
     cmsUInt32Number count;
     cmsUInt8Number *p;
 

@@ -260,22 +256,22 @@
 
     if (count < 8) {
 
         memset(p, 0, count);
         byteReverse(ctx->in, 16);
-        MD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
+        cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
 
         memset(ctx->in, 0, 56);
     } else {
         memset(p, 0, count - 8);
     }
     byteReverse(ctx->in, 14);
 
     ((cmsUInt32Number *) ctx->in)[14] = ctx->bits[0];
     ((cmsUInt32Number *) ctx->in)[15] = ctx->bits[1];
 
-    MD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
+    cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
 
     byteReverse((cmsUInt8Number *) ctx->buf, 4);
     memmove(ProfileID ->ID8, ctx->buf, 16);
 
     _cmsFree(ctx ->ContextID, ctx);

@@ -317,24 +313,24 @@
 
     // Save to temporary storage
     if (!cmsSaveProfileToMem(hProfile, Mem, &BytesNeeded)) goto Error;
 
     // Create MD5 object
-    MD5 = MD5alloc(ContextID);
+    MD5 = cmsMD5alloc(ContextID);
     if (MD5 == NULL) goto Error;
 
     // Add all bytes
-    MD5add(MD5, Mem, BytesNeeded);
+    cmsMD5add(MD5, Mem, BytesNeeded);
 
     // Temp storage is no longer needed
     _cmsFree(ContextID, Mem);
 
     // Restore header
     memmove(Icc, &Keep, sizeof(_cmsICCPROFILE));
 
     // And store the ID
-    MD5finish(&Icc ->ProfileID,  MD5);
+    cmsMD5finish(&Icc ->ProfileID,  MD5);
     return TRUE;
 
 Error:
 
     // Free resources as something went wrong
< prev index next >