Move checksumming files to seperate directory
authorJens Axboe <jens.axboe@oracle.com>
Mon, 30 Jul 2007 10:27:58 +0000 (12:27 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 30 Jul 2007 10:27:58 +0000 (12:27 +0200)
Too many of them now, move them out-of-sight. They will rarely
be modified anyway.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
30 files changed:
Makefile
crc/crc16.c [new file with mode: 0644]
crc/crc16.h [new file with mode: 0644]
crc/crc32.c [new file with mode: 0644]
crc/crc32.h [new file with mode: 0644]
crc/crc64.c [new file with mode: 0644]
crc/crc64.h [new file with mode: 0644]
crc/crc7.c [new file with mode: 0644]
crc/crc7.h [new file with mode: 0644]
crc/md5.c [new file with mode: 0644]
crc/md5.h [new file with mode: 0644]
crc/sha256.c [new file with mode: 0644]
crc/sha256.h [new file with mode: 0644]
crc/sha512.c [new file with mode: 0644]
crc/sha512.h [new file with mode: 0644]
crc16.c [deleted file]
crc16.h [deleted file]
crc32.c [deleted file]
crc32.h [deleted file]
crc64.c [deleted file]
crc64.h [deleted file]
crc7.c [deleted file]
crc7.h [deleted file]
md5.c [deleted file]
md5.h [deleted file]
sha256.c [deleted file]
sha256.h [deleted file]
sha512.c [deleted file]
sha512.h [deleted file]
verify.c

index 410cf7c..e6baade 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,10 +5,17 @@ OPTFLAGS= -O2 -g $(EXTFLAGS)
 CFLAGS = -Wwrite-strings -Wall -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(OPTFLAGS) $(DEBUGFLAGS) -rdynamic
 PROGS  = fio
 SCRIPTS = fio_generate_plots
-OBJS = gettime.o fio.o ioengines.o init.o stat.o log.o time.o md5.o crc32.o \
-       crc16.o crc7.o crc64.o sha256.o sha512.o filesetup.o eta.o verify.o \
-       memory.o io_u.o parse.o mutex.o options.o rbtree.o diskutil.o fifo.o \
-       blktrace.o
+OBJS = gettime.o fio.o ioengines.o init.o stat.o log.o time.o filesetup.o \
+       eta.o verify.o memory.o io_u.o parse.o mutex.o options.o rbtree.o \
+       diskutil.o fifo.o blktrace.o
+
+OBJS += crc/crc7.o
+OBJS += crc/crc16.o
+OBJS += crc/crc32.o
+OBJS += crc/crc64.o
+OBJS += crc/sha256.o
+OBJS += crc/sha512.o
+OBJS += crc/md5.o
 
 OBJS += engines/cpu.o
 OBJS += engines/libaio.o
@@ -32,10 +39,10 @@ fio: $(OBJS)
        $(CC) $(CFLAGS) -o $@ $(filter %.o,$^) $(EXTLIBS) -lpthread -lm -ldl -laio -lrt
 
 clean:
-       -rm -f *.o .depend cscope.out $(PROGS) engines/*.o core.* core
+       -rm -f *.o .depend cscope.out $(PROGS) engines/*.o crc/*.o core.* core
 
 depend:
-       @$(CC) -MM $(ALL_CFLAGS) *.c engines/*.c 1> .depend
+       @$(CC) -MM $(ALL_CFLAGS) *.c engines/*.c crc/*.[ch] 1> .depend
 
 cscope:
        @cscope -b
diff --git a/crc/crc16.c b/crc/crc16.c
new file mode 100644 (file)
index 0000000..ac7983a
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *      crc16.c
+ *
+ * This source code is licensed under the GNU General Public License,
+ * Version 2. See the file COPYING for more details.
+ */
+
+#include "crc16.h"
+
+/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */
+unsigned short const crc16_table[256] = {
+       0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
+       0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
+       0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
+       0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
+       0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
+       0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
+       0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
+       0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
+       0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
+       0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
+       0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
+       0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
+       0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
+       0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
+       0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
+       0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
+       0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
+       0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
+       0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
+       0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
+       0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
+       0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
+       0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
+       0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
+       0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
+       0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
+       0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
+       0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
+       0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
+       0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
+       0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
+       0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
+};
+
+unsigned short crc16(unsigned char const *buffer, unsigned int len)
+{
+       unsigned short crc = 0;
+
+       while (len--)
+               crc = crc16_byte(crc, *buffer++);
+       return crc;
+}
diff --git a/crc/crc16.h b/crc/crc16.h
new file mode 100644 (file)
index 0000000..841378d
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *     crc16.h - CRC-16 routine
+ *
+ * Implements the standard CRC-16:
+ *   Width 16
+ *   Poly  0x8005 (x^16 + x^15 + x^2 + 1)
+ *   Init  0
+ *
+ * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
+ *
+ * This source code is licensed under the GNU General Public License,
+ * Version 2. See the file COPYING for more details.
+ */
+
+#ifndef __CRC16_H
+#define __CRC16_H
+
+extern unsigned short const crc16_table[256];
+
+extern unsigned short crc16(const unsigned char *buffer, unsigned int len);
+
+static inline unsigned short crc16_byte(unsigned short crc,
+                                       const unsigned char data)
+{
+       return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
+}
+
+#endif /* __CRC16_H */
diff --git a/crc/crc32.c b/crc/crc32.c
new file mode 100644 (file)
index 0000000..ba6cc06
--- /dev/null
@@ -0,0 +1,84 @@
+/* crc32 -- calculate and POSIX.2 checksum 
+   Copyright (C) 92, 1995-1999 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#include "crc32.h"
+
+static const unsigned long crctab[256] = {
+  0x0,
+  0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B,
+  0x1A864DB2, 0x1E475005, 0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6,
+  0x2B4BCB61, 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD,
+  0x4C11DB70, 0x48D0C6C7, 0x4593E01E, 0x4152FDA9, 0x5F15ADAC,
+  0x5BD4B01B, 0x569796C2, 0x52568B75, 0x6A1936C8, 0x6ED82B7F,
+  0x639B0DA6, 0x675A1011, 0x791D4014, 0x7DDC5DA3, 0x709F7B7A,
+  0x745E66CD, 0x9823B6E0, 0x9CE2AB57, 0x91A18D8E, 0x95609039,
+  0x8B27C03C, 0x8FE6DD8B, 0x82A5FB52, 0x8664E6E5, 0xBE2B5B58,
+  0xBAEA46EF, 0xB7A96036, 0xB3687D81, 0xAD2F2D84, 0xA9EE3033,
+  0xA4AD16EA, 0xA06C0B5D, 0xD4326D90, 0xD0F37027, 0xDDB056FE,
+  0xD9714B49, 0xC7361B4C, 0xC3F706FB, 0xCEB42022, 0xCA753D95,
+  0xF23A8028, 0xF6FB9D9F, 0xFBB8BB46, 0xFF79A6F1, 0xE13EF6F4,
+  0xE5FFEB43, 0xE8BCCD9A, 0xEC7DD02D, 0x34867077, 0x30476DC0,
+  0x3D044B19, 0x39C556AE, 0x278206AB, 0x23431B1C, 0x2E003DC5,
+  0x2AC12072, 0x128E9DCF, 0x164F8078, 0x1B0CA6A1, 0x1FCDBB16,
+  0x018AEB13, 0x054BF6A4, 0x0808D07D, 0x0CC9CDCA, 0x7897AB07,
+  0x7C56B6B0, 0x71159069, 0x75D48DDE, 0x6B93DDDB, 0x6F52C06C,
+  0x6211E6B5, 0x66D0FB02, 0x5E9F46BF, 0x5A5E5B08, 0x571D7DD1,
+  0x53DC6066, 0x4D9B3063, 0x495A2DD4, 0x44190B0D, 0x40D816BA,
+  0xACA5C697, 0xA864DB20, 0xA527FDF9, 0xA1E6E04E, 0xBFA1B04B,
+  0xBB60ADFC, 0xB6238B25, 0xB2E29692, 0x8AAD2B2F, 0x8E6C3698,
+  0x832F1041, 0x87EE0DF6, 0x99A95DF3, 0x9D684044, 0x902B669D,
+  0x94EA7B2A, 0xE0B41DE7, 0xE4750050, 0xE9362689, 0xEDF73B3E,
+  0xF3B06B3B, 0xF771768C, 0xFA325055, 0xFEF34DE2, 0xC6BCF05F,
+  0xC27DEDE8, 0xCF3ECB31, 0xCBFFD686, 0xD5B88683, 0xD1799B34,
+  0xDC3ABDED, 0xD8FBA05A, 0x690CE0EE, 0x6DCDFD59, 0x608EDB80,
+  0x644FC637, 0x7A089632, 0x7EC98B85, 0x738AAD5C, 0x774BB0EB,
+  0x4F040D56, 0x4BC510E1, 0x46863638, 0x42472B8F, 0x5C007B8A,
+  0x58C1663D, 0x558240E4, 0x51435D53, 0x251D3B9E, 0x21DC2629,
+  0x2C9F00F0, 0x285E1D47, 0x36194D42, 0x32D850F5, 0x3F9B762C,
+  0x3B5A6B9B, 0x0315D626, 0x07D4CB91, 0x0A97ED48, 0x0E56F0FF,
+  0x1011A0FA, 0x14D0BD4D, 0x19939B94, 0x1D528623, 0xF12F560E,
+  0xF5EE4BB9, 0xF8AD6D60, 0xFC6C70D7, 0xE22B20D2, 0xE6EA3D65,
+  0xEBA91BBC, 0xEF68060B, 0xD727BBB6, 0xD3E6A601, 0xDEA580D8,
+  0xDA649D6F, 0xC423CD6A, 0xC0E2D0DD, 0xCDA1F604, 0xC960EBB3,
+  0xBD3E8D7E, 0xB9FF90C9, 0xB4BCB610, 0xB07DABA7, 0xAE3AFBA2,
+  0xAAFBE615, 0xA7B8C0CC, 0xA379DD7B, 0x9B3660C6, 0x9FF77D71,
+  0x92B45BA8, 0x9675461F, 0x8832161A, 0x8CF30BAD, 0x81B02D74,
+  0x857130C3, 0x5D8A9099, 0x594B8D2E, 0x5408ABF7, 0x50C9B640,
+  0x4E8EE645, 0x4A4FFBF2, 0x470CDD2B, 0x43CDC09C, 0x7B827D21,
+  0x7F436096, 0x7200464F, 0x76C15BF8, 0x68860BFD, 0x6C47164A,
+  0x61043093, 0x65C52D24, 0x119B4BE9, 0x155A565E, 0x18197087,
+  0x1CD86D30, 0x029F3D35, 0x065E2082, 0x0B1D065B, 0x0FDC1BEC,
+  0x3793A651, 0x3352BBE6, 0x3E119D3F, 0x3AD08088, 0x2497D08D,
+  0x2056CD3A, 0x2D15EBE3, 0x29D4F654, 0xC5A92679, 0xC1683BCE,
+  0xCC2B1D17, 0xC8EA00A0, 0xD6AD50A5, 0xD26C4D12, 0xDF2F6BCB,
+  0xDBEE767C, 0xE3A1CBC1, 0xE760D676, 0xEA23F0AF, 0xEEE2ED18,
+  0xF0A5BD1D, 0xF464A0AA, 0xF9278673, 0xFDE69BC4, 0x89B8FD09,
+  0x8D79E0BE, 0x803AC667, 0x84FBDBD0, 0x9ABC8BD5, 0x9E7D9662,
+  0x933EB0BB, 0x97FFAD0C, 0xAFB010B1, 0xAB710D06, 0xA6322BDF,
+  0xA2F33668, 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4
+};
+
+unsigned long crc32(const void *buffer, unsigned long length)
+{
+       const unsigned char *cp = (const unsigned char *) buffer;
+       unsigned long crc = 0;
+
+       while (length--)
+               crc = (crc << 8) ^ crctab[((crc >> 24) ^ *(cp++)) & 0xFF];
+
+       return crc;
+}
diff --git a/crc/crc32.h b/crc/crc32.h
new file mode 100644 (file)
index 0000000..b7e5eee
--- /dev/null
@@ -0,0 +1,23 @@
+/* crc32 -- calculate and POSIX.2 checksum 
+   Copyright (C) 92, 1995-1999 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef CRC32_H
+#define CRC32_H
+
+extern unsigned long crc32(const void * const, unsigned long);
+
+#endif
diff --git a/crc/crc64.c b/crc/crc64.c
new file mode 100644 (file)
index 0000000..a61d432
--- /dev/null
@@ -0,0 +1,104 @@
+#include "crc64.h"
+
+/*
+ * poly 0x95AC9329AC4BC9B5ULL and init 0xFFFFFFFFFFFFFFFFULL
+ */
+static const unsigned long long crctab64[256] = {
+  0x0000000000000000ULL, 0x7ad870c830358979ULL, 0xf5b0e190606b12f2ULL,
+  0x8f689158505e9b8bULL, 0xc038e5739841b68fULL, 0xbae095bba8743ff6ULL,
+  0x358804e3f82aa47dULL, 0x4f50742bc81f2d04ULL, 0xab28ecb46814fe75ULL,
+  0xd1f09c7c5821770cULL, 0x5e980d24087fec87ULL, 0x24407dec384a65feULL,
+  0x6b1009c7f05548faULL, 0x11c8790fc060c183ULL, 0x9ea0e857903e5a08ULL,
+  0xe478989fa00bd371ULL, 0x7d08ff3b88be6f81ULL, 0x07d08ff3b88be6f8ULL,
+  0x88b81eabe8d57d73ULL, 0xf2606e63d8e0f40aULL, 0xbd301a4810ffd90eULL,
+  0xc7e86a8020ca5077ULL, 0x4880fbd87094cbfcULL, 0x32588b1040a14285ULL,
+  0xd620138fe0aa91f4ULL, 0xacf86347d09f188dULL, 0x2390f21f80c18306ULL,
+  0x594882d7b0f40a7fULL, 0x1618f6fc78eb277bULL, 0x6cc0863448deae02ULL,
+  0xe3a8176c18803589ULL, 0x997067a428b5bcf0ULL, 0xfa11fe77117cdf02ULL,
+  0x80c98ebf2149567bULL, 0x0fa11fe77117cdf0ULL, 0x75796f2f41224489ULL,
+  0x3a291b04893d698dULL, 0x40f16bccb908e0f4ULL, 0xcf99fa94e9567b7fULL,
+  0xb5418a5cd963f206ULL, 0x513912c379682177ULL, 0x2be1620b495da80eULL,
+  0xa489f35319033385ULL, 0xde51839b2936bafcULL, 0x9101f7b0e12997f8ULL,
+  0xebd98778d11c1e81ULL, 0x64b116208142850aULL, 0x1e6966e8b1770c73ULL,
+  0x8719014c99c2b083ULL, 0xfdc17184a9f739faULL, 0x72a9e0dcf9a9a271ULL,
+  0x08719014c99c2b08ULL, 0x4721e43f0183060cULL, 0x3df994f731b68f75ULL,
+  0xb29105af61e814feULL, 0xc849756751dd9d87ULL, 0x2c31edf8f1d64ef6ULL,
+  0x56e99d30c1e3c78fULL, 0xd9810c6891bd5c04ULL, 0xa3597ca0a188d57dULL,
+  0xec09088b6997f879ULL, 0x96d1784359a27100ULL, 0x19b9e91b09fcea8bULL,
+  0x636199d339c963f2ULL, 0xdf7adabd7a6e2d6fULL, 0xa5a2aa754a5ba416ULL,
+  0x2aca3b2d1a053f9dULL, 0x50124be52a30b6e4ULL, 0x1f423fcee22f9be0ULL,
+  0x659a4f06d21a1299ULL, 0xeaf2de5e82448912ULL, 0x902aae96b271006bULL,
+  0x74523609127ad31aULL, 0x0e8a46c1224f5a63ULL, 0x81e2d7997211c1e8ULL,
+  0xfb3aa75142244891ULL, 0xb46ad37a8a3b6595ULL, 0xceb2a3b2ba0eececULL,
+  0x41da32eaea507767ULL, 0x3b024222da65fe1eULL, 0xa2722586f2d042eeULL,
+  0xd8aa554ec2e5cb97ULL, 0x57c2c41692bb501cULL, 0x2d1ab4dea28ed965ULL,
+  0x624ac0f56a91f461ULL, 0x1892b03d5aa47d18ULL, 0x97fa21650afae693ULL,
+  0xed2251ad3acf6feaULL, 0x095ac9329ac4bc9bULL, 0x7382b9faaaf135e2ULL,
+  0xfcea28a2faafae69ULL, 0x8632586aca9a2710ULL, 0xc9622c4102850a14ULL,
+  0xb3ba5c8932b0836dULL, 0x3cd2cdd162ee18e6ULL, 0x460abd1952db919fULL,
+  0x256b24ca6b12f26dULL, 0x5fb354025b277b14ULL, 0xd0dbc55a0b79e09fULL,
+  0xaa03b5923b4c69e6ULL, 0xe553c1b9f35344e2ULL, 0x9f8bb171c366cd9bULL,
+  0x10e3202993385610ULL, 0x6a3b50e1a30ddf69ULL, 0x8e43c87e03060c18ULL,
+  0xf49bb8b633338561ULL, 0x7bf329ee636d1eeaULL, 0x012b592653589793ULL,
+  0x4e7b2d0d9b47ba97ULL, 0x34a35dc5ab7233eeULL, 0xbbcbcc9dfb2ca865ULL,
+  0xc113bc55cb19211cULL, 0x5863dbf1e3ac9decULL, 0x22bbab39d3991495ULL,
+  0xadd33a6183c78f1eULL, 0xd70b4aa9b3f20667ULL, 0x985b3e827bed2b63ULL,
+  0xe2834e4a4bd8a21aULL, 0x6debdf121b863991ULL, 0x1733afda2bb3b0e8ULL,
+  0xf34b37458bb86399ULL, 0x8993478dbb8deae0ULL, 0x06fbd6d5ebd3716bULL,
+  0x7c23a61ddbe6f812ULL, 0x3373d23613f9d516ULL, 0x49aba2fe23cc5c6fULL,
+  0xc6c333a67392c7e4ULL, 0xbc1b436e43a74e9dULL, 0x95ac9329ac4bc9b5ULL,
+  0xef74e3e19c7e40ccULL, 0x601c72b9cc20db47ULL, 0x1ac40271fc15523eULL,
+  0x5594765a340a7f3aULL, 0x2f4c0692043ff643ULL, 0xa02497ca54616dc8ULL,
+  0xdafce7026454e4b1ULL, 0x3e847f9dc45f37c0ULL, 0x445c0f55f46abeb9ULL,
+  0xcb349e0da4342532ULL, 0xb1eceec59401ac4bULL, 0xfebc9aee5c1e814fULL,
+  0x8464ea266c2b0836ULL, 0x0b0c7b7e3c7593bdULL, 0x71d40bb60c401ac4ULL,
+  0xe8a46c1224f5a634ULL, 0x927c1cda14c02f4dULL, 0x1d148d82449eb4c6ULL,
+  0x67ccfd4a74ab3dbfULL, 0x289c8961bcb410bbULL, 0x5244f9a98c8199c2ULL,
+  0xdd2c68f1dcdf0249ULL, 0xa7f41839ecea8b30ULL, 0x438c80a64ce15841ULL,
+  0x3954f06e7cd4d138ULL, 0xb63c61362c8a4ab3ULL, 0xcce411fe1cbfc3caULL,
+  0x83b465d5d4a0eeceULL, 0xf96c151de49567b7ULL, 0x76048445b4cbfc3cULL,
+  0x0cdcf48d84fe7545ULL, 0x6fbd6d5ebd3716b7ULL, 0x15651d968d029fceULL,
+  0x9a0d8ccedd5c0445ULL, 0xe0d5fc06ed698d3cULL, 0xaf85882d2576a038ULL,
+  0xd55df8e515432941ULL, 0x5a3569bd451db2caULL, 0x20ed197575283bb3ULL,
+  0xc49581ead523e8c2ULL, 0xbe4df122e51661bbULL, 0x3125607ab548fa30ULL,
+  0x4bfd10b2857d7349ULL, 0x04ad64994d625e4dULL, 0x7e7514517d57d734ULL,
+  0xf11d85092d094cbfULL, 0x8bc5f5c11d3cc5c6ULL, 0x12b5926535897936ULL,
+  0x686de2ad05bcf04fULL, 0xe70573f555e26bc4ULL, 0x9ddd033d65d7e2bdULL,
+  0xd28d7716adc8cfb9ULL, 0xa85507de9dfd46c0ULL, 0x273d9686cda3dd4bULL,
+  0x5de5e64efd965432ULL, 0xb99d7ed15d9d8743ULL, 0xc3450e196da80e3aULL,
+  0x4c2d9f413df695b1ULL, 0x36f5ef890dc31cc8ULL, 0x79a59ba2c5dc31ccULL,
+  0x037deb6af5e9b8b5ULL, 0x8c157a32a5b7233eULL, 0xf6cd0afa9582aa47ULL,
+  0x4ad64994d625e4daULL, 0x300e395ce6106da3ULL, 0xbf66a804b64ef628ULL,
+  0xc5bed8cc867b7f51ULL, 0x8aeeace74e645255ULL, 0xf036dc2f7e51db2cULL,
+  0x7f5e4d772e0f40a7ULL, 0x05863dbf1e3ac9deULL, 0xe1fea520be311aafULL,
+  0x9b26d5e88e0493d6ULL, 0x144e44b0de5a085dULL, 0x6e963478ee6f8124ULL,
+  0x21c640532670ac20ULL, 0x5b1e309b16452559ULL, 0xd476a1c3461bbed2ULL,
+  0xaeaed10b762e37abULL, 0x37deb6af5e9b8b5bULL, 0x4d06c6676eae0222ULL,
+  0xc26e573f3ef099a9ULL, 0xb8b627f70ec510d0ULL, 0xf7e653dcc6da3dd4ULL,
+  0x8d3e2314f6efb4adULL, 0x0256b24ca6b12f26ULL, 0x788ec2849684a65fULL,
+  0x9cf65a1b368f752eULL, 0xe62e2ad306bafc57ULL, 0x6946bb8b56e467dcULL,
+  0x139ecb4366d1eea5ULL, 0x5ccebf68aecec3a1ULL, 0x2616cfa09efb4ad8ULL,
+  0xa97e5ef8cea5d153ULL, 0xd3a62e30fe90582aULL, 0xb0c7b7e3c7593bd8ULL,
+  0xca1fc72bf76cb2a1ULL, 0x45775673a732292aULL, 0x3faf26bb9707a053ULL,
+  0x70ff52905f188d57ULL, 0x0a2722586f2d042eULL, 0x854fb3003f739fa5ULL,
+  0xff97c3c80f4616dcULL, 0x1bef5b57af4dc5adULL, 0x61372b9f9f784cd4ULL,
+  0xee5fbac7cf26d75fULL, 0x9487ca0fff135e26ULL, 0xdbd7be24370c7322ULL,
+  0xa10fceec0739fa5bULL, 0x2e675fb4576761d0ULL, 0x54bf2f7c6752e8a9ULL,
+  0xcdcf48d84fe75459ULL, 0xb71738107fd2dd20ULL, 0x387fa9482f8c46abULL,
+  0x42a7d9801fb9cfd2ULL, 0x0df7adabd7a6e2d6ULL, 0x772fdd63e7936bafULL,
+  0xf8474c3bb7cdf024ULL, 0x829f3cf387f8795dULL, 0x66e7a46c27f3aa2cULL,
+  0x1c3fd4a417c62355ULL, 0x935745fc4798b8deULL, 0xe98f353477ad31a7ULL,
+  0xa6df411fbfb21ca3ULL, 0xdc0731d78f8795daULL, 0x536fa08fdfd90e51ULL,
+  0x29b7d047efec8728ULL
+};
+
+unsigned long long crc64(const unsigned char *buffer, unsigned long length)
+{
+       unsigned long long crc = 0;
+
+       while (length--)
+               crc = crctab64[(crc ^ *(buffer++)) & 0xff] ^ (crc >> 8);
+
+       return crc;
+}
+
diff --git a/crc/crc64.h b/crc/crc64.h
new file mode 100644 (file)
index 0000000..e4310c2
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef CRC64_H
+#define CRC64_H
+
+unsigned long long crc64(const unsigned char *, unsigned long);
+
+#endif
diff --git a/crc/crc7.c b/crc/crc7.c
new file mode 100644 (file)
index 0000000..47aa332
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *      crc7.c
+ *
+ * This source code is licensed under the GNU General Public License,
+ * Version 2. See the file COPYING for more details.
+ */
+
+#include "crc7.h"
+
+/* Table for CRC-7 (polynomial x^7 + x^3 + 1) */
+const unsigned char crc7_syndrome_table[256] = {
+       0x00, 0x09, 0x12, 0x1b, 0x24, 0x2d, 0x36, 0x3f,
+       0x48, 0x41, 0x5a, 0x53, 0x6c, 0x65, 0x7e, 0x77,
+       0x19, 0x10, 0x0b, 0x02, 0x3d, 0x34, 0x2f, 0x26,
+       0x51, 0x58, 0x43, 0x4a, 0x75, 0x7c, 0x67, 0x6e,
+       0x32, 0x3b, 0x20, 0x29, 0x16, 0x1f, 0x04, 0x0d,
+       0x7a, 0x73, 0x68, 0x61, 0x5e, 0x57, 0x4c, 0x45,
+       0x2b, 0x22, 0x39, 0x30, 0x0f, 0x06, 0x1d, 0x14,
+       0x63, 0x6a, 0x71, 0x78, 0x47, 0x4e, 0x55, 0x5c,
+       0x64, 0x6d, 0x76, 0x7f, 0x40, 0x49, 0x52, 0x5b,
+       0x2c, 0x25, 0x3e, 0x37, 0x08, 0x01, 0x1a, 0x13,
+       0x7d, 0x74, 0x6f, 0x66, 0x59, 0x50, 0x4b, 0x42,
+       0x35, 0x3c, 0x27, 0x2e, 0x11, 0x18, 0x03, 0x0a,
+       0x56, 0x5f, 0x44, 0x4d, 0x72, 0x7b, 0x60, 0x69,
+       0x1e, 0x17, 0x0c, 0x05, 0x3a, 0x33, 0x28, 0x21,
+       0x4f, 0x46, 0x5d, 0x54, 0x6b, 0x62, 0x79, 0x70,
+       0x07, 0x0e, 0x15, 0x1c, 0x23, 0x2a, 0x31, 0x38,
+       0x41, 0x48, 0x53, 0x5a, 0x65, 0x6c, 0x77, 0x7e,
+       0x09, 0x00, 0x1b, 0x12, 0x2d, 0x24, 0x3f, 0x36,
+       0x58, 0x51, 0x4a, 0x43, 0x7c, 0x75, 0x6e, 0x67,
+       0x10, 0x19, 0x02, 0x0b, 0x34, 0x3d, 0x26, 0x2f,
+       0x73, 0x7a, 0x61, 0x68, 0x57, 0x5e, 0x45, 0x4c,
+       0x3b, 0x32, 0x29, 0x20, 0x1f, 0x16, 0x0d, 0x04,
+       0x6a, 0x63, 0x78, 0x71, 0x4e, 0x47, 0x5c, 0x55,
+       0x22, 0x2b, 0x30, 0x39, 0x06, 0x0f, 0x14, 0x1d,
+       0x25, 0x2c, 0x37, 0x3e, 0x01, 0x08, 0x13, 0x1a,
+       0x6d, 0x64, 0x7f, 0x76, 0x49, 0x40, 0x5b, 0x52,
+       0x3c, 0x35, 0x2e, 0x27, 0x18, 0x11, 0x0a, 0x03,
+       0x74, 0x7d, 0x66, 0x6f, 0x50, 0x59, 0x42, 0x4b,
+       0x17, 0x1e, 0x05, 0x0c, 0x33, 0x3a, 0x21, 0x28,
+       0x5f, 0x56, 0x4d, 0x44, 0x7b, 0x72, 0x69, 0x60,
+       0x0e, 0x07, 0x1c, 0x15, 0x2a, 0x23, 0x38, 0x31,
+       0x46, 0x4f, 0x54, 0x5d, 0x62, 0x6b, 0x70, 0x79
+};
+
+unsigned char crc7(const unsigned char *buffer, unsigned int len)
+{
+       unsigned char crc = 0;
+
+       while (len--)
+               crc = crc7_byte(crc, *buffer++);
+       return crc;
+}
diff --git a/crc/crc7.h b/crc/crc7.h
new file mode 100644 (file)
index 0000000..6ff3cd8
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef CRC7_H
+#define CRC7_H
+
+extern const unsigned char crc7_syndrome_table[256];
+
+static inline unsigned char crc7_byte(unsigned char crc, unsigned char data)
+{
+       return crc7_syndrome_table[(crc << 1) ^ data];
+}
+
+extern unsigned char crc7(const unsigned char *buffer, unsigned int len);
+
+#endif
diff --git a/crc/md5.c b/crc/md5.c
new file mode 100644 (file)
index 0000000..8f9adb2
--- /dev/null
+++ b/crc/md5.c
@@ -0,0 +1,126 @@
+/*
+ * Shamelessly lifted from the 2.6 kernel (crypto/md5.c)
+ */
+#include <string.h>
+#include <stdint.h>
+#include "md5.h"
+
+static void md5_transform(uint32_t *hash, uint32_t const *in)
+{
+       uint32_t a, b, c, d;
+
+       a = hash[0];
+       b = hash[1];
+       c = hash[2];
+       d = hash[3];
+
+       MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
+       MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
+       MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
+       MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
+       MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
+       MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
+       MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
+       MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
+       MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
+       MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
+       MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
+       MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
+       MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
+       MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
+       MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
+       MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
+
+       MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
+       MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
+       MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
+       MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
+       MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
+       MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
+       MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
+       MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
+       MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
+       MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
+       MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
+       MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
+       MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
+       MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
+       MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
+       MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
+
+       MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
+       MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
+       MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
+       MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
+       MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
+       MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
+       MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
+       MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
+       MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
+       MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
+       MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
+       MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
+       MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
+       MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
+       MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
+       MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
+
+       MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
+       MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
+       MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
+       MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
+       MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
+       MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
+       MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
+       MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
+       MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
+       MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
+       MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
+       MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
+       MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
+       MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
+       MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
+       MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
+
+       hash[0] += a;
+       hash[1] += b;
+       hash[2] += c;
+       hash[3] += d;
+}
+
+void md5_init(struct md5_ctx *mctx)
+{
+       mctx->hash[0] = 0x67452301;
+       mctx->hash[1] = 0xefcdab89;
+       mctx->hash[2] = 0x98badcfe;
+       mctx->hash[3] = 0x10325476;
+}
+
+void md5_update(struct md5_ctx *mctx, const uint8_t *data, unsigned int len)
+{
+       const uint32_t avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
+
+       mctx->byte_count += len;
+
+       if (avail > len) {
+               memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
+                      data, len);
+               return;
+       }
+
+       memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
+              data, avail);
+
+       md5_transform(mctx->hash, mctx->block);
+       data += avail;
+       len -= avail;
+
+       while (len >= sizeof(mctx->block)) {
+               memcpy(mctx->block, data, sizeof(mctx->block));
+               md5_transform(mctx->hash, mctx->block);
+               data += sizeof(mctx->block);
+               len -= sizeof(mctx->block);
+       }
+
+       memcpy(mctx->block, data, len);
+}
diff --git a/crc/md5.h b/crc/md5.h
new file mode 100644 (file)
index 0000000..6747d30
--- /dev/null
+++ b/crc/md5.h
@@ -0,0 +1,28 @@
+#ifndef MD5_H
+#define MD5_H
+
+#include <stdint.h>
+
+#define MD5_DIGEST_SIZE                16
+#define MD5_HMAC_BLOCK_SIZE    64
+#define MD5_BLOCK_WORDS                16
+#define MD5_HASH_WORDS         4
+
+#define F1(x, y, z)    (z ^ (x & (y ^ z)))
+#define F2(x, y, z)    F1(z, x, y)
+#define F3(x, y, z)    (x ^ y ^ z)
+#define F4(x, y, z)    (y ^ (x | ~z))
+
+#define MD5STEP(f, w, x, y, z, in, s) \
+       (w += f(x, y, z) + in, w = (w<<s | w>>(32-s)) + x)
+
+struct md5_ctx {
+       uint32_t *hash;
+       uint32_t block[MD5_BLOCK_WORDS];
+       uint64_t byte_count;
+};
+
+extern void md5_update(struct md5_ctx *, const uint8_t *, unsigned int);
+extern void md5_init(struct md5_ctx *);
+
+#endif
diff --git a/crc/sha256.c b/crc/sha256.c
new file mode 100644 (file)
index 0000000..8ec2943
--- /dev/null
@@ -0,0 +1,280 @@
+/*
+ * Cryptographic API.
+ *
+ * SHA-256, as specified in
+ * http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf
+ *
+ * SHA-256 code by Jean-Luc Cooke <jlcooke@certainkey.com>.
+ *
+ * Copyright (c) Jean-Luc Cooke <jlcooke@certainkey.com>
+ * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option) 
+ * any later version.
+ *
+ */
+#include <string.h>
+#include <inttypes.h>
+#include <byteswap.h>
+#include <endian.h>
+
+#include "sha256.h"
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define        __be32_to_cpu(x)        __bswap_32(x)
+#else
+#define __be32_to_cpu(x)       (x)
+#endif
+
+#define SHA256_DIGEST_SIZE     32
+#define SHA256_HMAC_BLOCK_SIZE 64
+
+static inline uint32_t Ch(uint32_t x, uint32_t y, uint32_t z)
+{
+       return z ^ (x & (y ^ z));
+}
+
+static inline uint32_t Maj(uint32_t x, uint32_t y, uint32_t z)
+{
+       return (x & y) | (z & (x | y));
+}
+
+#define e0(x)       (ror32(x, 2) ^ ror32(x,13) ^ ror32(x,22))
+#define e1(x)       (ror32(x, 6) ^ ror32(x,11) ^ ror32(x,25))
+#define s0(x)       (ror32(x, 7) ^ ror32(x,18) ^ (x >> 3))
+#define s1(x)       (ror32(x,17) ^ ror32(x,19) ^ (x >> 10))
+
+#define H0         0x6a09e667
+#define H1         0xbb67ae85
+#define H2         0x3c6ef372
+#define H3         0xa54ff53a
+#define H4         0x510e527f
+#define H5         0x9b05688c
+#define H6         0x1f83d9ab
+#define H7         0x5be0cd19
+
+static inline uint32_t ror32(uint32_t word, unsigned int shift)
+{
+        return (word >> shift) | (word << (32 - shift));
+}
+
+static inline void LOAD_OP(int I, uint32_t *W, const uint8_t *input)
+{
+       W[I] = __be32_to_cpu(((uint32_t *)(input))[I]);
+}
+
+static inline void BLEND_OP(int I, uint32_t *W)
+{
+       W[I] = s1(W[I-2]) + W[I-7] + s0(W[I-15]) + W[I-16];
+}
+
+static void sha256_transform(uint32_t *state, const uint8_t *input)
+{
+       uint32_t a, b, c, d, e, f, g, h, t1, t2;
+       uint32_t W[64];
+       int i;
+
+       /* load the input */
+       for (i = 0; i < 16; i++)
+               LOAD_OP(i, W, input);
+
+       /* now blend */
+       for (i = 16; i < 64; i++)
+               BLEND_OP(i, W);
+
+       /* load the state into our registers */
+       a=state[0];  b=state[1];  c=state[2];  d=state[3];
+       e=state[4];  f=state[5];  g=state[6];  h=state[7];
+
+       /* now iterate */
+       t1 = h + e1(e) + Ch(e,f,g) + 0x428a2f98 + W[ 0];
+       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
+       t1 = g + e1(d) + Ch(d,e,f) + 0x71374491 + W[ 1];
+       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
+       t1 = f + e1(c) + Ch(c,d,e) + 0xb5c0fbcf + W[ 2];
+       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
+       t1 = e + e1(b) + Ch(b,c,d) + 0xe9b5dba5 + W[ 3];
+       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
+       t1 = d + e1(a) + Ch(a,b,c) + 0x3956c25b + W[ 4];
+       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
+       t1 = c + e1(h) + Ch(h,a,b) + 0x59f111f1 + W[ 5];
+       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
+       t1 = b + e1(g) + Ch(g,h,a) + 0x923f82a4 + W[ 6];
+       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
+       t1 = a + e1(f) + Ch(f,g,h) + 0xab1c5ed5 + W[ 7];
+       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
+
+       t1 = h + e1(e) + Ch(e,f,g) + 0xd807aa98 + W[ 8];
+       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
+       t1 = g + e1(d) + Ch(d,e,f) + 0x12835b01 + W[ 9];
+       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
+       t1 = f + e1(c) + Ch(c,d,e) + 0x243185be + W[10];
+       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
+       t1 = e + e1(b) + Ch(b,c,d) + 0x550c7dc3 + W[11];
+       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
+       t1 = d + e1(a) + Ch(a,b,c) + 0x72be5d74 + W[12];
+       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
+       t1 = c + e1(h) + Ch(h,a,b) + 0x80deb1fe + W[13];
+       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
+       t1 = b + e1(g) + Ch(g,h,a) + 0x9bdc06a7 + W[14];
+       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
+       t1 = a + e1(f) + Ch(f,g,h) + 0xc19bf174 + W[15];
+       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
+
+       t1 = h + e1(e) + Ch(e,f,g) + 0xe49b69c1 + W[16];
+       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
+       t1 = g + e1(d) + Ch(d,e,f) + 0xefbe4786 + W[17];
+       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
+       t1 = f + e1(c) + Ch(c,d,e) + 0x0fc19dc6 + W[18];
+       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
+       t1 = e + e1(b) + Ch(b,c,d) + 0x240ca1cc + W[19];
+       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
+       t1 = d + e1(a) + Ch(a,b,c) + 0x2de92c6f + W[20];
+       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
+       t1 = c + e1(h) + Ch(h,a,b) + 0x4a7484aa + W[21];
+       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
+       t1 = b + e1(g) + Ch(g,h,a) + 0x5cb0a9dc + W[22];
+       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
+       t1 = a + e1(f) + Ch(f,g,h) + 0x76f988da + W[23];
+       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
+
+       t1 = h + e1(e) + Ch(e,f,g) + 0x983e5152 + W[24];
+       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
+       t1 = g + e1(d) + Ch(d,e,f) + 0xa831c66d + W[25];
+       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
+       t1 = f + e1(c) + Ch(c,d,e) + 0xb00327c8 + W[26];
+       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
+       t1 = e + e1(b) + Ch(b,c,d) + 0xbf597fc7 + W[27];
+       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
+       t1 = d + e1(a) + Ch(a,b,c) + 0xc6e00bf3 + W[28];
+       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
+       t1 = c + e1(h) + Ch(h,a,b) + 0xd5a79147 + W[29];
+       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
+       t1 = b + e1(g) + Ch(g,h,a) + 0x06ca6351 + W[30];
+       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
+       t1 = a + e1(f) + Ch(f,g,h) + 0x14292967 + W[31];
+       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
+
+       t1 = h + e1(e) + Ch(e,f,g) + 0x27b70a85 + W[32];
+       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
+       t1 = g + e1(d) + Ch(d,e,f) + 0x2e1b2138 + W[33];
+       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
+       t1 = f + e1(c) + Ch(c,d,e) + 0x4d2c6dfc + W[34];
+       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
+       t1 = e + e1(b) + Ch(b,c,d) + 0x53380d13 + W[35];
+       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
+       t1 = d + e1(a) + Ch(a,b,c) + 0x650a7354 + W[36];
+       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
+       t1 = c + e1(h) + Ch(h,a,b) + 0x766a0abb + W[37];
+       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
+       t1 = b + e1(g) + Ch(g,h,a) + 0x81c2c92e + W[38];
+       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
+       t1 = a + e1(f) + Ch(f,g,h) + 0x92722c85 + W[39];
+       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
+
+       t1 = h + e1(e) + Ch(e,f,g) + 0xa2bfe8a1 + W[40];
+       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
+       t1 = g + e1(d) + Ch(d,e,f) + 0xa81a664b + W[41];
+       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
+       t1 = f + e1(c) + Ch(c,d,e) + 0xc24b8b70 + W[42];
+       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
+       t1 = e + e1(b) + Ch(b,c,d) + 0xc76c51a3 + W[43];
+       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
+       t1 = d + e1(a) + Ch(a,b,c) + 0xd192e819 + W[44];
+       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
+       t1 = c + e1(h) + Ch(h,a,b) + 0xd6990624 + W[45];
+       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
+       t1 = b + e1(g) + Ch(g,h,a) + 0xf40e3585 + W[46];
+       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
+       t1 = a + e1(f) + Ch(f,g,h) + 0x106aa070 + W[47];
+       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
+
+       t1 = h + e1(e) + Ch(e,f,g) + 0x19a4c116 + W[48];
+       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
+       t1 = g + e1(d) + Ch(d,e,f) + 0x1e376c08 + W[49];
+       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
+       t1 = f + e1(c) + Ch(c,d,e) + 0x2748774c + W[50];
+       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
+       t1 = e + e1(b) + Ch(b,c,d) + 0x34b0bcb5 + W[51];
+       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
+       t1 = d + e1(a) + Ch(a,b,c) + 0x391c0cb3 + W[52];
+       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
+       t1 = c + e1(h) + Ch(h,a,b) + 0x4ed8aa4a + W[53];
+       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
+       t1 = b + e1(g) + Ch(g,h,a) + 0x5b9cca4f + W[54];
+       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
+       t1 = a + e1(f) + Ch(f,g,h) + 0x682e6ff3 + W[55];
+       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
+
+       t1 = h + e1(e) + Ch(e,f,g) + 0x748f82ee + W[56];
+       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
+       t1 = g + e1(d) + Ch(d,e,f) + 0x78a5636f + W[57];
+       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
+       t1 = f + e1(c) + Ch(c,d,e) + 0x84c87814 + W[58];
+       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
+       t1 = e + e1(b) + Ch(b,c,d) + 0x8cc70208 + W[59];
+       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
+       t1 = d + e1(a) + Ch(a,b,c) + 0x90befffa + W[60];
+       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
+       t1 = c + e1(h) + Ch(h,a,b) + 0xa4506ceb + W[61];
+       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
+       t1 = b + e1(g) + Ch(g,h,a) + 0xbef9a3f7 + W[62];
+       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
+       t1 = a + e1(f) + Ch(f,g,h) + 0xc67178f2 + W[63];
+       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
+
+       state[0] += a; state[1] += b; state[2] += c; state[3] += d;
+       state[4] += e; state[5] += f; state[6] += g; state[7] += h;
+
+       /* clear any sensitive info... */
+       a = b = c = d = e = f = g = h = t1 = t2 = 0;
+       memset(W, 0, 64 * sizeof(uint32_t));
+}
+
+void sha256_init(struct sha256_ctx *sctx)
+{
+       sctx->state[0] = H0;
+       sctx->state[1] = H1;
+       sctx->state[2] = H2;
+       sctx->state[3] = H3;
+       sctx->state[4] = H4;
+       sctx->state[5] = H5;
+       sctx->state[6] = H6;
+       sctx->state[7] = H7;
+       sctx->count[0] = sctx->count[1] = 0;
+}
+
+void sha256_update(struct sha256_ctx *sctx, const uint8_t *data,
+                  unsigned int len)
+{
+       unsigned int i, index, part_len;
+
+       /* Compute number of bytes mod 128 */
+       index = (unsigned int)((sctx->count[0] >> 3) & 0x3f);
+
+       /* Update number of bits */
+       if ((sctx->count[0] += (len << 3)) < (len << 3)) {
+               sctx->count[1]++;
+               sctx->count[1] += (len >> 29);
+       }
+
+       part_len = 64 - index;
+
+       /* Transform as many times as possible. */
+       if (len >= part_len) {
+               memcpy(&sctx->buf[index], data, part_len);
+               sha256_transform(sctx->state, sctx->buf);
+
+               for (i = part_len; i + 63 < len; i += 64)
+                       sha256_transform(sctx->state, &data[i]);
+               index = 0;
+       } else {
+               i = 0;
+       }
+       
+       /* Buffer remaining input */
+       memcpy(&sctx->buf[index], &data[i], len-i);
+}
diff --git a/crc/sha256.h b/crc/sha256.h
new file mode 100644 (file)
index 0000000..a3ca0e6
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef FIO_SHA256_H
+#define FIO_SHA256_H
+
+struct sha256_ctx {
+       uint32_t count[2];
+       uint32_t state[8];
+       uint8_t *buf;
+};
+
+void sha256_init(struct sha256_ctx *);
+void sha256_update(struct sha256_ctx *, const uint8_t *, unsigned int);
+
+#endif
diff --git a/crc/sha512.c b/crc/sha512.c
new file mode 100644 (file)
index 0000000..1f9ebb4
--- /dev/null
@@ -0,0 +1,205 @@
+/* SHA-512 code by Jean-Luc Cooke <jlcooke@certainkey.com>
+ *
+ * Copyright (c) Jean-Luc Cooke <jlcooke@certainkey.com>
+ * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
+ * Copyright (c) 2003 Kyle McMartin <kyle@debian.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ */
+
+#include <string.h>
+#include <inttypes.h>
+#include <byteswap.h>
+#include <endian.h>
+
+#include "sha512.h"
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define        __be64_to_cpu(x)        __bswap_64(x)
+#else
+#define __be64_to_cpu(x)       (x)
+#endif
+
+#define SHA384_DIGEST_SIZE 48
+#define SHA512_DIGEST_SIZE 64
+#define SHA384_HMAC_BLOCK_SIZE 128
+#define SHA512_HMAC_BLOCK_SIZE 128
+
+static inline uint64_t Ch(uint64_t x, uint64_t y, uint64_t z)
+{
+        return z ^ (x & (y ^ z));
+}
+
+static inline uint64_t Maj(uint64_t x, uint64_t y, uint64_t z)
+{
+        return (x & y) | (z & (x | y));
+}
+
+static inline uint64_t RORuint64_t(uint64_t x, uint64_t y)
+{
+        return (x >> y) | (x << (64 - y));
+}
+
+static const uint64_t sha512_K[80] = {
+        0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL,
+        0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
+        0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, 0xd807aa98a3030242ULL,
+        0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
+        0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL,
+        0xc19bf174cf692694ULL, 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL,
+        0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, 0x2de92c6f592b0275ULL,
+        0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
+        0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL,
+        0xbf597fc7beef0ee4ULL, 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL,
+        0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, 0x27b70a8546d22ffcULL,
+        0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL,
+        0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL,
+        0x92722c851482353bULL, 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL,
+        0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, 0xd192e819d6ef5218ULL,
+        0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
+        0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL,
+        0x34b0bcb5e19b48a8ULL, 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL,
+        0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, 0x748f82ee5defb2fcULL,
+        0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL,
+        0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL,
+        0xc67178f2e372532bULL, 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL,
+        0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, 0x06f067aa72176fbaULL,
+        0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
+        0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL,
+        0x431d67c49c100d4cULL, 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
+        0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL,
+};
+
+#define e0(x)       (RORuint64_t(x,28) ^ RORuint64_t(x,34) ^ RORuint64_t(x,39))
+#define e1(x)       (RORuint64_t(x,14) ^ RORuint64_t(x,18) ^ RORuint64_t(x,41))
+#define s0(x)       (RORuint64_t(x, 1) ^ RORuint64_t(x, 8) ^ (x >> 7))
+#define s1(x)       (RORuint64_t(x,19) ^ RORuint64_t(x,61) ^ (x >> 6))
+
+/* H* initial state for SHA-512 */
+#define H0         0x6a09e667f3bcc908ULL
+#define H1         0xbb67ae8584caa73bULL
+#define H2         0x3c6ef372fe94f82bULL
+#define H3         0xa54ff53a5f1d36f1ULL
+#define H4         0x510e527fade682d1ULL
+#define H5         0x9b05688c2b3e6c1fULL
+#define H6         0x1f83d9abfb41bd6bULL
+#define H7         0x5be0cd19137e2179ULL
+
+/* H'* initial state for SHA-384 */
+#define HP0 0xcbbb9d5dc1059ed8ULL
+#define HP1 0x629a292a367cd507ULL
+#define HP2 0x9159015a3070dd17ULL
+#define HP3 0x152fecd8f70e5939ULL
+#define HP4 0x67332667ffc00b31ULL
+#define HP5 0x8eb44a8768581511ULL
+#define HP6 0xdb0c2e0d64f98fa7ULL
+#define HP7 0x47b5481dbefa4fa4ULL
+
+static inline void LOAD_OP(int I, uint64_t *W, const uint8_t *input)
+{
+       W[I] = __be64_to_cpu( ((uint64_t *)(input))[I] );
+}
+
+static inline void BLEND_OP(int I, uint64_t *W)
+{
+       W[I] = s1(W[I-2]) + W[I-7] + s0(W[I-15]) + W[I-16];
+}
+
+static void sha512_transform(uint64_t *state, uint64_t *W, const uint8_t *input)
+{
+       uint64_t a, b, c, d, e, f, g, h, t1, t2;
+
+       int i;
+
+       /* load the input */
+       for (i = 0; i < 16; i++)
+               LOAD_OP(i, W, input);
+
+       for (i = 16; i < 80; i++)
+               BLEND_OP(i, W);
+
+       /* load the state into our registers */
+       a=state[0];   b=state[1];   c=state[2];   d=state[3];
+       e=state[4];   f=state[5];   g=state[6];   h=state[7];
+
+       /* now iterate */
+       for (i=0; i<80; i+=8) {
+               t1 = h + e1(e) + Ch(e,f,g) + sha512_K[i  ] + W[i  ];
+               t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
+               t1 = g + e1(d) + Ch(d,e,f) + sha512_K[i+1] + W[i+1];
+               t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
+               t1 = f + e1(c) + Ch(c,d,e) + sha512_K[i+2] + W[i+2];
+               t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
+               t1 = e + e1(b) + Ch(b,c,d) + sha512_K[i+3] + W[i+3];
+               t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
+               t1 = d + e1(a) + Ch(a,b,c) + sha512_K[i+4] + W[i+4];
+               t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
+               t1 = c + e1(h) + Ch(h,a,b) + sha512_K[i+5] + W[i+5];
+               t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
+               t1 = b + e1(g) + Ch(g,h,a) + sha512_K[i+6] + W[i+6];
+               t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
+               t1 = a + e1(f) + Ch(f,g,h) + sha512_K[i+7] + W[i+7];
+               t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
+       }
+
+       state[0] += a; state[1] += b; state[2] += c; state[3] += d;
+       state[4] += e; state[5] += f; state[6] += g; state[7] += h;
+
+       /* erase our data */
+       a = b = c = d = e = f = g = h = t1 = t2 = 0;
+}
+
+void sha512_init(struct sha512_ctx *sctx)
+{
+       sctx->state[0] = H0;
+       sctx->state[1] = H1;
+       sctx->state[2] = H2;
+       sctx->state[3] = H3;
+       sctx->state[4] = H4;
+       sctx->state[5] = H5;
+       sctx->state[6] = H6;
+       sctx->state[7] = H7;
+       sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0;
+}
+
+void sha512_update(struct sha512_ctx *sctx, const uint8_t *data,
+                  unsigned int len)
+{
+       unsigned int i, index, part_len;
+
+       /* Compute number of bytes mod 128 */
+       index = (unsigned int)((sctx->count[0] >> 3) & 0x7F);
+       
+       /* Update number of bits */
+       if ((sctx->count[0] += (len << 3)) < (len << 3)) {
+               if ((sctx->count[1] += 1) < 1)
+                       if ((sctx->count[2] += 1) < 1)
+                               sctx->count[3]++;
+               sctx->count[1] += (len >> 29);
+       }
+       
+        part_len = 128 - index;
+       
+       /* Transform as many times as possible. */
+       if (len >= part_len) {
+               memcpy(&sctx->buf[index], data, part_len);
+               sha512_transform(sctx->state, sctx->W, sctx->buf);
+
+               for (i = part_len; i + 127 < len; i+=128)
+                       sha512_transform(sctx->state, sctx->W, &data[i]);
+
+               index = 0;
+       } else {
+               i = 0;
+       }
+
+       /* Buffer remaining input */
+       memcpy(&sctx->buf[index], &data[i], len - i);
+
+       /* erase our data */
+       memset(sctx->W, 0, sizeof(sctx->W));
+}
diff --git a/crc/sha512.h b/crc/sha512.h
new file mode 100644 (file)
index 0000000..46e10cb
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef FIO_SHA512_H
+#define FIO_SHA512_H
+
+struct sha512_ctx {
+       uint64_t state[8];
+       uint32_t count[4];
+       uint8_t *buf;
+       uint64_t W[80];
+};
+
+void sha512_init(struct sha512_ctx *);
+void sha512_update(struct sha512_ctx *, const uint8_t *, unsigned int);
+
+#endif
diff --git a/crc16.c b/crc16.c
deleted file mode 100644 (file)
index ac7983a..0000000
--- a/crc16.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *      crc16.c
- *
- * This source code is licensed under the GNU General Public License,
- * Version 2. See the file COPYING for more details.
- */
-
-#include "crc16.h"
-
-/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */
-unsigned short const crc16_table[256] = {
-       0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
-       0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
-       0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
-       0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
-       0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
-       0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
-       0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
-       0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
-       0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
-       0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
-       0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
-       0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
-       0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
-       0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
-       0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
-       0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
-       0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
-       0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
-       0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
-       0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
-       0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
-       0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
-       0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
-       0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
-       0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
-       0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
-       0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
-       0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
-       0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
-       0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
-       0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
-       0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
-};
-
-unsigned short crc16(unsigned char const *buffer, unsigned int len)
-{
-       unsigned short crc = 0;
-
-       while (len--)
-               crc = crc16_byte(crc, *buffer++);
-       return crc;
-}
diff --git a/crc16.h b/crc16.h
deleted file mode 100644 (file)
index 841378d..0000000
--- a/crc16.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *     crc16.h - CRC-16 routine
- *
- * Implements the standard CRC-16:
- *   Width 16
- *   Poly  0x8005 (x^16 + x^15 + x^2 + 1)
- *   Init  0
- *
- * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
- *
- * This source code is licensed under the GNU General Public License,
- * Version 2. See the file COPYING for more details.
- */
-
-#ifndef __CRC16_H
-#define __CRC16_H
-
-extern unsigned short const crc16_table[256];
-
-extern unsigned short crc16(const unsigned char *buffer, unsigned int len);
-
-static inline unsigned short crc16_byte(unsigned short crc,
-                                       const unsigned char data)
-{
-       return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
-}
-
-#endif /* __CRC16_H */
diff --git a/crc32.c b/crc32.c
deleted file mode 100644 (file)
index ba6cc06..0000000
--- a/crc32.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* crc32 -- calculate and POSIX.2 checksum 
-   Copyright (C) 92, 1995-1999 Free Software Foundation, Inc.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software Foundation,
-   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
-
-#include "crc32.h"
-
-static const unsigned long crctab[256] = {
-  0x0,
-  0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B,
-  0x1A864DB2, 0x1E475005, 0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6,
-  0x2B4BCB61, 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD,
-  0x4C11DB70, 0x48D0C6C7, 0x4593E01E, 0x4152FDA9, 0x5F15ADAC,
-  0x5BD4B01B, 0x569796C2, 0x52568B75, 0x6A1936C8, 0x6ED82B7F,
-  0x639B0DA6, 0x675A1011, 0x791D4014, 0x7DDC5DA3, 0x709F7B7A,
-  0x745E66CD, 0x9823B6E0, 0x9CE2AB57, 0x91A18D8E, 0x95609039,
-  0x8B27C03C, 0x8FE6DD8B, 0x82A5FB52, 0x8664E6E5, 0xBE2B5B58,
-  0xBAEA46EF, 0xB7A96036, 0xB3687D81, 0xAD2F2D84, 0xA9EE3033,
-  0xA4AD16EA, 0xA06C0B5D, 0xD4326D90, 0xD0F37027, 0xDDB056FE,
-  0xD9714B49, 0xC7361B4C, 0xC3F706FB, 0xCEB42022, 0xCA753D95,
-  0xF23A8028, 0xF6FB9D9F, 0xFBB8BB46, 0xFF79A6F1, 0xE13EF6F4,
-  0xE5FFEB43, 0xE8BCCD9A, 0xEC7DD02D, 0x34867077, 0x30476DC0,
-  0x3D044B19, 0x39C556AE, 0x278206AB, 0x23431B1C, 0x2E003DC5,
-  0x2AC12072, 0x128E9DCF, 0x164F8078, 0x1B0CA6A1, 0x1FCDBB16,
-  0x018AEB13, 0x054BF6A4, 0x0808D07D, 0x0CC9CDCA, 0x7897AB07,
-  0x7C56B6B0, 0x71159069, 0x75D48DDE, 0x6B93DDDB, 0x6F52C06C,
-  0x6211E6B5, 0x66D0FB02, 0x5E9F46BF, 0x5A5E5B08, 0x571D7DD1,
-  0x53DC6066, 0x4D9B3063, 0x495A2DD4, 0x44190B0D, 0x40D816BA,
-  0xACA5C697, 0xA864DB20, 0xA527FDF9, 0xA1E6E04E, 0xBFA1B04B,
-  0xBB60ADFC, 0xB6238B25, 0xB2E29692, 0x8AAD2B2F, 0x8E6C3698,
-  0x832F1041, 0x87EE0DF6, 0x99A95DF3, 0x9D684044, 0x902B669D,
-  0x94EA7B2A, 0xE0B41DE7, 0xE4750050, 0xE9362689, 0xEDF73B3E,
-  0xF3B06B3B, 0xF771768C, 0xFA325055, 0xFEF34DE2, 0xC6BCF05F,
-  0xC27DEDE8, 0xCF3ECB31, 0xCBFFD686, 0xD5B88683, 0xD1799B34,
-  0xDC3ABDED, 0xD8FBA05A, 0x690CE0EE, 0x6DCDFD59, 0x608EDB80,
-  0x644FC637, 0x7A089632, 0x7EC98B85, 0x738AAD5C, 0x774BB0EB,
-  0x4F040D56, 0x4BC510E1, 0x46863638, 0x42472B8F, 0x5C007B8A,
-  0x58C1663D, 0x558240E4, 0x51435D53, 0x251D3B9E, 0x21DC2629,
-  0x2C9F00F0, 0x285E1D47, 0x36194D42, 0x32D850F5, 0x3F9B762C,
-  0x3B5A6B9B, 0x0315D626, 0x07D4CB91, 0x0A97ED48, 0x0E56F0FF,
-  0x1011A0FA, 0x14D0BD4D, 0x19939B94, 0x1D528623, 0xF12F560E,
-  0xF5EE4BB9, 0xF8AD6D60, 0xFC6C70D7, 0xE22B20D2, 0xE6EA3D65,
-  0xEBA91BBC, 0xEF68060B, 0xD727BBB6, 0xD3E6A601, 0xDEA580D8,
-  0xDA649D6F, 0xC423CD6A, 0xC0E2D0DD, 0xCDA1F604, 0xC960EBB3,
-  0xBD3E8D7E, 0xB9FF90C9, 0xB4BCB610, 0xB07DABA7, 0xAE3AFBA2,
-  0xAAFBE615, 0xA7B8C0CC, 0xA379DD7B, 0x9B3660C6, 0x9FF77D71,
-  0x92B45BA8, 0x9675461F, 0x8832161A, 0x8CF30BAD, 0x81B02D74,
-  0x857130C3, 0x5D8A9099, 0x594B8D2E, 0x5408ABF7, 0x50C9B640,
-  0x4E8EE645, 0x4A4FFBF2, 0x470CDD2B, 0x43CDC09C, 0x7B827D21,
-  0x7F436096, 0x7200464F, 0x76C15BF8, 0x68860BFD, 0x6C47164A,
-  0x61043093, 0x65C52D24, 0x119B4BE9, 0x155A565E, 0x18197087,
-  0x1CD86D30, 0x029F3D35, 0x065E2082, 0x0B1D065B, 0x0FDC1BEC,
-  0x3793A651, 0x3352BBE6, 0x3E119D3F, 0x3AD08088, 0x2497D08D,
-  0x2056CD3A, 0x2D15EBE3, 0x29D4F654, 0xC5A92679, 0xC1683BCE,
-  0xCC2B1D17, 0xC8EA00A0, 0xD6AD50A5, 0xD26C4D12, 0xDF2F6BCB,
-  0xDBEE767C, 0xE3A1CBC1, 0xE760D676, 0xEA23F0AF, 0xEEE2ED18,
-  0xF0A5BD1D, 0xF464A0AA, 0xF9278673, 0xFDE69BC4, 0x89B8FD09,
-  0x8D79E0BE, 0x803AC667, 0x84FBDBD0, 0x9ABC8BD5, 0x9E7D9662,
-  0x933EB0BB, 0x97FFAD0C, 0xAFB010B1, 0xAB710D06, 0xA6322BDF,
-  0xA2F33668, 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4
-};
-
-unsigned long crc32(const void *buffer, unsigned long length)
-{
-       const unsigned char *cp = (const unsigned char *) buffer;
-       unsigned long crc = 0;
-
-       while (length--)
-               crc = (crc << 8) ^ crctab[((crc >> 24) ^ *(cp++)) & 0xFF];
-
-       return crc;
-}
diff --git a/crc32.h b/crc32.h
deleted file mode 100644 (file)
index b7e5eee..0000000
--- a/crc32.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* crc32 -- calculate and POSIX.2 checksum 
-   Copyright (C) 92, 1995-1999 Free Software Foundation, Inc.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software Foundation,
-   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
-
-#ifndef CRC32_H
-#define CRC32_H
-
-extern unsigned long crc32(const void * const, unsigned long);
-
-#endif
diff --git a/crc64.c b/crc64.c
deleted file mode 100644 (file)
index a61d432..0000000
--- a/crc64.c
+++ /dev/null
@@ -1,104 +0,0 @@
-#include "crc64.h"
-
-/*
- * poly 0x95AC9329AC4BC9B5ULL and init 0xFFFFFFFFFFFFFFFFULL
- */
-static const unsigned long long crctab64[256] = {
-  0x0000000000000000ULL, 0x7ad870c830358979ULL, 0xf5b0e190606b12f2ULL,
-  0x8f689158505e9b8bULL, 0xc038e5739841b68fULL, 0xbae095bba8743ff6ULL,
-  0x358804e3f82aa47dULL, 0x4f50742bc81f2d04ULL, 0xab28ecb46814fe75ULL,
-  0xd1f09c7c5821770cULL, 0x5e980d24087fec87ULL, 0x24407dec384a65feULL,
-  0x6b1009c7f05548faULL, 0x11c8790fc060c183ULL, 0x9ea0e857903e5a08ULL,
-  0xe478989fa00bd371ULL, 0x7d08ff3b88be6f81ULL, 0x07d08ff3b88be6f8ULL,
-  0x88b81eabe8d57d73ULL, 0xf2606e63d8e0f40aULL, 0xbd301a4810ffd90eULL,
-  0xc7e86a8020ca5077ULL, 0x4880fbd87094cbfcULL, 0x32588b1040a14285ULL,
-  0xd620138fe0aa91f4ULL, 0xacf86347d09f188dULL, 0x2390f21f80c18306ULL,
-  0x594882d7b0f40a7fULL, 0x1618f6fc78eb277bULL, 0x6cc0863448deae02ULL,
-  0xe3a8176c18803589ULL, 0x997067a428b5bcf0ULL, 0xfa11fe77117cdf02ULL,
-  0x80c98ebf2149567bULL, 0x0fa11fe77117cdf0ULL, 0x75796f2f41224489ULL,
-  0x3a291b04893d698dULL, 0x40f16bccb908e0f4ULL, 0xcf99fa94e9567b7fULL,
-  0xb5418a5cd963f206ULL, 0x513912c379682177ULL, 0x2be1620b495da80eULL,
-  0xa489f35319033385ULL, 0xde51839b2936bafcULL, 0x9101f7b0e12997f8ULL,
-  0xebd98778d11c1e81ULL, 0x64b116208142850aULL, 0x1e6966e8b1770c73ULL,
-  0x8719014c99c2b083ULL, 0xfdc17184a9f739faULL, 0x72a9e0dcf9a9a271ULL,
-  0x08719014c99c2b08ULL, 0x4721e43f0183060cULL, 0x3df994f731b68f75ULL,
-  0xb29105af61e814feULL, 0xc849756751dd9d87ULL, 0x2c31edf8f1d64ef6ULL,
-  0x56e99d30c1e3c78fULL, 0xd9810c6891bd5c04ULL, 0xa3597ca0a188d57dULL,
-  0xec09088b6997f879ULL, 0x96d1784359a27100ULL, 0x19b9e91b09fcea8bULL,
-  0x636199d339c963f2ULL, 0xdf7adabd7a6e2d6fULL, 0xa5a2aa754a5ba416ULL,
-  0x2aca3b2d1a053f9dULL, 0x50124be52a30b6e4ULL, 0x1f423fcee22f9be0ULL,
-  0x659a4f06d21a1299ULL, 0xeaf2de5e82448912ULL, 0x902aae96b271006bULL,
-  0x74523609127ad31aULL, 0x0e8a46c1224f5a63ULL, 0x81e2d7997211c1e8ULL,
-  0xfb3aa75142244891ULL, 0xb46ad37a8a3b6595ULL, 0xceb2a3b2ba0eececULL,
-  0x41da32eaea507767ULL, 0x3b024222da65fe1eULL, 0xa2722586f2d042eeULL,
-  0xd8aa554ec2e5cb97ULL, 0x57c2c41692bb501cULL, 0x2d1ab4dea28ed965ULL,
-  0x624ac0f56a91f461ULL, 0x1892b03d5aa47d18ULL, 0x97fa21650afae693ULL,
-  0xed2251ad3acf6feaULL, 0x095ac9329ac4bc9bULL, 0x7382b9faaaf135e2ULL,
-  0xfcea28a2faafae69ULL, 0x8632586aca9a2710ULL, 0xc9622c4102850a14ULL,
-  0xb3ba5c8932b0836dULL, 0x3cd2cdd162ee18e6ULL, 0x460abd1952db919fULL,
-  0x256b24ca6b12f26dULL, 0x5fb354025b277b14ULL, 0xd0dbc55a0b79e09fULL,
-  0xaa03b5923b4c69e6ULL, 0xe553c1b9f35344e2ULL, 0x9f8bb171c366cd9bULL,
-  0x10e3202993385610ULL, 0x6a3b50e1a30ddf69ULL, 0x8e43c87e03060c18ULL,
-  0xf49bb8b633338561ULL, 0x7bf329ee636d1eeaULL, 0x012b592653589793ULL,
-  0x4e7b2d0d9b47ba97ULL, 0x34a35dc5ab7233eeULL, 0xbbcbcc9dfb2ca865ULL,
-  0xc113bc55cb19211cULL, 0x5863dbf1e3ac9decULL, 0x22bbab39d3991495ULL,
-  0xadd33a6183c78f1eULL, 0xd70b4aa9b3f20667ULL, 0x985b3e827bed2b63ULL,
-  0xe2834e4a4bd8a21aULL, 0x6debdf121b863991ULL, 0x1733afda2bb3b0e8ULL,
-  0xf34b37458bb86399ULL, 0x8993478dbb8deae0ULL, 0x06fbd6d5ebd3716bULL,
-  0x7c23a61ddbe6f812ULL, 0x3373d23613f9d516ULL, 0x49aba2fe23cc5c6fULL,
-  0xc6c333a67392c7e4ULL, 0xbc1b436e43a74e9dULL, 0x95ac9329ac4bc9b5ULL,
-  0xef74e3e19c7e40ccULL, 0x601c72b9cc20db47ULL, 0x1ac40271fc15523eULL,
-  0x5594765a340a7f3aULL, 0x2f4c0692043ff643ULL, 0xa02497ca54616dc8ULL,
-  0xdafce7026454e4b1ULL, 0x3e847f9dc45f37c0ULL, 0x445c0f55f46abeb9ULL,
-  0xcb349e0da4342532ULL, 0xb1eceec59401ac4bULL, 0xfebc9aee5c1e814fULL,
-  0x8464ea266c2b0836ULL, 0x0b0c7b7e3c7593bdULL, 0x71d40bb60c401ac4ULL,
-  0xe8a46c1224f5a634ULL, 0x927c1cda14c02f4dULL, 0x1d148d82449eb4c6ULL,
-  0x67ccfd4a74ab3dbfULL, 0x289c8961bcb410bbULL, 0x5244f9a98c8199c2ULL,
-  0xdd2c68f1dcdf0249ULL, 0xa7f41839ecea8b30ULL, 0x438c80a64ce15841ULL,
-  0x3954f06e7cd4d138ULL, 0xb63c61362c8a4ab3ULL, 0xcce411fe1cbfc3caULL,
-  0x83b465d5d4a0eeceULL, 0xf96c151de49567b7ULL, 0x76048445b4cbfc3cULL,
-  0x0cdcf48d84fe7545ULL, 0x6fbd6d5ebd3716b7ULL, 0x15651d968d029fceULL,
-  0x9a0d8ccedd5c0445ULL, 0xe0d5fc06ed698d3cULL, 0xaf85882d2576a038ULL,
-  0xd55df8e515432941ULL, 0x5a3569bd451db2caULL, 0x20ed197575283bb3ULL,
-  0xc49581ead523e8c2ULL, 0xbe4df122e51661bbULL, 0x3125607ab548fa30ULL,
-  0x4bfd10b2857d7349ULL, 0x04ad64994d625e4dULL, 0x7e7514517d57d734ULL,
-  0xf11d85092d094cbfULL, 0x8bc5f5c11d3cc5c6ULL, 0x12b5926535897936ULL,
-  0x686de2ad05bcf04fULL, 0xe70573f555e26bc4ULL, 0x9ddd033d65d7e2bdULL,
-  0xd28d7716adc8cfb9ULL, 0xa85507de9dfd46c0ULL, 0x273d9686cda3dd4bULL,
-  0x5de5e64efd965432ULL, 0xb99d7ed15d9d8743ULL, 0xc3450e196da80e3aULL,
-  0x4c2d9f413df695b1ULL, 0x36f5ef890dc31cc8ULL, 0x79a59ba2c5dc31ccULL,
-  0x037deb6af5e9b8b5ULL, 0x8c157a32a5b7233eULL, 0xf6cd0afa9582aa47ULL,
-  0x4ad64994d625e4daULL, 0x300e395ce6106da3ULL, 0xbf66a804b64ef628ULL,
-  0xc5bed8cc867b7f51ULL, 0x8aeeace74e645255ULL, 0xf036dc2f7e51db2cULL,
-  0x7f5e4d772e0f40a7ULL, 0x05863dbf1e3ac9deULL, 0xe1fea520be311aafULL,
-  0x9b26d5e88e0493d6ULL, 0x144e44b0de5a085dULL, 0x6e963478ee6f8124ULL,
-  0x21c640532670ac20ULL, 0x5b1e309b16452559ULL, 0xd476a1c3461bbed2ULL,
-  0xaeaed10b762e37abULL, 0x37deb6af5e9b8b5bULL, 0x4d06c6676eae0222ULL,
-  0xc26e573f3ef099a9ULL, 0xb8b627f70ec510d0ULL, 0xf7e653dcc6da3dd4ULL,
-  0x8d3e2314f6efb4adULL, 0x0256b24ca6b12f26ULL, 0x788ec2849684a65fULL,
-  0x9cf65a1b368f752eULL, 0xe62e2ad306bafc57ULL, 0x6946bb8b56e467dcULL,
-  0x139ecb4366d1eea5ULL, 0x5ccebf68aecec3a1ULL, 0x2616cfa09efb4ad8ULL,
-  0xa97e5ef8cea5d153ULL, 0xd3a62e30fe90582aULL, 0xb0c7b7e3c7593bd8ULL,
-  0xca1fc72bf76cb2a1ULL, 0x45775673a732292aULL, 0x3faf26bb9707a053ULL,
-  0x70ff52905f188d57ULL, 0x0a2722586f2d042eULL, 0x854fb3003f739fa5ULL,
-  0xff97c3c80f4616dcULL, 0x1bef5b57af4dc5adULL, 0x61372b9f9f784cd4ULL,
-  0xee5fbac7cf26d75fULL, 0x9487ca0fff135e26ULL, 0xdbd7be24370c7322ULL,
-  0xa10fceec0739fa5bULL, 0x2e675fb4576761d0ULL, 0x54bf2f7c6752e8a9ULL,
-  0xcdcf48d84fe75459ULL, 0xb71738107fd2dd20ULL, 0x387fa9482f8c46abULL,
-  0x42a7d9801fb9cfd2ULL, 0x0df7adabd7a6e2d6ULL, 0x772fdd63e7936bafULL,
-  0xf8474c3bb7cdf024ULL, 0x829f3cf387f8795dULL, 0x66e7a46c27f3aa2cULL,
-  0x1c3fd4a417c62355ULL, 0x935745fc4798b8deULL, 0xe98f353477ad31a7ULL,
-  0xa6df411fbfb21ca3ULL, 0xdc0731d78f8795daULL, 0x536fa08fdfd90e51ULL,
-  0x29b7d047efec8728ULL
-};
-
-unsigned long long crc64(const unsigned char *buffer, unsigned long length)
-{
-       unsigned long long crc = 0;
-
-       while (length--)
-               crc = crctab64[(crc ^ *(buffer++)) & 0xff] ^ (crc >> 8);
-
-       return crc;
-}
-
diff --git a/crc64.h b/crc64.h
deleted file mode 100644 (file)
index e4310c2..0000000
--- a/crc64.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef CRC64_H
-#define CRC64_H
-
-unsigned long long crc64(const unsigned char *, unsigned long);
-
-#endif
diff --git a/crc7.c b/crc7.c
deleted file mode 100644 (file)
index 47aa332..0000000
--- a/crc7.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *      crc7.c
- *
- * This source code is licensed under the GNU General Public License,
- * Version 2. See the file COPYING for more details.
- */
-
-#include "crc7.h"
-
-/* Table for CRC-7 (polynomial x^7 + x^3 + 1) */
-const unsigned char crc7_syndrome_table[256] = {
-       0x00, 0x09, 0x12, 0x1b, 0x24, 0x2d, 0x36, 0x3f,
-       0x48, 0x41, 0x5a, 0x53, 0x6c, 0x65, 0x7e, 0x77,
-       0x19, 0x10, 0x0b, 0x02, 0x3d, 0x34, 0x2f, 0x26,
-       0x51, 0x58, 0x43, 0x4a, 0x75, 0x7c, 0x67, 0x6e,
-       0x32, 0x3b, 0x20, 0x29, 0x16, 0x1f, 0x04, 0x0d,
-       0x7a, 0x73, 0x68, 0x61, 0x5e, 0x57, 0x4c, 0x45,
-       0x2b, 0x22, 0x39, 0x30, 0x0f, 0x06, 0x1d, 0x14,
-       0x63, 0x6a, 0x71, 0x78, 0x47, 0x4e, 0x55, 0x5c,
-       0x64, 0x6d, 0x76, 0x7f, 0x40, 0x49, 0x52, 0x5b,
-       0x2c, 0x25, 0x3e, 0x37, 0x08, 0x01, 0x1a, 0x13,
-       0x7d, 0x74, 0x6f, 0x66, 0x59, 0x50, 0x4b, 0x42,
-       0x35, 0x3c, 0x27, 0x2e, 0x11, 0x18, 0x03, 0x0a,
-       0x56, 0x5f, 0x44, 0x4d, 0x72, 0x7b, 0x60, 0x69,
-       0x1e, 0x17, 0x0c, 0x05, 0x3a, 0x33, 0x28, 0x21,
-       0x4f, 0x46, 0x5d, 0x54, 0x6b, 0x62, 0x79, 0x70,
-       0x07, 0x0e, 0x15, 0x1c, 0x23, 0x2a, 0x31, 0x38,
-       0x41, 0x48, 0x53, 0x5a, 0x65, 0x6c, 0x77, 0x7e,
-       0x09, 0x00, 0x1b, 0x12, 0x2d, 0x24, 0x3f, 0x36,
-       0x58, 0x51, 0x4a, 0x43, 0x7c, 0x75, 0x6e, 0x67,
-       0x10, 0x19, 0x02, 0x0b, 0x34, 0x3d, 0x26, 0x2f,
-       0x73, 0x7a, 0x61, 0x68, 0x57, 0x5e, 0x45, 0x4c,
-       0x3b, 0x32, 0x29, 0x20, 0x1f, 0x16, 0x0d, 0x04,
-       0x6a, 0x63, 0x78, 0x71, 0x4e, 0x47, 0x5c, 0x55,
-       0x22, 0x2b, 0x30, 0x39, 0x06, 0x0f, 0x14, 0x1d,
-       0x25, 0x2c, 0x37, 0x3e, 0x01, 0x08, 0x13, 0x1a,
-       0x6d, 0x64, 0x7f, 0x76, 0x49, 0x40, 0x5b, 0x52,
-       0x3c, 0x35, 0x2e, 0x27, 0x18, 0x11, 0x0a, 0x03,
-       0x74, 0x7d, 0x66, 0x6f, 0x50, 0x59, 0x42, 0x4b,
-       0x17, 0x1e, 0x05, 0x0c, 0x33, 0x3a, 0x21, 0x28,
-       0x5f, 0x56, 0x4d, 0x44, 0x7b, 0x72, 0x69, 0x60,
-       0x0e, 0x07, 0x1c, 0x15, 0x2a, 0x23, 0x38, 0x31,
-       0x46, 0x4f, 0x54, 0x5d, 0x62, 0x6b, 0x70, 0x79
-};
-
-unsigned char crc7(const unsigned char *buffer, unsigned int len)
-{
-       unsigned char crc = 0;
-
-       while (len--)
-               crc = crc7_byte(crc, *buffer++);
-       return crc;
-}
diff --git a/crc7.h b/crc7.h
deleted file mode 100644 (file)
index 6ff3cd8..0000000
--- a/crc7.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CRC7_H
-#define CRC7_H
-
-extern const unsigned char crc7_syndrome_table[256];
-
-static inline unsigned char crc7_byte(unsigned char crc, unsigned char data)
-{
-       return crc7_syndrome_table[(crc << 1) ^ data];
-}
-
-extern unsigned char crc7(const unsigned char *buffer, unsigned int len);
-
-#endif
diff --git a/md5.c b/md5.c
deleted file mode 100644 (file)
index 8f9adb2..0000000
--- a/md5.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Shamelessly lifted from the 2.6 kernel (crypto/md5.c)
- */
-#include <string.h>
-#include <stdint.h>
-#include "md5.h"
-
-static void md5_transform(uint32_t *hash, uint32_t const *in)
-{
-       uint32_t a, b, c, d;
-
-       a = hash[0];
-       b = hash[1];
-       c = hash[2];
-       d = hash[3];
-
-       MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
-       MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
-       MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
-       MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
-       MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
-       MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
-       MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
-       MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
-       MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
-       MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
-       MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
-       MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
-       MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
-       MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
-       MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
-       MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
-       MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
-       MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
-       MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
-       MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
-       MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
-       MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
-       MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
-       MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
-       MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
-       MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
-       MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
-       MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
-       MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
-       MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
-       MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
-       MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
-       MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
-       MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
-       MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
-       MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
-       MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
-       MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
-       MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
-       MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
-       MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
-       MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
-       MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
-       MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
-       MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
-       MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
-       MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
-       MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
-       MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
-       MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
-       MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
-       MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
-       MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
-       MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
-       MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
-       MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
-       MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
-       MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
-       MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
-       MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
-       MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
-       MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
-       MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
-       MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
-       hash[0] += a;
-       hash[1] += b;
-       hash[2] += c;
-       hash[3] += d;
-}
-
-void md5_init(struct md5_ctx *mctx)
-{
-       mctx->hash[0] = 0x67452301;
-       mctx->hash[1] = 0xefcdab89;
-       mctx->hash[2] = 0x98badcfe;
-       mctx->hash[3] = 0x10325476;
-}
-
-void md5_update(struct md5_ctx *mctx, const uint8_t *data, unsigned int len)
-{
-       const uint32_t avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
-
-       mctx->byte_count += len;
-
-       if (avail > len) {
-               memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
-                      data, len);
-               return;
-       }
-
-       memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
-              data, avail);
-
-       md5_transform(mctx->hash, mctx->block);
-       data += avail;
-       len -= avail;
-
-       while (len >= sizeof(mctx->block)) {
-               memcpy(mctx->block, data, sizeof(mctx->block));
-               md5_transform(mctx->hash, mctx->block);
-               data += sizeof(mctx->block);
-               len -= sizeof(mctx->block);
-       }
-
-       memcpy(mctx->block, data, len);
-}
diff --git a/md5.h b/md5.h
deleted file mode 100644 (file)
index 6747d30..0000000
--- a/md5.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef MD5_H
-#define MD5_H
-
-#include <stdint.h>
-
-#define MD5_DIGEST_SIZE                16
-#define MD5_HMAC_BLOCK_SIZE    64
-#define MD5_BLOCK_WORDS                16
-#define MD5_HASH_WORDS         4
-
-#define F1(x, y, z)    (z ^ (x & (y ^ z)))
-#define F2(x, y, z)    F1(z, x, y)
-#define F3(x, y, z)    (x ^ y ^ z)
-#define F4(x, y, z)    (y ^ (x | ~z))
-
-#define MD5STEP(f, w, x, y, z, in, s) \
-       (w += f(x, y, z) + in, w = (w<<s | w>>(32-s)) + x)
-
-struct md5_ctx {
-       uint32_t *hash;
-       uint32_t block[MD5_BLOCK_WORDS];
-       uint64_t byte_count;
-};
-
-extern void md5_update(struct md5_ctx *, const uint8_t *, unsigned int);
-extern void md5_init(struct md5_ctx *);
-
-#endif
diff --git a/sha256.c b/sha256.c
deleted file mode 100644 (file)
index 8ec2943..0000000
--- a/sha256.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Cryptographic API.
- *
- * SHA-256, as specified in
- * http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf
- *
- * SHA-256 code by Jean-Luc Cooke <jlcooke@certainkey.com>.
- *
- * Copyright (c) Jean-Luc Cooke <jlcooke@certainkey.com>
- * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
- * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option) 
- * any later version.
- *
- */
-#include <string.h>
-#include <inttypes.h>
-#include <byteswap.h>
-#include <endian.h>
-
-#include "sha256.h"
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define        __be32_to_cpu(x)        __bswap_32(x)
-#else
-#define __be32_to_cpu(x)       (x)
-#endif
-
-#define SHA256_DIGEST_SIZE     32
-#define SHA256_HMAC_BLOCK_SIZE 64
-
-static inline uint32_t Ch(uint32_t x, uint32_t y, uint32_t z)
-{
-       return z ^ (x & (y ^ z));
-}
-
-static inline uint32_t Maj(uint32_t x, uint32_t y, uint32_t z)
-{
-       return (x & y) | (z & (x | y));
-}
-
-#define e0(x)       (ror32(x, 2) ^ ror32(x,13) ^ ror32(x,22))
-#define e1(x)       (ror32(x, 6) ^ ror32(x,11) ^ ror32(x,25))
-#define s0(x)       (ror32(x, 7) ^ ror32(x,18) ^ (x >> 3))
-#define s1(x)       (ror32(x,17) ^ ror32(x,19) ^ (x >> 10))
-
-#define H0         0x6a09e667
-#define H1         0xbb67ae85
-#define H2         0x3c6ef372
-#define H3         0xa54ff53a
-#define H4         0x510e527f
-#define H5         0x9b05688c
-#define H6         0x1f83d9ab
-#define H7         0x5be0cd19
-
-static inline uint32_t ror32(uint32_t word, unsigned int shift)
-{
-        return (word >> shift) | (word << (32 - shift));
-}
-
-static inline void LOAD_OP(int I, uint32_t *W, const uint8_t *input)
-{
-       W[I] = __be32_to_cpu(((uint32_t *)(input))[I]);
-}
-
-static inline void BLEND_OP(int I, uint32_t *W)
-{
-       W[I] = s1(W[I-2]) + W[I-7] + s0(W[I-15]) + W[I-16];
-}
-
-static void sha256_transform(uint32_t *state, const uint8_t *input)
-{
-       uint32_t a, b, c, d, e, f, g, h, t1, t2;
-       uint32_t W[64];
-       int i;
-
-       /* load the input */
-       for (i = 0; i < 16; i++)
-               LOAD_OP(i, W, input);
-
-       /* now blend */
-       for (i = 16; i < 64; i++)
-               BLEND_OP(i, W);
-
-       /* load the state into our registers */
-       a=state[0];  b=state[1];  c=state[2];  d=state[3];
-       e=state[4];  f=state[5];  g=state[6];  h=state[7];
-
-       /* now iterate */
-       t1 = h + e1(e) + Ch(e,f,g) + 0x428a2f98 + W[ 0];
-       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
-       t1 = g + e1(d) + Ch(d,e,f) + 0x71374491 + W[ 1];
-       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
-       t1 = f + e1(c) + Ch(c,d,e) + 0xb5c0fbcf + W[ 2];
-       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
-       t1 = e + e1(b) + Ch(b,c,d) + 0xe9b5dba5 + W[ 3];
-       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
-       t1 = d + e1(a) + Ch(a,b,c) + 0x3956c25b + W[ 4];
-       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
-       t1 = c + e1(h) + Ch(h,a,b) + 0x59f111f1 + W[ 5];
-       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
-       t1 = b + e1(g) + Ch(g,h,a) + 0x923f82a4 + W[ 6];
-       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
-       t1 = a + e1(f) + Ch(f,g,h) + 0xab1c5ed5 + W[ 7];
-       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
-
-       t1 = h + e1(e) + Ch(e,f,g) + 0xd807aa98 + W[ 8];
-       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
-       t1 = g + e1(d) + Ch(d,e,f) + 0x12835b01 + W[ 9];
-       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
-       t1 = f + e1(c) + Ch(c,d,e) + 0x243185be + W[10];
-       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
-       t1 = e + e1(b) + Ch(b,c,d) + 0x550c7dc3 + W[11];
-       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
-       t1 = d + e1(a) + Ch(a,b,c) + 0x72be5d74 + W[12];
-       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
-       t1 = c + e1(h) + Ch(h,a,b) + 0x80deb1fe + W[13];
-       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
-       t1 = b + e1(g) + Ch(g,h,a) + 0x9bdc06a7 + W[14];
-       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
-       t1 = a + e1(f) + Ch(f,g,h) + 0xc19bf174 + W[15];
-       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
-
-       t1 = h + e1(e) + Ch(e,f,g) + 0xe49b69c1 + W[16];
-       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
-       t1 = g + e1(d) + Ch(d,e,f) + 0xefbe4786 + W[17];
-       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
-       t1 = f + e1(c) + Ch(c,d,e) + 0x0fc19dc6 + W[18];
-       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
-       t1 = e + e1(b) + Ch(b,c,d) + 0x240ca1cc + W[19];
-       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
-       t1 = d + e1(a) + Ch(a,b,c) + 0x2de92c6f + W[20];
-       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
-       t1 = c + e1(h) + Ch(h,a,b) + 0x4a7484aa + W[21];
-       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
-       t1 = b + e1(g) + Ch(g,h,a) + 0x5cb0a9dc + W[22];
-       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
-       t1 = a + e1(f) + Ch(f,g,h) + 0x76f988da + W[23];
-       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
-
-       t1 = h + e1(e) + Ch(e,f,g) + 0x983e5152 + W[24];
-       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
-       t1 = g + e1(d) + Ch(d,e,f) + 0xa831c66d + W[25];
-       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
-       t1 = f + e1(c) + Ch(c,d,e) + 0xb00327c8 + W[26];
-       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
-       t1 = e + e1(b) + Ch(b,c,d) + 0xbf597fc7 + W[27];
-       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
-       t1 = d + e1(a) + Ch(a,b,c) + 0xc6e00bf3 + W[28];
-       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
-       t1 = c + e1(h) + Ch(h,a,b) + 0xd5a79147 + W[29];
-       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
-       t1 = b + e1(g) + Ch(g,h,a) + 0x06ca6351 + W[30];
-       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
-       t1 = a + e1(f) + Ch(f,g,h) + 0x14292967 + W[31];
-       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
-
-       t1 = h + e1(e) + Ch(e,f,g) + 0x27b70a85 + W[32];
-       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
-       t1 = g + e1(d) + Ch(d,e,f) + 0x2e1b2138 + W[33];
-       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
-       t1 = f + e1(c) + Ch(c,d,e) + 0x4d2c6dfc + W[34];
-       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
-       t1 = e + e1(b) + Ch(b,c,d) + 0x53380d13 + W[35];
-       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
-       t1 = d + e1(a) + Ch(a,b,c) + 0x650a7354 + W[36];
-       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
-       t1 = c + e1(h) + Ch(h,a,b) + 0x766a0abb + W[37];
-       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
-       t1 = b + e1(g) + Ch(g,h,a) + 0x81c2c92e + W[38];
-       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
-       t1 = a + e1(f) + Ch(f,g,h) + 0x92722c85 + W[39];
-       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
-
-       t1 = h + e1(e) + Ch(e,f,g) + 0xa2bfe8a1 + W[40];
-       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
-       t1 = g + e1(d) + Ch(d,e,f) + 0xa81a664b + W[41];
-       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
-       t1 = f + e1(c) + Ch(c,d,e) + 0xc24b8b70 + W[42];
-       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
-       t1 = e + e1(b) + Ch(b,c,d) + 0xc76c51a3 + W[43];
-       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
-       t1 = d + e1(a) + Ch(a,b,c) + 0xd192e819 + W[44];
-       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
-       t1 = c + e1(h) + Ch(h,a,b) + 0xd6990624 + W[45];
-       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
-       t1 = b + e1(g) + Ch(g,h,a) + 0xf40e3585 + W[46];
-       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
-       t1 = a + e1(f) + Ch(f,g,h) + 0x106aa070 + W[47];
-       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
-
-       t1 = h + e1(e) + Ch(e,f,g) + 0x19a4c116 + W[48];
-       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
-       t1 = g + e1(d) + Ch(d,e,f) + 0x1e376c08 + W[49];
-       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
-       t1 = f + e1(c) + Ch(c,d,e) + 0x2748774c + W[50];
-       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
-       t1 = e + e1(b) + Ch(b,c,d) + 0x34b0bcb5 + W[51];
-       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
-       t1 = d + e1(a) + Ch(a,b,c) + 0x391c0cb3 + W[52];
-       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
-       t1 = c + e1(h) + Ch(h,a,b) + 0x4ed8aa4a + W[53];
-       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
-       t1 = b + e1(g) + Ch(g,h,a) + 0x5b9cca4f + W[54];
-       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
-       t1 = a + e1(f) + Ch(f,g,h) + 0x682e6ff3 + W[55];
-       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
-
-       t1 = h + e1(e) + Ch(e,f,g) + 0x748f82ee + W[56];
-       t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
-       t1 = g + e1(d) + Ch(d,e,f) + 0x78a5636f + W[57];
-       t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
-       t1 = f + e1(c) + Ch(c,d,e) + 0x84c87814 + W[58];
-       t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
-       t1 = e + e1(b) + Ch(b,c,d) + 0x8cc70208 + W[59];
-       t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
-       t1 = d + e1(a) + Ch(a,b,c) + 0x90befffa + W[60];
-       t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
-       t1 = c + e1(h) + Ch(h,a,b) + 0xa4506ceb + W[61];
-       t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
-       t1 = b + e1(g) + Ch(g,h,a) + 0xbef9a3f7 + W[62];
-       t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
-       t1 = a + e1(f) + Ch(f,g,h) + 0xc67178f2 + W[63];
-       t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
-
-       state[0] += a; state[1] += b; state[2] += c; state[3] += d;
-       state[4] += e; state[5] += f; state[6] += g; state[7] += h;
-
-       /* clear any sensitive info... */
-       a = b = c = d = e = f = g = h = t1 = t2 = 0;
-       memset(W, 0, 64 * sizeof(uint32_t));
-}
-
-void sha256_init(struct sha256_ctx *sctx)
-{
-       sctx->state[0] = H0;
-       sctx->state[1] = H1;
-       sctx->state[2] = H2;
-       sctx->state[3] = H3;
-       sctx->state[4] = H4;
-       sctx->state[5] = H5;
-       sctx->state[6] = H6;
-       sctx->state[7] = H7;
-       sctx->count[0] = sctx->count[1] = 0;
-}
-
-void sha256_update(struct sha256_ctx *sctx, const uint8_t *data,
-                  unsigned int len)
-{
-       unsigned int i, index, part_len;
-
-       /* Compute number of bytes mod 128 */
-       index = (unsigned int)((sctx->count[0] >> 3) & 0x3f);
-
-       /* Update number of bits */
-       if ((sctx->count[0] += (len << 3)) < (len << 3)) {
-               sctx->count[1]++;
-               sctx->count[1] += (len >> 29);
-       }
-
-       part_len = 64 - index;
-
-       /* Transform as many times as possible. */
-       if (len >= part_len) {
-               memcpy(&sctx->buf[index], data, part_len);
-               sha256_transform(sctx->state, sctx->buf);
-
-               for (i = part_len; i + 63 < len; i += 64)
-                       sha256_transform(sctx->state, &data[i]);
-               index = 0;
-       } else {
-               i = 0;
-       }
-       
-       /* Buffer remaining input */
-       memcpy(&sctx->buf[index], &data[i], len-i);
-}
diff --git a/sha256.h b/sha256.h
deleted file mode 100644 (file)
index a3ca0e6..0000000
--- a/sha256.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef FIO_SHA256_H
-#define FIO_SHA256_H
-
-struct sha256_ctx {
-       uint32_t count[2];
-       uint32_t state[8];
-       uint8_t *buf;
-};
-
-void sha256_init(struct sha256_ctx *);
-void sha256_update(struct sha256_ctx *, const uint8_t *, unsigned int);
-
-#endif
diff --git a/sha512.c b/sha512.c
deleted file mode 100644 (file)
index 1f9ebb4..0000000
--- a/sha512.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/* SHA-512 code by Jean-Luc Cooke <jlcooke@certainkey.com>
- *
- * Copyright (c) Jean-Luc Cooke <jlcooke@certainkey.com>
- * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
- * Copyright (c) 2003 Kyle McMartin <kyle@debian.org>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- */
-
-#include <string.h>
-#include <inttypes.h>
-#include <byteswap.h>
-#include <endian.h>
-
-#include "sha512.h"
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define        __be64_to_cpu(x)        __bswap_64(x)
-#else
-#define __be64_to_cpu(x)       (x)
-#endif
-
-#define SHA384_DIGEST_SIZE 48
-#define SHA512_DIGEST_SIZE 64
-#define SHA384_HMAC_BLOCK_SIZE 128
-#define SHA512_HMAC_BLOCK_SIZE 128
-
-static inline uint64_t Ch(uint64_t x, uint64_t y, uint64_t z)
-{
-        return z ^ (x & (y ^ z));
-}
-
-static inline uint64_t Maj(uint64_t x, uint64_t y, uint64_t z)
-{
-        return (x & y) | (z & (x | y));
-}
-
-static inline uint64_t RORuint64_t(uint64_t x, uint64_t y)
-{
-        return (x >> y) | (x << (64 - y));
-}
-
-static const uint64_t sha512_K[80] = {
-        0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL,
-        0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
-        0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, 0xd807aa98a3030242ULL,
-        0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
-        0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL,
-        0xc19bf174cf692694ULL, 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL,
-        0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, 0x2de92c6f592b0275ULL,
-        0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
-        0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL,
-        0xbf597fc7beef0ee4ULL, 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL,
-        0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, 0x27b70a8546d22ffcULL,
-        0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL,
-        0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL,
-        0x92722c851482353bULL, 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL,
-        0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, 0xd192e819d6ef5218ULL,
-        0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
-        0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL,
-        0x34b0bcb5e19b48a8ULL, 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL,
-        0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, 0x748f82ee5defb2fcULL,
-        0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL,
-        0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL,
-        0xc67178f2e372532bULL, 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL,
-        0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, 0x06f067aa72176fbaULL,
-        0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
-        0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL,
-        0x431d67c49c100d4cULL, 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
-        0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL,
-};
-
-#define e0(x)       (RORuint64_t(x,28) ^ RORuint64_t(x,34) ^ RORuint64_t(x,39))
-#define e1(x)       (RORuint64_t(x,14) ^ RORuint64_t(x,18) ^ RORuint64_t(x,41))
-#define s0(x)       (RORuint64_t(x, 1) ^ RORuint64_t(x, 8) ^ (x >> 7))
-#define s1(x)       (RORuint64_t(x,19) ^ RORuint64_t(x,61) ^ (x >> 6))
-
-/* H* initial state for SHA-512 */
-#define H0         0x6a09e667f3bcc908ULL
-#define H1         0xbb67ae8584caa73bULL
-#define H2         0x3c6ef372fe94f82bULL
-#define H3         0xa54ff53a5f1d36f1ULL
-#define H4         0x510e527fade682d1ULL
-#define H5         0x9b05688c2b3e6c1fULL
-#define H6         0x1f83d9abfb41bd6bULL
-#define H7         0x5be0cd19137e2179ULL
-
-/* H'* initial state for SHA-384 */
-#define HP0 0xcbbb9d5dc1059ed8ULL
-#define HP1 0x629a292a367cd507ULL
-#define HP2 0x9159015a3070dd17ULL
-#define HP3 0x152fecd8f70e5939ULL
-#define HP4 0x67332667ffc00b31ULL
-#define HP5 0x8eb44a8768581511ULL
-#define HP6 0xdb0c2e0d64f98fa7ULL
-#define HP7 0x47b5481dbefa4fa4ULL
-
-static inline void LOAD_OP(int I, uint64_t *W, const uint8_t *input)
-{
-       W[I] = __be64_to_cpu( ((uint64_t *)(input))[I] );
-}
-
-static inline void BLEND_OP(int I, uint64_t *W)
-{
-       W[I] = s1(W[I-2]) + W[I-7] + s0(W[I-15]) + W[I-16];
-}
-
-static void sha512_transform(uint64_t *state, uint64_t *W, const uint8_t *input)
-{
-       uint64_t a, b, c, d, e, f, g, h, t1, t2;
-
-       int i;
-
-       /* load the input */
-       for (i = 0; i < 16; i++)
-               LOAD_OP(i, W, input);
-
-       for (i = 16; i < 80; i++)
-               BLEND_OP(i, W);
-
-       /* load the state into our registers */
-       a=state[0];   b=state[1];   c=state[2];   d=state[3];
-       e=state[4];   f=state[5];   g=state[6];   h=state[7];
-
-       /* now iterate */
-       for (i=0; i<80; i+=8) {
-               t1 = h + e1(e) + Ch(e,f,g) + sha512_K[i  ] + W[i  ];
-               t2 = e0(a) + Maj(a,b,c);    d+=t1;    h=t1+t2;
-               t1 = g + e1(d) + Ch(d,e,f) + sha512_K[i+1] + W[i+1];
-               t2 = e0(h) + Maj(h,a,b);    c+=t1;    g=t1+t2;
-               t1 = f + e1(c) + Ch(c,d,e) + sha512_K[i+2] + W[i+2];
-               t2 = e0(g) + Maj(g,h,a);    b+=t1;    f=t1+t2;
-               t1 = e + e1(b) + Ch(b,c,d) + sha512_K[i+3] + W[i+3];
-               t2 = e0(f) + Maj(f,g,h);    a+=t1;    e=t1+t2;
-               t1 = d + e1(a) + Ch(a,b,c) + sha512_K[i+4] + W[i+4];
-               t2 = e0(e) + Maj(e,f,g);    h+=t1;    d=t1+t2;
-               t1 = c + e1(h) + Ch(h,a,b) + sha512_K[i+5] + W[i+5];
-               t2 = e0(d) + Maj(d,e,f);    g+=t1;    c=t1+t2;
-               t1 = b + e1(g) + Ch(g,h,a) + sha512_K[i+6] + W[i+6];
-               t2 = e0(c) + Maj(c,d,e);    f+=t1;    b=t1+t2;
-               t1 = a + e1(f) + Ch(f,g,h) + sha512_K[i+7] + W[i+7];
-               t2 = e0(b) + Maj(b,c,d);    e+=t1;    a=t1+t2;
-       }
-
-       state[0] += a; state[1] += b; state[2] += c; state[3] += d;
-       state[4] += e; state[5] += f; state[6] += g; state[7] += h;
-
-       /* erase our data */
-       a = b = c = d = e = f = g = h = t1 = t2 = 0;
-}
-
-void sha512_init(struct sha512_ctx *sctx)
-{
-       sctx->state[0] = H0;
-       sctx->state[1] = H1;
-       sctx->state[2] = H2;
-       sctx->state[3] = H3;
-       sctx->state[4] = H4;
-       sctx->state[5] = H5;
-       sctx->state[6] = H6;
-       sctx->state[7] = H7;
-       sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0;
-}
-
-void sha512_update(struct sha512_ctx *sctx, const uint8_t *data,
-                  unsigned int len)
-{
-       unsigned int i, index, part_len;
-
-       /* Compute number of bytes mod 128 */
-       index = (unsigned int)((sctx->count[0] >> 3) & 0x7F);
-       
-       /* Update number of bits */
-       if ((sctx->count[0] += (len << 3)) < (len << 3)) {
-               if ((sctx->count[1] += 1) < 1)
-                       if ((sctx->count[2] += 1) < 1)
-                               sctx->count[3]++;
-               sctx->count[1] += (len >> 29);
-       }
-       
-        part_len = 128 - index;
-       
-       /* Transform as many times as possible. */
-       if (len >= part_len) {
-               memcpy(&sctx->buf[index], data, part_len);
-               sha512_transform(sctx->state, sctx->W, sctx->buf);
-
-               for (i = part_len; i + 127 < len; i+=128)
-                       sha512_transform(sctx->state, sctx->W, &data[i]);
-
-               index = 0;
-       } else {
-               i = 0;
-       }
-
-       /* Buffer remaining input */
-       memcpy(&sctx->buf[index], &data[i], len - i);
-
-       /* erase our data */
-       memset(sctx->W, 0, sizeof(sctx->W));
-}
diff --git a/sha512.h b/sha512.h
deleted file mode 100644 (file)
index 46e10cb..0000000
--- a/sha512.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef FIO_SHA512_H
-#define FIO_SHA512_H
-
-struct sha512_ctx {
-       uint64_t state[8];
-       uint32_t count[4];
-       uint8_t *buf;
-       uint64_t W[80];
-};
-
-void sha512_init(struct sha512_ctx *);
-void sha512_update(struct sha512_ctx *, const uint8_t *, unsigned int);
-
-#endif
index afc25ce..a0e26c9 100644 (file)
--- a/verify.c
+++ b/verify.c
@@ -8,13 +8,13 @@
 
 #include "fio.h"
 
-#include "md5.h"
-#include "crc64.h"
-#include "crc32.h"
-#include "crc16.h"
-#include "crc7.h"
-#include "sha256.h"
-#include "sha512.h"
+#include "crc/md5.h"
+#include "crc/crc64.h"
+#include "crc/crc32.h"
+#include "crc/crc16.h"
+#include "crc/crc7.h"
+#include "crc/sha256.h"
+#include "crc/sha512.h"
 
 static void fill_random_bytes(struct thread_data *td, void *p, unsigned int len)
 {