summaryrefslogtreecommitdiffstats
path: root/crypto/modes/xts128.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-07-09 08:37:46 +0200
committerRichard Levitte <levitte@openssl.org>2020-07-11 10:00:33 +0200
commite23d850ff3281220f33ed78d9ca4fcadfa279565 (patch)
tree4e7f73d978bb1a7986e0ac27ee61bdab23d66ed2 /crypto/modes/xts128.c
parentd685fc7a59699aeb17120aebd17a9175ce5930cd (diff)
Add and use internal header that implements endianness check
This moves test/ossl_test_endian.h to include/internal/endian.h and thereby makes the macros in there our standard way to check endianness in run-time. Reviewed-by: Kurt Roeckx <kurt@roeckx.be> (Merged from https://github.com/openssl/openssl/pull/12390)
Diffstat (limited to 'crypto/modes/xts128.c')
-rw-r--r--crypto/modes/xts128.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/crypto/modes/xts128.c b/crypto/modes/xts128.c
index 0dec42c310..55b81366bf 100644
--- a/crypto/modes/xts128.c
+++ b/crypto/modes/xts128.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <openssl/crypto.h>
+#include "internal/endian.h"
#include "crypto/modes.h"
#ifndef STRICT_ALIGNMENT
@@ -24,12 +25,7 @@ int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx,
const unsigned char *inp, unsigned char *out,
size_t len, int enc)
{
- const union {
- long one;
- char little;
- } is_endian = {
- 1
- };
+ DECLARE_IS_ENDIAN;
union {
u64 u[2];
u32 d[4];
@@ -72,7 +68,7 @@ int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx,
if (len == 0)
return 0;
- if (is_endian.little) {
+ if (IS_LITTLE_ENDIAN) {
unsigned int carry, res;
res = 0x87 & (((int)tweak.d[3]) >> 31);
@@ -111,7 +107,7 @@ int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx,
u8 c[16];
} tweak1;
- if (is_endian.little) {
+ if (IS_LITTLE_ENDIAN) {
unsigned int carry, res;
res = 0x87 & (((int)tweak.d[3]) >> 31);