diff options
Diffstat (limited to 'src/lib/libssl')
| -rw-r--r-- | src/lib/libssl/src/crypto/bn/bn_nist.c | 4 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/des/cfb_enc.c | 11 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/sha/sha512.c | 7 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/whrlpool/wp_block.c | 9 |
4 files changed, 18 insertions, 13 deletions
diff --git a/src/lib/libssl/src/crypto/bn/bn_nist.c b/src/lib/libssl/src/crypto/bn/bn_nist.c index 1e4cf833dc..4d4a7b86df 100644 --- a/src/lib/libssl/src/crypto/bn/bn_nist.c +++ b/src/lib/libssl/src/crypto/bn/bn_nist.c | |||
| @@ -59,6 +59,8 @@ | |||
| 59 | #include "bn_lcl.h" | 59 | #include "bn_lcl.h" |
| 60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
| 61 | 61 | ||
| 62 | #include <machine/endian.h> | ||
| 63 | |||
| 62 | 64 | ||
| 63 | #define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2 | 65 | #define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2 |
| 64 | #define BN_NIST_224_TOP (224+BN_BITS2-1)/BN_BITS2 | 66 | #define BN_NIST_224_TOP (224+BN_BITS2-1)/BN_BITS2 |
| @@ -318,7 +320,7 @@ static void nist_cp_bn(BN_ULONG *dst, const BN_ULONG *src, int top) | |||
| 318 | :(to[(n)/2] =((m)&1)?(from[(m)/2]>>32):(from[(m)/2]&BN_MASK2l))) | 320 | :(to[(n)/2] =((m)&1)?(from[(m)/2]>>32):(from[(m)/2]&BN_MASK2l))) |
| 319 | #define bn_32_set_0(to, n) (((n)&1)?(to[(n)/2]&=BN_MASK2l):(to[(n)/2]=0)); | 321 | #define bn_32_set_0(to, n) (((n)&1)?(to[(n)/2]&=BN_MASK2l):(to[(n)/2]=0)); |
| 320 | #define bn_cp_32(to,n,from,m) ((m)>=0)?bn_cp_32_naked(to,n,from,m):bn_32_set_0(to,n) | 322 | #define bn_cp_32(to,n,from,m) ((m)>=0)?bn_cp_32_naked(to,n,from,m):bn_32_set_0(to,n) |
| 321 | # if defined(L_ENDIAN) | 323 | # if _BYTE_ORDER == _LITTLE_ENDIAN |
| 322 | # if defined(__arch64__) | 324 | # if defined(__arch64__) |
| 323 | # define NIST_INT64 long | 325 | # define NIST_INT64 long |
| 324 | # else | 326 | # else |
diff --git a/src/lib/libssl/src/crypto/des/cfb_enc.c b/src/lib/libssl/src/crypto/des/cfb_enc.c index dd5237a86d..9bf6466bd2 100644 --- a/src/lib/libssl/src/crypto/des/cfb_enc.c +++ b/src/lib/libssl/src/crypto/des/cfb_enc.c | |||
| @@ -58,6 +58,7 @@ | |||
| 58 | 58 | ||
| 59 | #include "des_locl.h" | 59 | #include "des_locl.h" |
| 60 | #include <assert.h> | 60 | #include <assert.h> |
| 61 | #include <machine/endian.h> | ||
| 61 | 62 | ||
| 62 | /* The input and output are loaded in multiples of 8 bits. | 63 | /* The input and output are loaded in multiples of 8 bits. |
| 63 | * What this means is that if you hame numbits=12 and length=2 | 64 | * What this means is that if you hame numbits=12 and length=2 |
| @@ -76,7 +77,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
| 76 | register int num=numbits/8,n=(numbits+7)/8,i,rem=numbits%8; | 77 | register int num=numbits/8,n=(numbits+7)/8,i,rem=numbits%8; |
| 77 | DES_LONG ti[2]; | 78 | DES_LONG ti[2]; |
| 78 | unsigned char *iv; | 79 | unsigned char *iv; |
| 79 | #ifndef L_ENDIAN | 80 | #if _BYTE_ORDER != _LITTLE_ENDIAN |
| 80 | unsigned char ovec[16]; | 81 | unsigned char ovec[16]; |
| 81 | #else | 82 | #else |
| 82 | unsigned int sh[4]; | 83 | unsigned int sh[4]; |
| @@ -114,7 +115,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
| 114 | { v0=d0; v1=d1; } | 115 | { v0=d0; v1=d1; } |
| 115 | else | 116 | else |
| 116 | { | 117 | { |
| 117 | #ifndef L_ENDIAN | 118 | #if _BYTE_ORDER != _LITTLE_ENDIAN |
| 118 | iv=&ovec[0]; | 119 | iv=&ovec[0]; |
| 119 | l2c(v0,iv); | 120 | l2c(v0,iv); |
| 120 | l2c(v1,iv); | 121 | l2c(v1,iv); |
| @@ -129,7 +130,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
| 129 | for(i=0 ; i < 8 ; ++i) | 130 | for(i=0 ; i < 8 ; ++i) |
| 130 | ovec[i]=ovec[i+num]<<rem | | 131 | ovec[i]=ovec[i+num]<<rem | |
| 131 | ovec[i+num+1]>>(8-rem); | 132 | ovec[i+num+1]>>(8-rem); |
| 132 | #ifdef L_ENDIAN | 133 | #if _BYTE_ORDER == _LITTLE_ENDIAN |
| 133 | v0=sh[0], v1=sh[1]; | 134 | v0=sh[0], v1=sh[1]; |
| 134 | #else | 135 | #else |
| 135 | iv=&ovec[0]; | 136 | iv=&ovec[0]; |
| @@ -157,7 +158,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
| 157 | { v0=d0; v1=d1; } | 158 | { v0=d0; v1=d1; } |
| 158 | else | 159 | else |
| 159 | { | 160 | { |
| 160 | #ifndef L_ENDIAN | 161 | #if _BYTE_ORDER != _LITTLE_ENDIAN |
| 161 | iv=&ovec[0]; | 162 | iv=&ovec[0]; |
| 162 | l2c(v0,iv); | 163 | l2c(v0,iv); |
| 163 | l2c(v1,iv); | 164 | l2c(v1,iv); |
| @@ -172,7 +173,7 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
| 172 | for(i=0 ; i < 8 ; ++i) | 173 | for(i=0 ; i < 8 ; ++i) |
| 173 | ovec[i]=ovec[i+num]<<rem | | 174 | ovec[i]=ovec[i+num]<<rem | |
| 174 | ovec[i+num+1]>>(8-rem); | 175 | ovec[i+num+1]>>(8-rem); |
| 175 | #ifdef L_ENDIAN | 176 | #if _BYTE_ORDER == _LITTLE_ENDIAN |
| 176 | v0=sh[0], v1=sh[1]; | 177 | v0=sh[0], v1=sh[1]; |
| 177 | #else | 178 | #else |
| 178 | iv=&ovec[0]; | 179 | iv=&ovec[0]; |
diff --git a/src/lib/libssl/src/crypto/sha/sha512.c b/src/lib/libssl/src/crypto/sha/sha512.c index c92f18e418..49afaa05c2 100644 --- a/src/lib/libssl/src/crypto/sha/sha512.c +++ b/src/lib/libssl/src/crypto/sha/sha512.c | |||
| @@ -43,6 +43,7 @@ | |||
| 43 | */ | 43 | */ |
| 44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
| 45 | #include <string.h> | 45 | #include <string.h> |
| 46 | #include <machine/endian.h> | ||
| 46 | 47 | ||
| 47 | #include <openssl/crypto.h> | 48 | #include <openssl/crypto.h> |
| 48 | #include <openssl/sha.h> | 49 | #include <openssl/sha.h> |
| @@ -108,7 +109,7 @@ int SHA512_Final (unsigned char *md, SHA512_CTX *c) | |||
| 108 | sha512_block_data_order (c,p,1); | 109 | sha512_block_data_order (c,p,1); |
| 109 | 110 | ||
| 110 | memset (p+n,0,sizeof(c->u)-16-n); | 111 | memset (p+n,0,sizeof(c->u)-16-n); |
| 111 | #ifdef B_ENDIAN | 112 | #if _BYTE_ORDER == _BIG_ENDIAN |
| 112 | c->u.d[SHA_LBLOCK-2] = c->Nh; | 113 | c->u.d[SHA_LBLOCK-2] = c->Nh; |
| 113 | c->u.d[SHA_LBLOCK-1] = c->Nl; | 114 | c->u.d[SHA_LBLOCK-1] = c->Nl; |
| 114 | #else | 115 | #else |
| @@ -437,7 +438,7 @@ static void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num | |||
| 437 | 438 | ||
| 438 | for (i=0;i<16;i++) | 439 | for (i=0;i<16;i++) |
| 439 | { | 440 | { |
| 440 | #ifdef B_ENDIAN | 441 | #if _BYTE_ORDER == _BIG_ENDIAN |
| 441 | T1 = X[i] = W[i]; | 442 | T1 = X[i] = W[i]; |
| 442 | #else | 443 | #else |
| 443 | T1 = X[i] = PULL64(W[i]); | 444 | T1 = X[i] = PULL64(W[i]); |
| @@ -492,7 +493,7 @@ static void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num | |||
| 492 | a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3]; | 493 | a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; d = ctx->h[3]; |
| 493 | e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7]; | 494 | e = ctx->h[4]; f = ctx->h[5]; g = ctx->h[6]; h = ctx->h[7]; |
| 494 | 495 | ||
| 495 | #ifdef B_ENDIAN | 496 | #if _BYTE_ORDER == _BIG_ENDIAN |
| 496 | T1 = X[0] = W[0]; ROUND_00_15(0,a,b,c,d,e,f,g,h); | 497 | T1 = X[0] = W[0]; ROUND_00_15(0,a,b,c,d,e,f,g,h); |
| 497 | T1 = X[1] = W[1]; ROUND_00_15(1,h,a,b,c,d,e,f,g); | 498 | T1 = X[1] = W[1]; ROUND_00_15(1,h,a,b,c,d,e,f,g); |
| 498 | T1 = X[2] = W[2]; ROUND_00_15(2,g,h,a,b,c,d,e,f); | 499 | T1 = X[2] = W[2]; ROUND_00_15(2,g,h,a,b,c,d,e,f); |
diff --git a/src/lib/libssl/src/crypto/whrlpool/wp_block.c b/src/lib/libssl/src/crypto/whrlpool/wp_block.c index fadad01401..11164e50f5 100644 --- a/src/lib/libssl/src/crypto/whrlpool/wp_block.c +++ b/src/lib/libssl/src/crypto/whrlpool/wp_block.c | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | 37 | ||
| 38 | #include "wp_locl.h" | 38 | #include "wp_locl.h" |
| 39 | #include <string.h> | 39 | #include <string.h> |
| 40 | #include <machine/endian.h> | ||
| 40 | 41 | ||
| 41 | typedef unsigned char u8; | 42 | typedef unsigned char u8; |
| 42 | #if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32) | 43 | #if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32) |
| @@ -82,10 +83,10 @@ typedef unsigned long long u64; | |||
| 82 | # define ROTATE(a,n) ({ u64 ret; asm ("rolq %1,%0" \ | 83 | # define ROTATE(a,n) ({ u64 ret; asm ("rolq %1,%0" \ |
| 83 | : "=r"(ret) : "J"(n),"0"(a) : "cc"); ret; }) | 84 | : "=r"(ret) : "J"(n),"0"(a) : "cc"); ret; }) |
| 84 | # elif defined(__ia64) || defined(__ia64__) | 85 | # elif defined(__ia64) || defined(__ia64__) |
| 85 | # if defined(L_ENDIAN) | 86 | # if _BYTE_ORDER == _LITTLE_ENDIAN |
| 86 | # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ | 87 | # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ |
| 87 | : "=r"(ret) : "r"(a),"M"(64-(n))); ret; }) | 88 | : "=r"(ret) : "r"(a),"M"(64-(n))); ret; }) |
| 88 | # elif defined(B_ENDIAN) | 89 | # else |
| 89 | # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ | 90 | # define ROTATE(a,n) ({ u64 ret; asm ("shrp %0=%1,%1,%2" \ |
| 90 | : "=r"(ret) : "r"(a),"M"(n)); ret; }) | 91 | : "=r"(ret) : "r"(a),"M"(n)); ret; }) |
| 91 | # endif | 92 | # endif |
| @@ -94,9 +95,9 @@ typedef unsigned long long u64; | |||
| 94 | 95 | ||
| 95 | #if defined(OPENSSL_SMALL_FOOTPRINT) | 96 | #if defined(OPENSSL_SMALL_FOOTPRINT) |
| 96 | # if !defined(ROTATE) | 97 | # if !defined(ROTATE) |
| 97 | # if defined(L_ENDIAN) /* little-endians have to rotate left */ | 98 | # if _BYTE_ORDER == _LITTLE_ENDIAN /* little-endians have to rotate left */ |
| 98 | # define ROTATE(i,n) ((i)<<(n) ^ (i)>>(64-n)) | 99 | # define ROTATE(i,n) ((i)<<(n) ^ (i)>>(64-n)) |
| 99 | # elif defined(B_ENDIAN) /* big-endians have to rotate right */ | 100 | # else /* big-endians have to rotate right */ |
| 100 | # define ROTATE(i,n) ((i)>>(n) ^ (i)<<(64-n)) | 101 | # define ROTATE(i,n) ((i)>>(n) ^ (i)<<(64-n)) |
| 101 | # endif | 102 | # endif |
| 102 | # endif | 103 | # endif |
