mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Now that core functionality is depending on autoconf's AC_C_BIGENDIAN to be
right, there seems precious little reason to have a pile of hand-maintained endianness definitions in src/include/port/*.h. Get rid of those, and make the couple of places that used them depend on WORDS_BIGENDIAN instead.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $PostgreSQL: pgsql/contrib/pgcrypto/crypt-blowfish.c,v 1.11 2006/03/11 04:38:30 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pgcrypto/crypt-blowfish.c,v 1.12 2007/04/06 05:36:50 tgl Exp $
|
||||
*
|
||||
* This code comes from John the Ripper password cracker, with reentrant
|
||||
* and crypt(3) interfaces added, but optimizations specific to password
|
||||
@ -436,19 +436,19 @@ BF_encode(char *dst, const BF_word * src, int size)
|
||||
}
|
||||
|
||||
static void
|
||||
BF_swap(BF_word * x, int count)
|
||||
BF_swap(BF_word *x, int count)
|
||||
{
|
||||
static int endianness_check = 1;
|
||||
char *is_little_endian = (char *) &endianness_check;
|
||||
/* Swap on little-endian hardware, else do nothing */
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
BF_word tmp;
|
||||
|
||||
if (*is_little_endian)
|
||||
do
|
||||
{
|
||||
tmp = *x;
|
||||
tmp = (tmp << 16) | (tmp >> 16);
|
||||
*x++ = ((tmp & 0x00FF00FF) << 8) | ((tmp >> 8) & 0x00FF00FF);
|
||||
} while (--count);
|
||||
do
|
||||
{
|
||||
tmp = *x;
|
||||
tmp = (tmp << 16) | (tmp >> 16);
|
||||
*x++ = ((tmp & 0x00FF00FF) << 8) | ((tmp >> 8) & 0x00FF00FF);
|
||||
} while (--count);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if BF_SCALE
|
||||
|
@ -28,7 +28,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.13 2005/07/11 15:07:59 tgl Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.14 2007/04/06 05:36:50 tgl Exp $
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
@ -38,11 +38,6 @@
|
||||
#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)))
|
||||
@ -201,10 +196,9 @@ md5_pad(md5_ctxt * ctxt)
|
||||
}
|
||||
|
||||
/* 8 byte word */
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
memmove(&ctxt->md5_buf[56], &ctxt->md5_n8[0], 8);
|
||||
#endif
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#else
|
||||
ctxt->md5_buf[56] = ctxt->md5_n8[7];
|
||||
ctxt->md5_buf[57] = ctxt->md5_n8[6];
|
||||
ctxt->md5_buf[58] = ctxt->md5_n8[5];
|
||||
@ -222,10 +216,9 @@ void
|
||||
md5_result(uint8 *digest, md5_ctxt * ctxt)
|
||||
{
|
||||
/* 4 byte words */
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
memmove(digest, &ctxt->md5_st8[0], 16);
|
||||
#endif
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#else
|
||||
digest[0] = ctxt->md5_st8[3];
|
||||
digest[1] = ctxt->md5_st8[2];
|
||||
digest[2] = ctxt->md5_st8[1];
|
||||
@ -245,7 +238,7 @@ md5_result(uint8 *digest, md5_ctxt * ctxt)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
static uint32 X[16];
|
||||
#endif
|
||||
|
||||
@ -257,10 +250,9 @@ md5_calc(uint8 *b64, md5_ctxt * ctxt)
|
||||
uint32 C = ctxt->md5_stc;
|
||||
uint32 D = ctxt->md5_std;
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
uint32 *X = (uint32 *) b64;
|
||||
#endif
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#else
|
||||
/* 4 byte words */
|
||||
/* what a brute force but fast! */
|
||||
uint8 *y = (uint8 *) X;
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $PostgreSQL: pgsql/contrib/pgcrypto/px.h,v 1.16 2005/10/15 02:49:06 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pgcrypto/px.h,v 1.17 2007/04/06 05:36:50 tgl Exp $
|
||||
*/
|
||||
|
||||
#ifndef __PX_H
|
||||
@ -34,13 +34,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#ifdef HAVE_ENDIAN_H
|
||||
#include <endian.h>
|
||||
#endif
|
||||
|
||||
#ifndef BYTE_ORDER
|
||||
#error BYTE_ORDER must be defined as LITTLE_ENDIAN or BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
/* keep debug messages? */
|
||||
#define PX_DEBUG
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* $OpenBSD: rijndael.c,v 1.6 2000/12/09 18:51:34 markus Exp $ */
|
||||
|
||||
/* $PostgreSQL: pgsql/contrib/pgcrypto/rijndael.c,v 1.12 2005/10/15 02:49:06 momjian Exp $ */
|
||||
/* $PostgreSQL: pgsql/contrib/pgcrypto/rijndael.c,v 1.13 2007/04/06 05:36:50 tgl Exp $ */
|
||||
|
||||
/* This is an independent implementation of the encryption algorithm: */
|
||||
/* */
|
||||
@ -47,12 +47,6 @@ Mean: 500 cycles = 51.2 mbits/sec
|
||||
#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
|
||||
|
||||
@ -73,11 +67,7 @@ static void gen_tabs(void);
|
||||
|
||||
#define byte(x,n) ((u1byte)((x) >> (8 * (n))))
|
||||
|
||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
||||
#define BYTE_SWAP
|
||||
#endif
|
||||
|
||||
#ifdef BYTE_SWAP
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define io_swap(x) bswap(x)
|
||||
#else
|
||||
#define io_swap(x) (x)
|
||||
|
@ -28,7 +28,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.16 2005/07/11 15:07:59 tgl Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.17 2007/04/06 05:36:50 tgl Exp $
|
||||
*/
|
||||
/*
|
||||
* FIPS pub 180-1: Secure Hash Algorithm (SHA-1)
|
||||
@ -43,11 +43,6 @@
|
||||
#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};
|
||||
|
||||
@ -98,7 +93,7 @@ sha1_step(struct sha1_ctxt * ctxt)
|
||||
s;
|
||||
uint32 tmp;
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
struct sha1_ctxt tctxt;
|
||||
|
||||
memmove(&tctxt.m.b8[0], &ctxt->m.b8[0], 64);
|
||||
@ -264,7 +259,7 @@ sha1_pad(struct sha1_ctxt * ctxt)
|
||||
memset(&ctxt->m.b8[padstart], 0, padlen - 8);
|
||||
COUNT += (padlen - 8);
|
||||
COUNT %= 64;
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
PUTPAD(ctxt->c.b8[0]);
|
||||
PUTPAD(ctxt->c.b8[1]);
|
||||
PUTPAD(ctxt->c.b8[2]);
|
||||
@ -320,7 +315,7 @@ sha1_result(struct sha1_ctxt * ctxt, uint8 *digest0)
|
||||
|
||||
digest = (uint8 *) digest0;
|
||||
sha1_pad(ctxt);
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
memmove(digest, &ctxt->h.b8[0], 20);
|
||||
#else
|
||||
digest[0] = ctxt->h.b8[3];
|
||||
|
@ -33,7 +33,7 @@
|
||||
*
|
||||
* $From: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $
|
||||
*
|
||||
* $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.8 2006/10/04 00:29:46 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.9 2007/04/06 05:36:50 tgl Exp $
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
@ -56,40 +56,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*** SHA-256/384/512 Machine Architecture Definitions *****************/
|
||||
/*
|
||||
* BYTE_ORDER NOTE:
|
||||
*
|
||||
* Please make sure that your system defines BYTE_ORDER. If your
|
||||
* architecture is little-endian, make sure it also defines
|
||||
* LITTLE_ENDIAN and that the two (BYTE_ORDER and LITTLE_ENDIAN) are
|
||||
* equivilent.
|
||||
*
|
||||
* If your system does not define the above, then you can do so by
|
||||
* hand like this:
|
||||
*
|
||||
* #define LITTLE_ENDIAN 1234
|
||||
* #define BIG_ENDIAN 4321
|
||||
*
|
||||
* And for little-endian machines, add:
|
||||
*
|
||||
* #define BYTE_ORDER LITTLE_ENDIAN
|
||||
*
|
||||
* Or for big-endian machines:
|
||||
*
|
||||
* #define BYTE_ORDER BIG_ENDIAN
|
||||
*
|
||||
* The FreeBSD machine this was written on defines BYTE_ORDER
|
||||
* appropriately by including <sys/types.h> (which in turn includes
|
||||
* <machine/endian.h> where the appropriate definitions are actually
|
||||
* made).
|
||||
*/
|
||||
#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
|
||||
|
||||
|
||||
/*** SHA-256/384/512 Various Length Definitions ***********************/
|
||||
/* NOTE: Most of these are in sha2.h */
|
||||
#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8)
|
||||
@ -98,7 +64,7 @@
|
||||
|
||||
|
||||
/*** ENDIAN REVERSAL MACROS *******************************************/
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
#define REVERSE32(w,x) { \
|
||||
uint32 tmp = (w); \
|
||||
tmp = (tmp >> 16) | (tmp << 16); \
|
||||
@ -112,7 +78,7 @@
|
||||
(x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \
|
||||
((tmp & 0x0000ffff0000ffffULL) << 16); \
|
||||
}
|
||||
#endif /* BYTE_ORDER == LITTLE_ENDIAN */
|
||||
#endif /* not bigendian */
|
||||
|
||||
/*
|
||||
* Macro for incrementally adding the unsigned 64-bit integer n to the
|
||||
@ -539,7 +505,7 @@ SHA256_Last(SHA256_CTX * context)
|
||||
unsigned int usedspace;
|
||||
|
||||
usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH;
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
/* Convert FROM host byte order */
|
||||
REVERSE64(context->bitcount, context->bitcount);
|
||||
#endif
|
||||
@ -589,7 +555,7 @@ SHA256_Final(uint8 digest[], SHA256_CTX * context)
|
||||
{
|
||||
SHA256_Last(context);
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
{
|
||||
/* Convert TO host byte order */
|
||||
int j;
|
||||
@ -865,7 +831,7 @@ SHA512_Last(SHA512_CTX * context)
|
||||
unsigned int usedspace;
|
||||
|
||||
usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH;
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
/* Convert FROM host byte order */
|
||||
REVERSE64(context->bitcount[0], context->bitcount[0]);
|
||||
REVERSE64(context->bitcount[1], context->bitcount[1]);
|
||||
@ -918,7 +884,7 @@ SHA512_Final(uint8 digest[], SHA512_CTX * context)
|
||||
SHA512_Last(context);
|
||||
|
||||
/* Save the hash data for output: */
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
{
|
||||
/* Convert TO host byte order */
|
||||
int j;
|
||||
@ -963,7 +929,7 @@ SHA384_Final(uint8 digest[], SHA384_CTX * context)
|
||||
SHA512_Last((SHA512_CTX *) context);
|
||||
|
||||
/* Save the hash data for output: */
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
{
|
||||
/* Convert TO host byte order */
|
||||
int j;
|
||||
@ -1006,7 +972,7 @@ SHA224_Final(uint8 digest[], SHA224_CTX * context)
|
||||
{
|
||||
SHA256_Last(context);
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
{
|
||||
/* Convert TO host byte order */
|
||||
int j;
|
||||
|
Reference in New Issue
Block a user