From b27e6c5874a6c4fa708021992a8a57e71841be39 Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 26 Jan 2024 14:23:06 -0800 Subject: [PATCH 1/2] Remove unused `XHTONS` and `arpa/inet.h`. --- wolftpm/tpm2_types.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/wolftpm/tpm2_types.h b/wolftpm/tpm2_types.h index 7f4b93da..cd7d0cf9 100644 --- a/wolftpm/tpm2_types.h +++ b/wolftpm/tpm2_types.h @@ -134,7 +134,6 @@ typedef int64_t INT64; #include #include #include - #include #ifdef WOLFTPM_USER_SETTINGS #include "user_settings.h" @@ -231,20 +230,6 @@ typedef int64_t INT64; #ifndef WOLFTPM_CUSTOM_TYPES #include - #ifndef XHTONS - /* WOLFCRYPT_ONLY means no wolfio and no arpa/inet.h */ - #ifdef WOLFCRYPT_ONLY - #ifdef BIG_ENDIAN_ORDER - #define XHTONS(s) (s) - #else - #define XHTONS(s) ((((s) & 0xff) << 8) | (((s) & 0xff00) >> 8)) - #endif - #else - #include - #define XHTONS(s) htons((s)) - #endif - #endif - #define XSTRTOL(s,e,b) strtol((s),(e),(b)) #define XATOI(s) atoi((s)) From a2a45d2a3d64c66b6b044f222fcc4aac4b7ce87c Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 26 Jan 2024 14:26:45 -0800 Subject: [PATCH 2/2] Match byte swap logic with wolfSSL (use WOLF_ALLOW_BUILTIN). --- wolftpm/tpm2_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wolftpm/tpm2_types.h b/wolftpm/tpm2_types.h index cd7d0cf9..ded3f009 100644 --- a/wolftpm/tpm2_types.h +++ b/wolftpm/tpm2_types.h @@ -703,7 +703,7 @@ static inline word16 ByteReverseWord16(word16 value) static inline word32 ByteReverseWord32(word32 value) { -#if !defined(WOLF_NO_BUILTIN) && defined(__GNUC_PREREQ) && __GNUC_PREREQ(4, 3) +#if defined(WOLF_ALLOW_BUILTIN) && defined(__GNUC_PREREQ) && __GNUC_PREREQ(4, 3) return (word32)__builtin_bswap32(value); #elif defined(PPC_INTRINSICS) /* PPC: load reverse indexed instruction */ @@ -743,7 +743,7 @@ static inline word32 ByteReverseWord32(word32 value) static inline word64 ByteReverseWord64(word64 value) { -#if !defined(WOLF_NO_BUILTIN) && defined(__GNUC_PREREQ) && __GNUC_PREREQ(4, 3) +#if defined(WOLF_ALLOW_BUILTIN) && defined(__GNUC_PREREQ) && __GNUC_PREREQ(4, 3) return (word64)__builtin_bswap64(value); #else return (word64)((word64)ByteReverseWord32((word32)value)) << 32 |