diff --git a/CMakeLists.txt b/CMakeLists.txt index aa8e19c5..4cd8e0ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -777,7 +777,7 @@ endif() # set(CPACK_PACKAGE_NAME "GmSSL") set(CPACK_PACKAGE_VENDOR "GmSSL develop team") -set(CPACK_PACKAGE_VERSION "3.2.0-dev.1042") +set(CPACK_PACKAGE_VERSION "3.2.0-dev.1043") set(CPACK_PACKAGE_DESCRIPTION_FILE ${PROJECT_SOURCE_DIR}/README.md) set(CPACK_NSIS_MODIFY_PATH ON) include(CPack) diff --git a/include/gmssl/endian.h b/include/gmssl/endian.h index 6d0003b9..89488c41 100644 --- a/include/gmssl/endian.h +++ b/include/gmssl/endian.h @@ -58,13 +58,45 @@ /* Little Endian R/W */ -#define GETU16_LE(p) (*(const uint16_t *)(p)) -#define GETU32_LE(p) (*(const uint32_t *)(p)) -#define GETU64_LE(p) (*(const uint64_t *)(p)) +#define GETU16_LE(p) \ + ((uint16_t)(uint8_t)(p)[0] | \ + (uint16_t)(uint8_t)(p)[1] << 8) -#define PUTU16_LE(p,V) *(uint16_t *)(p) = (V) -#define PUTU32_LE(p,V) *(uint32_t *)(p) = (V) -#define PUTU64_LE(p,V) *(uint64_t *)(p) = (V) +#define GETU32_LE(p) \ + ((uint32_t)(uint8_t)(p)[0] | \ + (uint32_t)(uint8_t)(p)[1] << 8 | \ + (uint32_t)(uint8_t)(p)[2] << 16 | \ + (uint32_t)(uint8_t)(p)[3] << 24) + +#define GETU64_LE(p) \ + ((uint64_t)(uint8_t)(p)[0] | \ + (uint64_t)(uint8_t)(p)[1] << 8 | \ + (uint64_t)(uint8_t)(p)[2] << 16 | \ + (uint64_t)(uint8_t)(p)[3] << 24 | \ + (uint64_t)(uint8_t)(p)[4] << 32 | \ + (uint64_t)(uint8_t)(p)[5] << 40 | \ + (uint64_t)(uint8_t)(p)[6] << 48 | \ + (uint64_t)(uint8_t)(p)[7] << 56) + +#define PUTU16_LE(p,V) \ + ((p)[0] = (uint8_t)(V), \ + (p)[1] = (uint8_t)((V) >> 8)) + +#define PUTU32_LE(p,V) \ + ((p)[0] = (uint8_t)(V), \ + (p)[1] = (uint8_t)((V) >> 8), \ + (p)[2] = (uint8_t)((V) >> 16), \ + (p)[3] = (uint8_t)((V) >> 24)) + +#define PUTU64_LE(p,V) \ + ((p)[0] = (uint8_t)(V), \ + (p)[1] = (uint8_t)((V) >> 8), \ + (p)[2] = (uint8_t)((V) >> 16), \ + (p)[3] = (uint8_t)((V) >> 24), \ + (p)[4] = (uint8_t)((V) >> 32), \ + (p)[5] = (uint8_t)((V) >> 40), \ + (p)[6] = (uint8_t)((V) >> 48), \ + (p)[7] = (uint8_t)((V) >> 56)) /* Rotate */ diff --git a/include/gmssl/version.h b/include/gmssl/version.h index 9dbb2834..bd6efbe6 100644 --- a/include/gmssl/version.h +++ b/include/gmssl/version.h @@ -19,7 +19,7 @@ extern "C" { // Also update CPACK_PACKAGE_VERSION in CMakeLists.txt #define GMSSL_VERSION_NUM 30200 -#define GMSSL_VERSION_STR "GmSSL 3.2.0-dev.1042" +#define GMSSL_VERSION_STR "GmSSL 3.2.0-dev.1043" int gmssl_version_num(void); const char *gmssl_version_str(void);