#include "bn_lcl.h"
#include "cryptlib.h"
+#include <machine/endian.h>
+
#define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2
#define BN_NIST_224_TOP (224+BN_BITS2-1)/BN_BITS2
:(to[(n)/2] =((m)&1)?(from[(m)/2]>>32):(from[(m)/2]&BN_MASK2l)))
#define bn_32_set_0(to, n) (((n)&1)?(to[(n)/2]&=BN_MASK2l):(to[(n)/2]=0));
#define bn_cp_32(to,n,from,m) ((m)>=0)?bn_cp_32_naked(to,n,from,m):bn_32_set_0(to,n)
-# if defined(L_ENDIAN)
+# if _BYTE_ORDER == _LITTLE_ENDIAN
# if defined(__arch64__)
# define NIST_INT64 long
# else
-# $OpenBSD: Makefile,v 1.25 2014/04/18 17:32:31 miod Exp $
+# $OpenBSD: Makefile,v 1.26 2014/04/18 19:41:21 miod Exp $
LIB= crypto
CFLAGS+= -Wall
-# arm and sh default to little endian, mips defaults to big endian
-.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "amd64" || \
- ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "i386" || \
- ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "sh" || \
- ${MACHINE_ARCH} == "vax"
-CFLAGS+= -DL_ENDIAN
-.else
-CFLAGS+= -DB_ENDIAN
-.endif
-
.include <bsd.own.mk> # for 'NOPIC' definition
.if !defined(NOPIC)
CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H
#include "des_locl.h"
#include <assert.h>
+#include <machine/endian.h>
/* The input and output are loaded in multiples of 8 bits.
* What this means is that if you hame numbits=12 and length=2
register int num=numbits/8,n=(numbits+7)/8,i,rem=numbits%8;
DES_LONG ti[2];
unsigned char *iv;
-#ifndef L_ENDIAN
+#if _BYTE_ORDER != _LITTLE_ENDIAN
unsigned char ovec[16];
#else
unsigned int sh[4];
{ v0=d0; v1=d1; }
else
{
-#ifndef L_ENDIAN
+#if _BYTE_ORDER != _LITTLE_ENDIAN
iv=&ovec[0];
l2c(v0,iv);
l2c(v1,iv);
for(i=0 ; i < 8 ; ++i)
ovec[i]=ovec[i+num]<<rem |
ovec[i+num+1]>>(8-rem);
-#ifdef L_ENDIAN
+#if _BYTE_ORDER == _LITTLE_ENDIAN
v0=sh[0], v1=sh[1];
#else
iv=&ovec[0];
{ v0=d0; v1=d1; }
else
{
-#ifndef L_ENDIAN
+#if _BYTE_ORDER != _LITTLE_ENDIAN
iv=&ovec[0];
l2c(v0,iv);
l2c(v1,iv);
for(i=0 ; i < 8 ; ++i)
ovec[i]=ovec[i+num]<<rem |
ovec[i+num+1]>>(8-rem);
-#ifdef L_ENDIAN
+#if _BYTE_ORDER == _LITTLE_ENDIAN
v0=sh[0], v1=sh[1];
#else
iv=&ovec[0];
*/
#include <stdlib.h>
#include <string.h>
+#include <machine/endian.h>
#include <openssl/crypto.h>
#include <openssl/sha.h>
sha512_block_data_order (c,p,1);
memset (p+n,0,sizeof(c->u)-16-n);
-#ifdef B_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
c->u.d[SHA_LBLOCK-2] = c->Nh;
c->u.d[SHA_LBLOCK-1] = c->Nl;
#else
for (i=0;i<16;i++)
{
-#ifdef B_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
T1 = X[i] = W[i];
#else
T1 = X[i] = PULL64(W[i]);
a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3];
e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7];
-#ifdef B_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
T1 = X[0] = W[0]; ROUND_00_15(0,a,b,c,d,e,f,g,h);
T1 = X[1] = W[1]; ROUND_00_15(1,h,a,b,c,d,e,f,g);
T1 = X[2] = W[2]; ROUND_00_15(2,g,h,a,b,c,d,e,f);
#include "wp_locl.h"
#include <string.h>
+#include <machine/endian.h>
typedef unsigned char u8;
#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32)
# define ROTATE(a,n) ({ u64 ret; asm ("rolq %1,%0" \
: "=r"(ret) : "J"(n),"0"(a) : "cc"); ret; })
# elif defined(__ia64) || defined(__ia64__)
-# if defined(L_ENDIAN)
+# if _BYTE_ORDER == _LITTLE_ENDIAN
# define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \
: "=r"(ret) : "r"(a),"M"(64-(n))); ret; })
-# elif defined(B_ENDIAN)
+# else
# define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \
: "=r"(ret) : "r"(a),"M"(n)); ret; })
# endif
#if defined(OPENSSL_SMALL_FOOTPRINT)
# if !defined(ROTATE)
-# if defined(L_ENDIAN) /* little-endians have to rotate left */
+# if _BYTE_ORDER == _LITTLE_ENDIAN /* little-endians have to rotate left */
# define ROTATE(i,n) ((i)<<(n) ^ (i)>>(64-n))
-# elif defined(B_ENDIAN) /* big-endians have to rotate right */
+# else /* big-endians have to rotate right */
# define ROTATE(i,n) ((i)>>(n) ^ (i)<<(64-n))
# endif
# endif
#include "bn_lcl.h"
#include "cryptlib.h"
+#include <machine/endian.h>
+
#define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2
#define BN_NIST_224_TOP (224+BN_BITS2-1)/BN_BITS2
:(to[(n)/2] =((m)&1)?(from[(m)/2]>>32):(from[(m)/2]&BN_MASK2l)))
#define bn_32_set_0(to, n) (((n)&1)?(to[(n)/2]&=BN_MASK2l):(to[(n)/2]=0));
#define bn_cp_32(to,n,from,m) ((m)>=0)?bn_cp_32_naked(to,n,from,m):bn_32_set_0(to,n)
-# if defined(L_ENDIAN)
+# if _BYTE_ORDER == _LITTLE_ENDIAN
# if defined(__arch64__)
# define NIST_INT64 long
# else
#include "des_locl.h"
#include <assert.h>
+#include <machine/endian.h>
/* The input and output are loaded in multiples of 8 bits.
* What this means is that if you hame numbits=12 and length=2
register int num=numbits/8,n=(numbits+7)/8,i,rem=numbits%8;
DES_LONG ti[2];
unsigned char *iv;
-#ifndef L_ENDIAN
+#if _BYTE_ORDER != _LITTLE_ENDIAN
unsigned char ovec[16];
#else
unsigned int sh[4];
{ v0=d0; v1=d1; }
else
{
-#ifndef L_ENDIAN
+#if _BYTE_ORDER != _LITTLE_ENDIAN
iv=&ovec[0];
l2c(v0,iv);
l2c(v1,iv);
for(i=0 ; i < 8 ; ++i)
ovec[i]=ovec[i+num]<<rem |
ovec[i+num+1]>>(8-rem);
-#ifdef L_ENDIAN
+#if _BYTE_ORDER == _LITTLE_ENDIAN
v0=sh[0], v1=sh[1];
#else
iv=&ovec[0];
{ v0=d0; v1=d1; }
else
{
-#ifndef L_ENDIAN
+#if _BYTE_ORDER != _LITTLE_ENDIAN
iv=&ovec[0];
l2c(v0,iv);
l2c(v1,iv);
for(i=0 ; i < 8 ; ++i)
ovec[i]=ovec[i+num]<<rem |
ovec[i+num+1]>>(8-rem);
-#ifdef L_ENDIAN
+#if _BYTE_ORDER == _LITTLE_ENDIAN
v0=sh[0], v1=sh[1];
#else
iv=&ovec[0];
*/
#include <stdlib.h>
#include <string.h>
+#include <machine/endian.h>
#include <openssl/crypto.h>
#include <openssl/sha.h>
sha512_block_data_order (c,p,1);
memset (p+n,0,sizeof(c->u)-16-n);
-#ifdef B_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
c->u.d[SHA_LBLOCK-2] = c->Nh;
c->u.d[SHA_LBLOCK-1] = c->Nl;
#else
for (i=0;i<16;i++)
{
-#ifdef B_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
T1 = X[i] = W[i];
#else
T1 = X[i] = PULL64(W[i]);
a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3];
e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7];
-#ifdef B_ENDIAN
+#if _BYTE_ORDER == _BIG_ENDIAN
T1 = X[0] = W[0]; ROUND_00_15(0,a,b,c,d,e,f,g,h);
T1 = X[1] = W[1]; ROUND_00_15(1,h,a,b,c,d,e,f,g);
T1 = X[2] = W[2]; ROUND_00_15(2,g,h,a,b,c,d,e,f);
#include "wp_locl.h"
#include <string.h>
+#include <machine/endian.h>
typedef unsigned char u8;
#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32)
# define ROTATE(a,n) ({ u64 ret; asm ("rolq %1,%0" \
: "=r"(ret) : "J"(n),"0"(a) : "cc"); ret; })
# elif defined(__ia64) || defined(__ia64__)
-# if defined(L_ENDIAN)
+# if _BYTE_ORDER == _LITTLE_ENDIAN
# define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \
: "=r"(ret) : "r"(a),"M"(64-(n))); ret; })
-# elif defined(B_ENDIAN)
+# else
# define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \
: "=r"(ret) : "r"(a),"M"(n)); ret; })
# endif
#if defined(OPENSSL_SMALL_FOOTPRINT)
# if !defined(ROTATE)
-# if defined(L_ENDIAN) /* little-endians have to rotate left */
+# if _BYTE_ORDER == _LITTLE_ENDIAN /* little-endians have to rotate left */
# define ROTATE(i,n) ((i)<<(n) ^ (i)>>(64-n))
-# elif defined(B_ENDIAN) /* big-endians have to rotate right */
+# else /* big-endians have to rotate right */
# define ROTATE(i,n) ((i)>>(n) ^ (i)<<(64-n))
# endif
# endif