summaryrefslogtreecommitdiffstats
path: root/src/sha1.h
diff options
context:
space:
mode:
authorjcsjcs <jcsjcs@f01d2545-417e-4e96-918e-98f8d0dbbcb6>2007-09-24 14:59:33 +0000
committerjcsjcs <jcsjcs@f01d2545-417e-4e96-918e-98f8d0dbbcb6>2007-09-24 14:59:33 +0000
commit3d54de27eddcfa14a5313a22bb09374e8a37aaa8 (patch)
tree4f335a85ef383828ec9d6979fa78fc40a23af043 /src/sha1.h
parent86e1c0ae7a8eac138cce370c2c07cea8c5b6f0a0 (diff)
downloadlibgpod-3d54de27eddcfa14a5313a22bb09374e8a37aaa8.tar.gz
libgpod-3d54de27eddcfa14a5313a22bb09374e8a37aaa8.tar.xz
libgpod-3d54de27eddcfa14a5313a22bb09374e8a37aaa8.zip
** code courtesy of Christophe Fergeau **
* src/itdb_itunesdb.c (mk_mhbd): write extended header needed for new iPod Nanos (3G Video) and iPod Classics. src/itdb_device.c src/itdb_device.h: Code to parse SysInfoExtended and SysInfo for the FireWireGUID. You must either copy the iPod description XML file to Device/SysInfoExtended or add a line 'FirewireGuid: 000A27....' to Device/SysInfo. You can get your FirewireGuid by using the tests/test-fw-id test program. * src/sha1.c src/sha1.h src/itdb_sha1.c src/itdb_sha1.h New files for obscure hash generation code. * src/Makefile.am: added new files. * tests/test-checksum.c tests/test-fw-id.c tests/Makefile.am: test programs to retrieve the FirewireGuid and calculate/write the obscure hash. git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1698 f01d2545-417e-4e96-918e-98f8d0dbbcb6
Diffstat (limited to 'src/sha1.h')
-rw-r--r--src/sha1.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/sha1.h b/src/sha1.h
new file mode 100644
index 0000000..2c8ea66
--- /dev/null
+++ b/src/sha1.h
@@ -0,0 +1,62 @@
+/* NIST Secure Hash Algorithm */
+/* heavily modified by Uwe Hollerbach <uh@alumni.caltech edu> */
+/* from Peter C. Gutmann's implementation as found in */
+/* Applied Cryptography by Bruce Schneier */
+/* This code is in the public domain */
+/* $Id: sha1.h,v 1.1 2005-12-28 18:06:50 tpm Exp $ */
+
+#ifndef __GST_CDDA_SHA_H__
+#define __GST_CDDA_SHA_H__
+
+#include <stdlib.h>
+#include <stdio.h>
+
+/* Useful defines & typedefs */
+typedef unsigned char SHA_BYTE; /* 8-bit quantity */
+typedef unsigned long SHA_LONG; /* 32-or-more-bit quantity */
+
+#define SHA_BLOCKSIZE 64
+#define SHA_DIGESTSIZE 20
+
+typedef struct {
+ SHA_LONG digest[5]; /* message digest */
+ SHA_LONG count_lo, count_hi; /* 64-bit bit count */
+ SHA_BYTE data[SHA_BLOCKSIZE]; /* SHA data buffer */
+ int local; /* unprocessed amount in data */
+} SHA_INFO;
+
+#define sha_init itdb_sha_init
+#define sha_update itdb_sha_update
+#define sha_final itdb_sha_final
+
+G_GNUC_INTERNAL void sha_init(SHA_INFO *);
+G_GNUC_INTERNAL void sha_update(SHA_INFO *, const SHA_BYTE *, int);
+G_GNUC_INTERNAL void sha_final(unsigned char [20], SHA_INFO *);
+
+#define SHA_VERSION 1
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+
+
+#ifdef WORDS_BIGENDIAN
+# if SIZEOF_LONG == 4
+# define SHA_BYTE_ORDER 4321
+# elif SIZEOF_LONG == 8
+# define SHA_BYTE_ORDER 87654321
+# endif
+#else
+# if SIZEOF_LONG == 4
+# define SHA_BYTE_ORDER 1234
+# elif SIZEOF_LONG == 8
+# define SHA_BYTE_ORDER 12345678
+# endif
+#endif
+
+#else
+
+#define SHA_BYTE_ORDER 1234
+
+#endif
+
+#endif /* __GST_CDDA_SHA_H__ */