From e7e1292f8a330687281ab73523880376c6faf184 Mon Sep 17 00:00:00 2001 From: Bryan Hunt Date: Fri, 11 Feb 2022 08:25:42 -0800 Subject: [PATCH 1/2] Don't attempt to pack structures with pointers - should fix aarch64 issues * These structures shouldn't be accessed by offsets anywhere in code anyway --- lib/atcacert/atcacert_def.h | 4 ++-- python/cryptoauthlib/atcacert.py | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/atcacert/atcacert_def.h b/lib/atcacert/atcacert_def.h index 1a48557ef..28fb9bc22 100644 --- a/lib/atcacert/atcacert_def.h +++ b/lib/atcacert/atcacert_def.h @@ -172,7 +172,7 @@ typedef struct ATCA_PACKED atcacert_cert_element_s * If any of the standard certificate elements (std_cert_elements) are not a part of the certificate * definition, set their count to 0 to indicate their absence. */ -typedef struct ATCA_PACKED atcacert_def_s +typedef struct atcacert_def_s { atcacert_cert_type_t type; //!< Certificate type. uint8_t template_id; //!< ID for the this certificate definition (4-bit value). @@ -198,7 +198,7 @@ typedef struct ATCA_PACKED atcacert_def_s * Tracks the state of a certificate as it's being rebuilt from device information. */ -typedef struct ATCA_PACKED atcacert_build_state_s +typedef struct atcacert_build_state_s { const atcacert_def_t* cert_def; //!< Certificate definition for the certificate being rebuilt. uint8_t* cert; //!< Buffer to contain the rebuilt certificate. diff --git a/python/cryptoauthlib/atcacert.py b/python/cryptoauthlib/atcacert.py index 56156d6ba..c2a10e519 100644 --- a/python/cryptoauthlib/atcacert.py +++ b/python/cryptoauthlib/atcacert.py @@ -221,8 +221,6 @@ class atcacert_def_t(AtcaStructure): """ CTypes mirror of atcacert_def_t from atcacert_def.h """ - _pack_ = 1 - def __init__(self, *args, **kwargs): if kwargs is not None: _atcacert_convert_enum(kwargs, 'type', atcacert_cert_type_t) From 4c49925d60dd2f3bb39a8143ef6f6253d73fe20d Mon Sep 17 00:00:00 2001 From: Bryan Hunt Date: Fri, 11 Feb 2022 08:43:54 -0800 Subject: [PATCH 2/2] Account for compilers that support #pragma pack as well --- lib/atcacert/atcacert_def.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/atcacert/atcacert_def.h b/lib/atcacert/atcacert_def.h index 28fb9bc22..ec6d85a8b 100644 --- a/lib/atcacert/atcacert_def.h +++ b/lib/atcacert/atcacert_def.h @@ -166,6 +166,10 @@ typedef struct ATCA_PACKED atcacert_cert_element_s atcacert_transform_t transforms[ATCA_MAX_TRANSFORMS]; //!< List of transforms from device to cert for this element. } atcacert_cert_element_t; +#ifndef ATCA_NO_PRAGMA_PACK +#pragma pack(pop) +#endif + /** * Defines a certificate and all the pieces to work with it. * @@ -208,10 +212,6 @@ typedef struct atcacert_build_state_s uint8_t device_sn[9]; //!< Storage for the device SN, when it's found. } atcacert_build_state_t; -#ifndef ATCA_NO_PRAGMA_PACK -#pragma pack(pop) -#endif - // Inform function naming when compiling in C++ #ifdef __cplusplus extern "C" {