http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=potorooo&dt=2005-07-10%2022:30:03
New sha2 code on Solaris 2.8 / SPARC. Seems like it has problems memcpy'ing to a non-8-byte-aligned uint64 *. Attached patch fixes it by simplifying the _Final code and getting rid of the pointer. (I redefined bzero and bcopy but now I think they should be replaced directly - patch later.) http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=goose&dt=2005-07-11%2006:00:04 http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=ferret&dt=2005-07-10%2018:25:11 The new sha2.c checks not only whether BYTE_ENDIAN is LITTLE_ENDIAN or BIG_ENDIAN but also whether it is set. And the test fails on both Cygwin and MINGW. As gcc evaluates "#if UNDEF1 == UNDEF2" as true and there were no compile failures reported with current code, that means currently internal AES, SHA1 and MD5 used randomly big-endian, little-endian or both variants of code. If there was no regression failures on those platforms, it must be only by dumb luck. Attached patch includes sys/param.h, where I found them on MINGW, and puts stricter checks into all files. After I see successful run in pgbuildfarm, I send it for stable branches too. http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=canary&dt=2005-07-11%2002:30:00 NetBSD 1.6 with older OpenSSL. OpenSSL < 0.9.7 does not have AES, but most of PGP tests use it as it is the preferred cipher. And the AES tests fails anyway. I guess it can stay as expected failure. http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=dragonfly&dt=2005-07-11%2003:30:04 Linking problem with zlib on Solaris 9/x86. I am clueless about this. I can anyone look into it? Error message: ld: fatal: relocations remain against allocatable but non-writable sections -- marko
Index: pgsql/contrib/pgcrypto/sha2.c =================================================================== *** pgsql.orig/contrib/pgcrypto/sha2.c --- pgsql/contrib/pgcrypto/sha2.c *************** SHA256_Update(SHA256_CTX *context, const *** 496,502 **** void SHA256_Final(uint8 digest[], SHA256_CTX *context) { - uint32 *d = (uint32 *)digest; unsigned int usedspace; /* If no digest buffer is passed, we don't bother doing this: */ --- 496,501 ---- *************** SHA256_Final(uint8 digest[], SHA256_CTX *** 542,553 **** int j; for (j = 0; j < 8; j++) { REVERSE32(context->state[j],context->state[j]); - *d++ = context->state[j]; } } - #else - bcopy(context->state, d, SHA256_DIGEST_LENGTH); #endif } /* Clean up state data: */ --- 541,550 ---- int j; for (j = 0; j < 8; j++) { REVERSE32(context->state[j],context->state[j]); } } #endif + bcopy(context->state, digest, SHA256_DIGEST_LENGTH); } /* Clean up state data: */ *************** SHA512_Last(SHA512_CTX *context) *** 823,830 **** void SHA512_Final(uint8 digest[], SHA512_CTX *context) { - uint64 *d = (uint64 *)digest; - /* If no digest buffer is passed, we don't bother doing this: */ if (digest != NULL) { SHA512_Last(context); --- 820,825 ---- *************** SHA512_Final(uint8 digest[], SHA512_CTX *** 836,847 **** int j; for (j = 0; j < 8; j++) { REVERSE64(context->state[j],context->state[j]); - *d++ = context->state[j]; } } - #else - bcopy(context->state, d, SHA512_DIGEST_LENGTH); #endif } /* Zero out state data */ --- 831,840 ---- int j; for (j = 0; j < 8; j++) { REVERSE64(context->state[j],context->state[j]); } } #endif + bcopy(context->state, digest, SHA512_DIGEST_LENGTH); } /* Zero out state data */ *************** SHA384_Update(SHA384_CTX *context, const *** 869,876 **** void SHA384_Final(uint8 digest[], SHA384_CTX *context) { - uint64 *d = (uint64 *)digest; - /* If no digest buffer is passed, we don't bother doing this: */ if (digest != NULL) { SHA512_Last((SHA512_CTX *)context); --- 862,867 ---- *************** SHA384_Final(uint8 digest[], SHA384_CTX *** 882,893 **** int j; for (j = 0; j < 6; j++) { REVERSE64(context->state[j],context->state[j]); - *d++ = context->state[j]; } } - #else - bcopy(context->state, d, SHA384_DIGEST_LENGTH); #endif } /* Zero out state data */ --- 873,882 ---- int j; for (j = 0; j < 6; j++) { REVERSE64(context->state[j],context->state[j]); } } #endif + bcopy(context->state, digest, SHA384_DIGEST_LENGTH); } /* Zero out state data */
Index: pgsql/contrib/pgcrypto/md5.c =================================================================== *** pgsql.orig/contrib/pgcrypto/md5.c --- pgsql/contrib/pgcrypto/md5.c *************** *** 30,40 **** * SUCH DAMAGE. */ ! #include "postgres.h" #include "px.h" #include "md5.h" #define SHIFT(X, s) (((X) << (s)) | ((X) >> (32 - (s)))) #define F(X, Y, Z) (((X) & (Y)) | ((~X) & (Z))) --- 30,47 ---- * SUCH DAMAGE. */ ! #include <postgres.h> ! #include <sys/param.h> ! #include "px.h" #include "md5.h" + /* sanity check */ + #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) + #error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN + #endif + #define SHIFT(X, s) (((X) << (s)) | ((X) >> (32 - (s)))) #define F(X, Y, Z) (((X) & (Y)) | ((~X) & (Z))) Index: pgsql/contrib/pgcrypto/rijndael.c =================================================================== *** pgsql.orig/contrib/pgcrypto/rijndael.c --- pgsql/contrib/pgcrypto/rijndael.c *************** Mean: 500 cycles = 51.2 mbits/sec *** 39,48 **** --- 39,56 ---- */ #include <postgres.h> + #include <sys/param.h> + #include "px.h" #include "rijndael.h" + /* sanity check */ + #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) + #error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN + #endif + + #define PRE_CALC_TABLES #define LARGE_TABLES Index: pgsql/contrib/pgcrypto/sha1.c =================================================================== *** pgsql.orig/contrib/pgcrypto/sha1.c --- pgsql/contrib/pgcrypto/sha1.c *************** *** 35,53 **** * implemented by Jun-ichiro itojun Itoh <itojun@itojun.org> */ ! #include "postgres.h" ! #include "px.h" #include "sha1.h" /* sanity check */ ! #if BYTE_ORDER != BIG_ENDIAN ! #if BYTE_ORDER != LITTLE_ENDIAN ! #define unsupported 1 #endif - #endif - - #ifndef unsupported /* constant table */ static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6}; --- 35,50 ---- * implemented by Jun-ichiro itojun Itoh <itojun@itojun.org> */ ! #include <postgres.h> ! #include <sys/param.h> + #include "px.h" #include "sha1.h" /* sanity check */ ! #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) ! #error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN #endif /* constant table */ static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6}; *************** sha1_result(struct sha1_ctxt * ctxt, uin *** 347,350 **** #endif } - #endif /* unsupported */ --- 344,346 ---- Index: pgsql/contrib/pgcrypto/sha2.c =================================================================== *** pgsql.orig/contrib/pgcrypto/sha2.c --- pgsql/contrib/pgcrypto/sha2.c *************** *** 36,41 **** --- 36,42 ---- */ #include <postgres.h> + #include <sys/param.h> #include "sha2.h"
---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster