than defining it for not (i386 and amd64 (and sometimes s390)) only.
Compile-time tests remain compile-time tests, and runtime-test remain
runtime-test instead of being converted to compile-time tests, per matthew@'s
explicit demand (rationale: this makes sure the compiler checks your code even
if you won't run it).
No functional change except on s390 (which we don't run on) and vax (which we
run on, but noone cares about)
ok matthew@
#endif
#include <assert.h>
-#ifndef STRICT_ALIGNMENT
-# define STRICT_ALIGNMENT 0
+#undef STRICT_ALIGNMENT
+#ifdef __STRICT_ALIGNMENT
+#define STRICT_ALIGNMENT 1
+#else
+#define STRICT_ALIGNMENT 0
#endif
void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,
in += 16;
out += 16;
}
- }
- else if (16%sizeof(size_t) == 0) { /* always true */
+ } else if (16%sizeof(size_t) == 0) { /* always true */
while (len>=16) {
size_t *out_t=(size_t *)out, *iv_t=(size_t *)iv;
in += 16;
out += 16;
}
- }
- else if (16%sizeof(size_t) == 0) { /* always true */
+ } else if (16%sizeof(size_t) == 0) { /* always true */
while (len>=16) {
size_t c, *out_t=(size_t *)out, *ivec_t=(size_t *)ivec;
const size_t *in_t=(const size_t *)in;
if (ctx->blocks > (U64(1)<<61)) return -2; /* too much data */
while (len>=16) {
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
union { u64 u[2]; u8 c[16]; } temp;
memcpy (temp.c,inp,16);
(*block)(ctx->cmac.c,ctx->cmac.c,key);
(*block)(ctx->nonce.c,scratch.c,key);
ctr64_inc(ctx->nonce.c);
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
temp.u[0] ^= scratch.u[0];
temp.u[1] ^= scratch.u[1];
memcpy(out,temp.c,16);
if (n!=len) return -1;
while (len>=16) {
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
union { u64 u[2]; u8 c[16]; } temp;
#endif
(*block)(ctx->nonce.c,scratch.c,key);
ctr64_inc(ctx->nonce.c);
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
memcpy (temp.c,inp,16);
ctx->cmac.u[0] ^= (scratch.u[0] ^= temp.u[0]);
ctx->cmac.u[1] ^= (scratch.u[1] ^= temp.u[1]);
--len;
n = (n+1) % 16;
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
if (((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0)
break;
#endif
--len;
n = (n+1) % 16;
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
if (((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0)
break;
#endif
n = (n+1) % 16;
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
if (((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0)
break;
#endif
#endif
#include <assert.h>
-#if defined(BSWAP4) && defined(STRICT_ALIGNMENT)
+#if defined(BSWAP4) && defined(__STRICT_ALIGNMENT)
/* redefine, because alignment is ensured */
#undef GETU32
#define GETU32(p) BSWAP4(*(const u32 *)(p))
return 0;
}
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
if (((size_t)in|(size_t)out)%sizeof(size_t) != 0)
break;
#endif
return 0;
}
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
if (((size_t)in|(size_t)out)%sizeof(size_t) != 0)
break;
#endif
typedef unsigned int u32;
typedef unsigned char u8;
-#define STRICT_ALIGNMENT 1
-#if defined(__i386) || defined(__i386__) || \
- defined(__x86_64) || defined(__x86_64__) || \
- defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \
- defined(__s390__) || defined(__s390x__)
-# undef STRICT_ALIGNMENT
-#endif
-
#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
#if defined(__GNUC__) && __GNUC__>=2
# if defined(__x86_64) || defined(__x86_64__)
# define BSWAP4(x) ({ u32 ret=(x); \
asm ("bswapl %0" \
: "+r"(ret)); ret; })
-# elif (defined(__arm__) || defined(__arm)) && !defined(STRICT_ALIGNMENT)
+# elif (defined(__arm__) || defined(__arm)) && !defined(__STRICT_ALIGNMENT)
# define BSWAP8(x) ({ u32 lo=(u64)(x)>>32,hi=(x); \
asm ("rev %0,%0; rev %1,%1" \
: "+r"(hi),"+r"(lo)); \
#endif
#endif
-#if defined(BSWAP4) && !defined(STRICT_ALIGNMENT)
+#if defined(BSWAP4) && !defined(__STRICT_ALIGNMENT)
#define GETU32(p) BSWAP4(*(const u32 *)(p))
#define PUTU32(p,v) *(u32 *)(p) = BSWAP4(v)
#else
--len;
n = (n+1) % 16;
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
if (((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0)
break;
#endif
* ====================================================================
*/
+#include <machine/endian.h>
#include <openssl/crypto.h>
#include "modes_lcl.h"
#include <string.h>
if (!enc && (len%16)) len-=16;
while (len>=16) {
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
memcpy(scratch.c,inp,16);
scratch.u[0] ^= tweak.u[0];
scratch.u[1] ^= tweak.u[1];
scratch.u[1] = ((u64*)inp)[1]^tweak.u[1];
#endif
(*ctx->block1)(scratch.c,scratch.c,ctx->key1);
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
scratch.u[0] ^= tweak.u[0];
scratch.u[1] ^= tweak.u[1];
memcpy(out,scratch.c,16);
}
tweak1.c[0] ^= (u8)(0x87&(0-c));
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
memcpy(scratch.c,inp,16);
scratch.u[0] ^= tweak1.u[0];
scratch.u[1] ^= tweak1.u[1];
scratch.u[0] ^= tweak.u[0];
scratch.u[1] ^= tweak.u[1];
(*ctx->block1)(scratch.c,scratch.c,ctx->key1);
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
scratch.u[0] ^= tweak.u[0];
scratch.u[1] ^= tweak.u[1];
memcpy (out,scratch.c,16);
const char SHA512_version[]="SHA-512" OPENSSL_VERSION_PTEXT;
-#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
- defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || \
- defined(__s390__) || defined(__s390x__) || \
- defined(SHA512_ASM)
+#if !defined(__STRICT_ALIGNMENT) || defined(SHA512_ASM)
#define SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA
#endif
#endif
#include <assert.h>
-#ifndef STRICT_ALIGNMENT
-# define STRICT_ALIGNMENT 0
+#undef STRICT_ALIGNMENT
+#ifdef __STRICT_ALIGNMENT
+#define STRICT_ALIGNMENT 1
+#else
+#define STRICT_ALIGNMENT 0
#endif
void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,
in += 16;
out += 16;
}
- }
- else if (16%sizeof(size_t) == 0) { /* always true */
+ } else if (16%sizeof(size_t) == 0) { /* always true */
while (len>=16) {
size_t *out_t=(size_t *)out, *iv_t=(size_t *)iv;
in += 16;
out += 16;
}
- }
- else if (16%sizeof(size_t) == 0) { /* always true */
+ } else if (16%sizeof(size_t) == 0) { /* always true */
while (len>=16) {
size_t c, *out_t=(size_t *)out, *ivec_t=(size_t *)ivec;
const size_t *in_t=(const size_t *)in;
if (ctx->blocks > (U64(1)<<61)) return -2; /* too much data */
while (len>=16) {
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
union { u64 u[2]; u8 c[16]; } temp;
memcpy (temp.c,inp,16);
(*block)(ctx->cmac.c,ctx->cmac.c,key);
(*block)(ctx->nonce.c,scratch.c,key);
ctr64_inc(ctx->nonce.c);
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
temp.u[0] ^= scratch.u[0];
temp.u[1] ^= scratch.u[1];
memcpy(out,temp.c,16);
if (n!=len) return -1;
while (len>=16) {
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
union { u64 u[2]; u8 c[16]; } temp;
#endif
(*block)(ctx->nonce.c,scratch.c,key);
ctr64_inc(ctx->nonce.c);
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
memcpy (temp.c,inp,16);
ctx->cmac.u[0] ^= (scratch.u[0] ^= temp.u[0]);
ctx->cmac.u[1] ^= (scratch.u[1] ^= temp.u[1]);
--len;
n = (n+1) % 16;
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
if (((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0)
break;
#endif
--len;
n = (n+1) % 16;
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
if (((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0)
break;
#endif
n = (n+1) % 16;
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
if (((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0)
break;
#endif
#endif
#include <assert.h>
-#if defined(BSWAP4) && defined(STRICT_ALIGNMENT)
+#if defined(BSWAP4) && defined(__STRICT_ALIGNMENT)
/* redefine, because alignment is ensured */
#undef GETU32
#define GETU32(p) BSWAP4(*(const u32 *)(p))
return 0;
}
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
if (((size_t)in|(size_t)out)%sizeof(size_t) != 0)
break;
#endif
return 0;
}
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
if (((size_t)in|(size_t)out)%sizeof(size_t) != 0)
break;
#endif
typedef unsigned int u32;
typedef unsigned char u8;
-#define STRICT_ALIGNMENT 1
-#if defined(__i386) || defined(__i386__) || \
- defined(__x86_64) || defined(__x86_64__) || \
- defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \
- defined(__s390__) || defined(__s390x__)
-# undef STRICT_ALIGNMENT
-#endif
-
#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
#if defined(__GNUC__) && __GNUC__>=2
# if defined(__x86_64) || defined(__x86_64__)
# define BSWAP4(x) ({ u32 ret=(x); \
asm ("bswapl %0" \
: "+r"(ret)); ret; })
-# elif (defined(__arm__) || defined(__arm)) && !defined(STRICT_ALIGNMENT)
+# elif (defined(__arm__) || defined(__arm)) && !defined(__STRICT_ALIGNMENT)
# define BSWAP8(x) ({ u32 lo=(u64)(x)>>32,hi=(x); \
asm ("rev %0,%0; rev %1,%1" \
: "+r"(hi),"+r"(lo)); \
#endif
#endif
-#if defined(BSWAP4) && !defined(STRICT_ALIGNMENT)
+#if defined(BSWAP4) && !defined(__STRICT_ALIGNMENT)
#define GETU32(p) BSWAP4(*(const u32 *)(p))
#define PUTU32(p,v) *(u32 *)(p) = BSWAP4(v)
#else
--len;
n = (n+1) % 16;
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
if (((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0)
break;
#endif
* ====================================================================
*/
+#include <machine/endian.h>
#include <openssl/crypto.h>
#include "modes_lcl.h"
#include <string.h>
if (!enc && (len%16)) len-=16;
while (len>=16) {
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
memcpy(scratch.c,inp,16);
scratch.u[0] ^= tweak.u[0];
scratch.u[1] ^= tweak.u[1];
scratch.u[1] = ((u64*)inp)[1]^tweak.u[1];
#endif
(*ctx->block1)(scratch.c,scratch.c,ctx->key1);
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
scratch.u[0] ^= tweak.u[0];
scratch.u[1] ^= tweak.u[1];
memcpy(out,scratch.c,16);
}
tweak1.c[0] ^= (u8)(0x87&(0-c));
}
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
memcpy(scratch.c,inp,16);
scratch.u[0] ^= tweak1.u[0];
scratch.u[1] ^= tweak1.u[1];
scratch.u[0] ^= tweak.u[0];
scratch.u[1] ^= tweak.u[1];
(*ctx->block1)(scratch.c,scratch.c,ctx->key1);
-#if defined(STRICT_ALIGNMENT)
+#ifdef __STRICT_ALIGNMENT
scratch.u[0] ^= tweak.u[0];
scratch.u[1] ^= tweak.u[1];
memcpy (out,scratch.c,16);
const char SHA512_version[]="SHA-512" OPENSSL_VERSION_PTEXT;
-#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
- defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || \
- defined(__s390__) || defined(__s390x__) || \
- defined(SHA512_ASM)
+#if !defined(__STRICT_ALIGNMENT) || defined(SHA512_ASM)
#define SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA
#endif