#include <glib.h>
#include "mono-digest.h"
+#if HAVE_COMMONCRYPTO_COMMONDIGEST_H
-typedef gint32 int32;
-typedef guint32 uint32;
+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 <process.h> */ /* prototype for exit() - JHB */
/* Using return() instead of exit() - SWR */
static void SHA1Transform(guint32 state[5], const guchar buffer[64])
{
-uint32 a, b, c, d, e;
+guint32 a, b, c, d, e;
typedef union {
unsigned char c[64];
- uint32 l[16];
+ guint32 l[16];
} CHAR64LONG16;
CHAR64LONG16* block;
#ifdef SHA1HANDSOFF
void mono_sha1_update(MonoSHA1Context* context, const guchar* data, guint32 len) /*
JHB */
{
-uint32 i, j; /* JHB */
+guint32 i, j; /* JHB */
#ifdef VERBOSE
SHAPrintContext(context, "before");
void mono_sha1_final( MonoSHA1Context* context, unsigned char digest[20])
{
-uint32 i; /* JHB */
+guint32 i; /* JHB */
unsigned char finalcount[8];
for (i = 0; i < 8; i++) {
SHA1Transform(context->state, context->buffer);
#endif
}
+
+#endif
void
-mono_sha1_get_digest (const gchar *buffer, gint buffer_size, guchar digest [20])
+mono_sha1_get_digest (const guchar *buffer, gint buffer_size, guchar digest [20])
{
MonoSHA1Context ctx;
}
+/**
+ * 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])
{