From 438f04066bb6333dcb219205a09501ee50fdd993 Mon Sep 17 00:00:00 2001 From: Vitaly Lavrov Date: Sat, 5 Mar 2022 13:44:21 +0300 Subject: Fixed a bug for BE architectures (#1478) Fixed a bug in the internal implementation of libgcrypt for bigendian architectures --- src/lib/third_party/include/gcrypt/common.h | 4 ++-- src/lib/third_party/src/gcrypt/cipher_wrap.c | 18 ------------------ 2 files changed, 2 insertions(+), 20 deletions(-) (limited to 'src/lib/third_party') diff --git a/src/lib/third_party/include/gcrypt/common.h b/src/lib/third_party/include/gcrypt/common.h index d25031bb5..ba6a654ab 100644 --- a/src/lib/third_party/include/gcrypt/common.h +++ b/src/lib/third_party/include/gcrypt/common.h @@ -94,9 +94,9 @@ #elif defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) -#define MBEDTLS_GET_UINT32_LE(b,i) htonl(*(uint32_t *) (&(b)[(i)])) +#define MBEDTLS_GET_UINT32_LE(b,i) bswap_32(*(uint32_t *) (&(b)[(i)])) #define MBEDTLS_GET_UINT32_BE(b,i) (*(uint32_t *) (&(b)[(i)])) -#define MBEDTLS_PUT_UINT32_LE(n,b,i) *(uint32_t *) (&(b)[(i)]) = htonl(n); +#define MBEDTLS_PUT_UINT32_LE(n,b,i) *(uint32_t *) (&(b)[(i)]) = bswap_32(n); #define MBEDTLS_PUT_UINT64_BE(n,b,i) *(uint64_t *) (&(b)[(i)]) = (n); #else diff --git a/src/lib/third_party/src/gcrypt/cipher_wrap.c b/src/lib/third_party/src/gcrypt/cipher_wrap.c index 6db209cba..5e3e679aa 100644 --- a/src/lib/third_party/src/gcrypt/cipher_wrap.c +++ b/src/lib/third_party/src/gcrypt/cipher_wrap.c @@ -42,24 +42,6 @@ static int aes_setkey_enc_wrap( void *ctx, const unsigned char *key, return mbedtls_aes_setkey_enc( (mbedtls_aes_context *) ctx, key, key_bitlen ); } -static void * aes_ctx_alloc( void ) -{ - mbedtls_aes_context *aes = mbedtls_calloc( 1, sizeof( mbedtls_aes_context ) ); - - if( aes == NULL ) - return( NULL ); - - mbedtls_aes_init( aes ); - - return( aes ); -} - -static void aes_ctx_free( void *ctx ) -{ - mbedtls_aes_free( (mbedtls_aes_context *) ctx ); - mbedtls_free( ctx ); -} - static void aes_ctx_zero( void *ctx ) { mbedtls_aes_init( (mbedtls_aes_context *) ctx ); -- cgit v1.2.3