From: Robert K. <may...@us...> - 2001-07-05 21:39:55
|
Update of /cvsroot/bitcollider/bitprint In directory usw-pr-cvs1:/tmp/cvs-serv25756 Modified Files: bitprint.c Log Message: Added safety check to make sure that people correctly define the endianess of the target platform. Index: bitprint.c =================================================================== RCS file: /cvsroot/bitcollider/bitprint/bitprint.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** bitprint.c 2001/07/05 20:42:40 1.2 --- bitprint.c 2001/07/05 21:39:52 1.3 *************** *** 6,10 **** /* =================================================================== */ ! /* Note: The actual code in this file starts around line 135! */ /* =================================================================== */ #include <string.h> --- 6,10 ---- /* =================================================================== */ ! /* Note: The actual code in this file starts around line 70! */ /* =================================================================== */ #include <string.h> *************** *** 17,20 **** --- 17,79 ---- /* =================================================================== */ + /* Endian issues */ + /* =================================================================== */ + + /* This section specifies the endianness of the target platform. Right + now, all windows platforms are little endian. However, for other platforms, + this assumption cannot be made. */ + + #ifdef _WIN32 + #undef WORDS_BIGENDIAN + #define SIZEOF_LONG 4 + #else + + #error Please define the endianness of the platform that will run this code. + /* Notes for non-windows users: + If you are using autoconf, then add the following lines to your + configure.in script: + + AC_C_BIGENDIAN + AC_CHECK_SIZEOF(long) + + and then, add these lines to your config.h.in file: + + #undef WORDS_BIGENDIAN + #undef SIZEOF_LONG + + and then, uncomment the line below and your endian issues should + be taken care of! + + #include "config.h" + + If you are not using autoconf, then define WORDS_BIGENDIAN if this code + will run on a big-endian machine. Also, define SIZEOF_LONG to be + the size of a long variable on your platform. Set it to 4 on a 32bit + processor and 8 on a 64 bit processor. + + */ + #endif + + #ifdef WORDS_BIGENDIAN + # define BIG_ENDIAN 1 + #else + # define BIG_ENDIAN 0 + #endif + + #ifdef WORDS_BIGENDIAN + # if SIZEOF_LONG == 4 + # define SHA_BYTE_ORDER 4321 + # elif SIZEOF_LONG == 8 + # define SHA_BYTE_ORDER 87654321 + # endif + #else + # if SIZEOF_LONG == 4 + # define SHA_BYTE_ORDER 1234 + # elif SIZEOF_LONG == 8 + # define SHA_BYTE_ORDER 12345678 + # endif + #endif + + /* =================================================================== */ /* FILE: sha1.h */ /* =================================================================== */ *************** *** 24,28 **** /* Applied Cryptography by Bruce Schneier */ /* This code is in the public domain */ - /* $Id$ */ typedef unsigned char BYTE; /* 8-bit quantity */ --- 83,86 ---- *************** *** 38,42 **** #define SHA_VERSION 1 - #define SHA_BYTE_ORDER 1234 /* =================================================================== */ --- 96,99 ---- *************** *** 404,413 **** * http://www.cs.technion.ac.il/~biham/Reports/Tiger/ */ - - #ifdef WORDS_BIGENDIAN - # define BIG_ENDIAN 1 - #else - # define BIG_ENDIAN 0 - #endif /* The following macro denotes that an optimization */ --- 461,464 ---- |