mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
fix byte-order definition checks
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
17afc17d02
commit
a38af51159
2 changed files with 19 additions and 19 deletions
2
src/3rdparty/digest/sha1.c
vendored
2
src/3rdparty/digest/sha1.c
vendored
|
@ -32,7 +32,7 @@
|
|||
* blk0() and blk() perform the initial expand.
|
||||
* I got the idea of expanding during the round function from SSLeay
|
||||
*/
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
#if __BYTE_ORDER__ != __BIG_ENDIAN__
|
||||
# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|
||||
|(rol(block->l[i],8)&0x00FF00FF))
|
||||
#else
|
||||
|
|
36
src/3rdparty/digest/sha2.c
vendored
36
src/3rdparty/digest/sha2.c
vendored
|
@ -69,7 +69,7 @@
|
|||
|
||||
|
||||
/*** ENDIAN REVERSAL MACROS *******************************************/
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
#if __BYTE_ORDER__ != __BIG_ENDIAN__
|
||||
#define REVERSE32(w,x) { \
|
||||
sha2_word32 tmp = (w); \
|
||||
tmp = (tmp >> 16) | (tmp << 16); \
|
||||
|
@ -83,7 +83,7 @@
|
|||
(x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \
|
||||
((tmp & 0x0000ffff0000ffffULL) << 16); \
|
||||
}
|
||||
#endif /* Q_BYTE_ORDER */
|
||||
#endif /* __BYTE_ORDER__ */
|
||||
|
||||
/*
|
||||
* Macro for incrementally adding the unsigned 64-bit integer n to the
|
||||
|
@ -284,7 +284,7 @@ void SHA256_Init(SHA256_CTX* context) {
|
|||
|
||||
/* Unrolled SHA-256 round macros: */
|
||||
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
#if __BYTE_ORDER__ != __BIG_ENDIAN__
|
||||
|
||||
#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \
|
||||
REVERSE32(*data++, W256[j]); \
|
||||
|
@ -295,7 +295,7 @@ void SHA256_Init(SHA256_CTX* context) {
|
|||
j++
|
||||
|
||||
|
||||
#else /* Q_BYTE_ORDER */
|
||||
#else /* __BYTE_ORDER__ */
|
||||
|
||||
#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \
|
||||
T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \
|
||||
|
@ -304,7 +304,7 @@ void SHA256_Init(SHA256_CTX* context) {
|
|||
(h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
|
||||
j++
|
||||
|
||||
#endif /* Q_BYTE_ORDER */
|
||||
#endif /* __BYTE_ORDER__ */
|
||||
|
||||
#define ROUND256(a,b,c,d,e,f,g,h) \
|
||||
s0 = W256[(j+1)&0x0f]; \
|
||||
|
@ -394,15 +394,15 @@ void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
|
|||
|
||||
j = 0;
|
||||
do {
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
#if __BYTE_ORDER__ != __BIG_ENDIAN__
|
||||
/* Copy data while converting to host byte order */
|
||||
REVERSE32(*data++,W256[j]);
|
||||
/* Apply the SHA-256 compression function to update a..h */
|
||||
T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + W256[j];
|
||||
#else /* Q_BYTE_ORDER */
|
||||
#else /* __BYTE_ORDER__ */
|
||||
/* Apply the SHA-256 compression function to update a..h with copy */
|
||||
T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j] = *data++);
|
||||
#endif /* Q_BYTE_ORDER */
|
||||
#endif /* __BYTE_ORDER__ */
|
||||
T2 = Sigma0_256(a) + Maj(a, b, c);
|
||||
h = g;
|
||||
g = f;
|
||||
|
@ -514,7 +514,7 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
|
|||
/* If no digest buffer is passed, we don't bother doing this: */
|
||||
if (digest != (sha2_byte*)0) {
|
||||
usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH;
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
#if __BYTE_ORDER__ != __BIG_ENDIAN__
|
||||
/* Convert FROM host byte order */
|
||||
REVERSE64(context->bitcount,context->bitcount);
|
||||
#endif
|
||||
|
@ -549,7 +549,7 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
|
|||
/* Final transform: */
|
||||
SHA256_Transform(context, (sha2_word32*)context->buffer);
|
||||
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
#if __BYTE_ORDER__ != __BIG_ENDIAN__
|
||||
{
|
||||
/* Convert TO host byte order */
|
||||
int j;
|
||||
|
@ -581,7 +581,7 @@ void SHA512_Init(SHA512_CTX* context) {
|
|||
#ifdef SHA2_UNROLL_TRANSFORM
|
||||
|
||||
/* Unrolled SHA-512 round macros: */
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
#if __BYTE_ORDER__ != __BIG_ENDIAN__
|
||||
|
||||
#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \
|
||||
REVERSE64(*data++, W512[j]); \
|
||||
|
@ -592,7 +592,7 @@ void SHA512_Init(SHA512_CTX* context) {
|
|||
j++
|
||||
|
||||
|
||||
#else /* Q_BYTE_ORDER */
|
||||
#else /* __BYTE_ORDER__ */
|
||||
|
||||
#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \
|
||||
T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \
|
||||
|
@ -601,7 +601,7 @@ void SHA512_Init(SHA512_CTX* context) {
|
|||
(h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
|
||||
j++
|
||||
|
||||
#endif /* Q_BYTE_ORDER */
|
||||
#endif /* __BYTE_ORDER__ */
|
||||
|
||||
#define ROUND512(a,b,c,d,e,f,g,h) \
|
||||
s0 = W512[(j+1)&0x0f]; \
|
||||
|
@ -686,7 +686,7 @@ void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
|
|||
|
||||
j = 0;
|
||||
do {
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
#if __BYTE_ORDER__ != __BIG_ENDIAN__
|
||||
/* Convert TO host byte order */
|
||||
REVERSE64(*data++, W512[j]);
|
||||
/* Apply the SHA-512 compression function to update a..h */
|
||||
|
@ -694,7 +694,7 @@ void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
|
|||
#else
|
||||
/* Apply the SHA-512 compression function to update a..h with copy */
|
||||
T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++);
|
||||
#endif /* Q_BYTE_ORDER */
|
||||
#endif /* __BYTE_ORDER__ */
|
||||
T2 = Sigma0_512(a) + Maj(a, b, c);
|
||||
h = g;
|
||||
g = f;
|
||||
|
@ -801,7 +801,7 @@ void SHA512_Last(SHA512_CTX* context) {
|
|||
unsigned int usedspace;
|
||||
|
||||
usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH;
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
#if __BYTE_ORDER__ != __BIG_ENDIAN__
|
||||
/* Convert FROM host byte order */
|
||||
REVERSE64(context->bitcount[0],context->bitcount[0]);
|
||||
REVERSE64(context->bitcount[1],context->bitcount[1]);
|
||||
|
@ -849,7 +849,7 @@ void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
|
|||
SHA512_Last(context);
|
||||
|
||||
/* Save the hash data for output: */
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
#if __BYTE_ORDER__ != __BIG_ENDIAN__
|
||||
{
|
||||
/* Convert TO host byte order */
|
||||
int j;
|
||||
|
@ -894,7 +894,7 @@ void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
|
|||
SHA512_Last((SHA512_CTX*)context);
|
||||
|
||||
/* Save the hash data for output: */
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
#if __BYTE_ORDER__ != __BIG_ENDIAN__
|
||||
{
|
||||
/* Convert TO host byte order */
|
||||
int j;
|
||||
|
|
Loading…
Add table
Reference in a new issue