Only store frame number and not a pointer to frame_data structure in seq_analysis_item_t
[metze/wireshark/wip.git] / wsutil / sha1.c
index 98ad368351220a500dd27cd1d8abadf74fdaaf15..3aaf5570529d6c0aab493f22e4fc96039c90e363 100644 (file)
@@ -1,8 +1,6 @@
 /*
  *  FIPS-180-1 compliant SHA-1 implementation
  *
- *  $Id$
- *
  *  Copyright (C) 2001-2003  Christophe Devine
  *  Copyright (C) 2012       Chris Elston, Katalix Systems Ltd <celston@katalix.com>
  *
@@ -21,7 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  *
  *  Changed to use guint instead of uint 2004 by Anders Broman
- *     Original code found at http://www.cr0.net:8040/code/crypto/sha1/
+ *  Original code found at http://www.cr0.net:8040/code/crypto/sha1/
  *  References: http://www.ietf.org/rfc/rfc3174.txt?number=3174
  *
  *  2012-08-21 - C Elston - Split sha1_hmac function to allow incremental usage.
@@ -31,7 +29,6 @@
 #include <glib.h>
 
 #include "sha1.h"
-#include "file_util.h"
 
 #define GET_UINT32(n,b,i)                       \
 {                                               \
@@ -258,13 +255,13 @@ void sha1_update( sha1_context *ctx, const guint8 *input, guint32 length )
 
 static guint8 sha1_padding[64] =
 {
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
 };
 
-void sha1_finish( sha1_context *ctx, guint8 digest[20] )
+void sha1_finish( sha1_context *ctx, guint8 digest[SHA1_DIGEST_LEN] )
 {
     guint32 last, padn;
     guint32 high, low;
@@ -315,20 +312,20 @@ void sha1_hmac_update( sha1_hmac_context *hctx, const guint8 *buf, guint32 bufle
     sha1_update( &hctx->ctx, buf, buflen );
 }
 
-void sha1_hmac_finish( sha1_hmac_context *hctx, guint8 digest[20] )
+void sha1_hmac_finish( sha1_hmac_context *hctx, guint8 digest[SHA1_DIGEST_LEN] )
 {
-    guint8 tmpbuf[20];
+    guint8 tmpbuf[SHA1_DIGEST_LEN];
 
     sha1_finish( &hctx->ctx, tmpbuf );
 
     sha1_starts( &hctx->ctx );
     sha1_update( &hctx->ctx, hctx->k_opad, 64 );
-    sha1_update( &hctx->ctx, tmpbuf, 20 );
+    sha1_update( &hctx->ctx, tmpbuf, SHA1_DIGEST_LEN );
     sha1_finish( &hctx->ctx, digest );
 }
 
 void sha1_hmac( const guint8 *key, guint32 keylen, const guint8 *buf, guint32 buflen,
-                guint8 digest[20] )
+                guint8 digest[SHA1_DIGEST_LEN] )
 {
     sha1_hmac_context hctx;
 
@@ -341,7 +338,6 @@ void sha1_hmac( const guint8 *key, guint32 keylen, const guint8 *buf, guint32 bu
 
 #include <stdlib.h>
 #include <stdio.h>
-#include <glib.h>
 #include <errno.h>
 
 /*
@@ -369,7 +365,7 @@ int main( int argc, char *argv[] )
     char output[41];
     sha1_context ctx;
     unsigned char buf[1000];
-    unsigned char sha1sum[20];
+    unsigned char sha1sum[SHA1_DIGEST_LEN];
 
     if( argc < 2 )
     {
@@ -398,7 +394,7 @@ int main( int argc, char *argv[] )
 
             sha1_finish( &ctx, sha1sum );
 
-            for( j = 0; j < 20; j++ )
+            for( j = 0; j < SHA1_DIGEST_LEN; j++ )
             {
                 g_snprintf( output + j * 2, 41-j*2, "%02x", sha1sum[j] );
             }
@@ -431,7 +427,7 @@ int main( int argc, char *argv[] )
 
         sha1_finish( &ctx, sha1sum );
 
-        for( j = 0; j < 20; j++ )
+        for( j = 0; j < SHA1_DIGEST_LEN; j++ )
         {
             printf( "%02x", sha1sum[j] );
         }
@@ -444,3 +440,16 @@ int main( int argc, char *argv[] )
 
 #endif
 
+
+/*
+ * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */