diff options
author | Richard Levitte <levitte@openssl.org> | 2020-07-09 08:37:46 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-07-11 10:00:33 +0200 |
commit | e23d850ff3281220f33ed78d9ca4fcadfa279565 (patch) | |
tree | 4e7f73d978bb1a7986e0ac27ee61bdab23d66ed2 /providers/implementations/ciphers | |
parent | d685fc7a59699aeb17120aebd17a9175ce5930cd (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 'providers/implementations/ciphers')
-rw-r--r-- | providers/implementations/ciphers/cipher_chacha20_poly1305_hw.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/providers/implementations/ciphers/cipher_chacha20_poly1305_hw.c b/providers/implementations/ciphers/cipher_chacha20_poly1305_hw.c index 70ffaf1588..bd99a9fb4e 100644 --- a/providers/implementations/ciphers/cipher_chacha20_poly1305_hw.c +++ b/providers/implementations/ciphers/cipher_chacha20_poly1305_hw.c @@ -9,6 +9,7 @@ /* chacha20_poly1305 cipher implementation */ +#include "internal/endian.h" #include "cipher_chacha20_poly1305.h" static int chacha_poly1305_tls_init(PROV_CIPHER_CTX *bctx, @@ -117,10 +118,7 @@ static int chacha20_poly1305_tls_cipher(PROV_CIPHER_CTX *bctx, size_t tail, tohash_len, buf_len, plen = ctx->tls_payload_length; unsigned char *buf, *tohash, *ctr, storage[sizeof(zero) + 32]; - const union { - long one; - char little; - } is_endian = { 1 }; + DECLARE_IS_ENDIAN; if (len != plen + POLY1305_BLOCK_SIZE) return 0; @@ -214,7 +212,7 @@ static int chacha20_poly1305_tls_cipher(PROV_CIPHER_CTX *bctx, Poly1305_Update(poly, zero, tail); } - if (is_endian.little) { + if (IS_LITTLE_ENDIAN) { memcpy(ctr, (unsigned char *)&ctx->len, POLY1305_BLOCK_SIZE); } else { ctr[0] = (unsigned char)(ctx->len.aad); @@ -273,10 +271,7 @@ static int chacha20_poly1305_aead_cipher(PROV_CIPHER_CTX *bctx, size_t olen = 0; int rv = 0; - const union { - long one; - char little; - } is_endian = { 1 }; + DECLARE_IS_ENDIAN; if (!ctx->mac_inited) { #if !defined(OPENSSL_SMALL_FOOTPRINT) @@ -347,7 +342,7 @@ static int chacha20_poly1305_aead_cipher(PROV_CIPHER_CTX *bctx, if ((rem = (size_t)ctx->len.text % POLY1305_BLOCK_SIZE)) Poly1305_Update(poly, zero, POLY1305_BLOCK_SIZE - rem); - if (is_endian.little) { + if (IS_LITTLE_ENDIAN) { Poly1305_Update(poly, (unsigned char *)&ctx->len, POLY1305_BLOCK_SIZE); } else { |