Wed Feb 24 15:50:55 CET 2010 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / utils / mono-sha1.c
index ea36586e3bf7882a16391e912f39a2f0933450bc..ab96e29986d0da3e6599d59b85e330c022100518 100644 (file)
@@ -72,12 +72,10 @@ A million repetitions of "a"
 
 #include <stdio.h>
 #include <string.h>
+#include <glib.h>
 #include "mono-digest.h"
 
 
-typedef          long int int32;
-typedef unsigned long int uint32;
-
 /* #include <process.h> */     /* prototype for exit() - JHB */
 /* Using return() instead of exit() - SWR */
 
@@ -121,10 +119,10 @@ static void SHAPrintContext(MonoSHA1Context *context, char *msg){
 
 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
@@ -191,7 +189,7 @@ void mono_sha1_init(MonoSHA1Context* context)
 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");
@@ -219,7 +217,7 @@ uint32 i, j;        /* JHB */
 
 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++) {
@@ -248,7 +246,7 @@ unsigned char finalcount[8];
 }
  
 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;
 
@@ -258,6 +256,16 @@ mono_sha1_get_digest (const gchar *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])
 {