< prev index next >

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

Print this page

        

*** 28,38 **** // file: // //--------------------------------------------------------------------------------- // // Little Color Management System ! // Copyright (c) 1998-2017 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, --- 28,38 ---- // file: // //--------------------------------------------------------------------------------- // // Little Color Management System ! // 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,105 **** #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]) ! { ! register cmsUInt32Number a, b, c, d; a = buf[0]; b = buf[1]; c = buf[2]; d = buf[3]; --- 92,104 ---- #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 cmsMD5_Transform(cmsUInt32Number buf[4], cmsUInt32Number in[16]) { ! CMSREGISTER cmsUInt32Number a, b, c, d; a = buf[0]; b = buf[1]; c = buf[2]; d = buf[3];
*** 178,189 **** buf[3] += d; } // Create a MD5 object ! static ! cmsHANDLE MD5alloc(cmsContext ContextID) { _cmsMD5* ctx = (_cmsMD5*) _cmsMallocZero(ContextID, sizeof(_cmsMD5)); if (ctx == NULL) return NULL; ctx ->ContextID = ContextID; --- 177,188 ---- buf[3] += d; } // Create a MD5 object ! ! cmsHANDLE CMSEXPORT cmsMD5alloc(cmsContext ContextID) { _cmsMD5* ctx = (_cmsMD5*) _cmsMallocZero(ContextID, sizeof(_cmsMD5)); if (ctx == NULL) return NULL; ctx ->ContextID = ContextID;
*** 197,209 **** ctx->bits[1] = 0; return (cmsHANDLE) ctx; } ! ! static ! void MD5add(cmsHANDLE Handle, cmsUInt8Number* buf, cmsUInt32Number len) { _cmsMD5* ctx = (_cmsMD5*) Handle; cmsUInt32Number t; t = ctx->bits[0]; --- 196,206 ---- ctx->bits[1] = 0; return (cmsHANDLE) ctx; } ! void CMSEXPORT cmsMD5add(cmsHANDLE Handle, const cmsUInt8Number* buf, cmsUInt32Number len) { _cmsMD5* ctx = (_cmsMD5*) Handle; cmsUInt32Number t; t = ctx->bits[0];
*** 225,253 **** } memmove(p, buf, t); byteReverse(ctx->in, 16); ! MD5_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); buf += 64; len -= 64; } memmove(ctx->in, buf, len); } // Destroy the object and return the checksum ! static ! void MD5finish(cmsProfileID* ProfileID, cmsHANDLE Handle) { _cmsMD5* ctx = (_cmsMD5*) Handle; cmsUInt32Number count; cmsUInt8Number *p; --- 222,249 ---- } memmove(p, buf, t); byteReverse(ctx->in, 16); ! cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in); buf += t; len -= t; } while (len >= 64) { memmove(ctx->in, buf, 64); byteReverse(ctx->in, 16); ! cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in); buf += 64; len -= 64; } memmove(ctx->in, buf, len); } // Destroy the object and return the checksum ! void CMSEXPORT cmsMD5finish(cmsProfileID* ProfileID, cmsHANDLE Handle) { _cmsMD5* ctx = (_cmsMD5*) Handle; cmsUInt32Number count; cmsUInt8Number *p;
*** 260,281 **** if (count < 8) { memset(p, 0, count); byteReverse(ctx->in, 16); ! MD5_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); byteReverse((cmsUInt8Number *) ctx->buf, 4); memmove(ProfileID ->ID8, ctx->buf, 16); _cmsFree(ctx ->ContextID, ctx); --- 256,277 ---- if (count < 8) { memset(p, 0, count); byteReverse(ctx->in, 16); ! 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]; ! cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in); byteReverse((cmsUInt8Number *) ctx->buf, 4); memmove(ProfileID ->ID8, ctx->buf, 16); _cmsFree(ctx ->ContextID, ctx);
*** 317,340 **** // Save to temporary storage if (!cmsSaveProfileToMem(hProfile, Mem, &BytesNeeded)) goto Error; // Create MD5 object ! MD5 = MD5alloc(ContextID); if (MD5 == NULL) goto Error; // Add all bytes ! MD5add(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); return TRUE; Error: // Free resources as something went wrong --- 313,336 ---- // Save to temporary storage if (!cmsSaveProfileToMem(hProfile, Mem, &BytesNeeded)) goto Error; // Create MD5 object ! MD5 = cmsMD5alloc(ContextID); if (MD5 == NULL) goto Error; // Add all bytes ! cmsMD5add(MD5, Mem, BytesNeeded); // Temp storage is no longer needed _cmsFree(ContextID, Mem); // Restore header memmove(Icc, &Keep, sizeof(_cmsICCPROFILE)); // And store the ID ! cmsMD5finish(&Icc ->ProfileID, MD5); return TRUE; Error: // Free resources as something went wrong
< prev index next >