X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fmono-md5.c;h=5ded45eb9db3d8f4b8d17316df2b83573ea237fc;hb=ad563e4352fcb9631aca8498d66b431bb605f282;hp=c4e0438a0310d2e21bc5bea0ec4c0bf2b3dbf073;hpb=93703b4ef8bdcf1d6cf336e14f534454221730c5;p=mono.git diff --git a/mono/utils/mono-md5.c b/mono/utils/mono-md5.c index c4e0438a031..5ded45eb9db 100644 --- a/mono/utils/mono-md5.c +++ b/mono/utils/mono-md5.c @@ -27,6 +27,28 @@ #include #include "mono-digest.h" +#if HAVE_COMMONCRYPTO_COMMONDIGEST_H + +void +mono_md5_init (MonoMD5Context *ctx) +{ + CC_MD5_Init (ctx); +} + +void +mono_md5_update (MonoMD5Context *ctx, const guchar *buf, guint32 len) +{ + CC_MD5_Update (ctx, buf, len); +} + +void +mono_md5_final (MonoMD5Context *ctx, guchar digest[16]) +{ + CC_MD5_Final (digest, ctx); +} + +#else + static void md5_transform (guint32 buf[4], const guint32 in[16]); static gint _ie = 0x44332211; @@ -295,7 +317,7 @@ md5_transform (guint32 buf[4], const guint32 in[16]) buf[3] += d; } - +#endif /** @@ -326,6 +348,8 @@ mono_md5_get_digest (const guchar *buffer, gint buffer_size, guchar digest[16]) * * Get the md5 hash of a file. The result is put in * the 16 bytes buffer @digest . + * + * If an IO error happens the value in @digest is not updated. **/ void mono_md5_get_digest_from_file (const gchar *filename, guchar digest[16]) @@ -347,6 +371,8 @@ mono_md5_get_digest_from_file (const gchar *filename, guchar digest[16]) if (ferror(fp)) { fclose(fp); return; + } else { + fclose(fp); } mono_md5_final (&ctx, digest);