X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=mono%2Futils%2Fmono-sha1.c;h=372ef2bcee9fe958c32d98ac2812d7eefc90d62d;hb=390697c8b2e2faf225440dc2b4c8ba73eb4dd85c;hp=8e77fa4af1205c1b9c874204349692ae136237fe;hpb=1c14f1ee6d701510c15499d71fc2b324151a8629;p=mono.git diff --git a/mono/utils/mono-sha1.c b/mono/utils/mono-sha1.c index 8e77fa4af12..372ef2bcee9 100644 --- a/mono/utils/mono-sha1.c +++ b/mono/utils/mono-sha1.c @@ -75,6 +75,27 @@ A million repetitions of "a" #include #include "mono-digest.h" +#if HAVE_COMMONCRYPTO_COMMONDIGEST_H + +void +mono_sha1_init (MonoSHA1Context* context) +{ + CC_SHA1_Init (context); +} + +void +mono_sha1_update (MonoSHA1Context* context, const guchar* data, guint32 len) +{ + CC_SHA1_Update (context, data, len); +} + +void +mono_sha1_final (MonoSHA1Context* context, unsigned char digest[20]) +{ + CC_SHA1_Final (digest, context); +} + +#else /* #include */ /* prototype for exit() - JHB */ /* Using return() instead of exit() - SWR */ @@ -244,6 +265,8 @@ unsigned char finalcount[8]; SHA1Transform(context->state, context->buffer); #endif } + +#endif void mono_sha1_get_digest (const guchar *buffer, gint buffer_size, guchar digest [20]) @@ -256,6 +279,16 @@ mono_sha1_get_digest (const guchar *buffer, gint buffer_size, guchar digest [20] } +/** + * mono_sha1_get_digest_from_file: get the sha1 hash of a file + * @filename: file name + * @digest: 20 bytes buffer receiving the hash code. + * + * Get the sha1 hash of a file. The result is put in + * the 20 bytes buffer @digest . + * + * If an IO error happens the value in @digest is not updated. + **/ void mono_sha1_get_digest_from_file (const gchar *filename, guchar digest [20]) {