Skip to content

Commit a7bbe3a

Browse files
committed
Release v3.7.8 (20250505)
1 parent 5135c92 commit a7bbe3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1480
-487
lines changed

CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
cmake_minimum_required(VERSION 3.10.0)
1+
cmake_minimum_required(VERSION 3.20.0)
22
project (cryptoauthlib C)
33

44
# Set the current release version
5-
set(VERSION "3.7.7")
5+
set(VERSION "3.7.8")
66
set(VERSION_MAJOR 3)
77
set(VERSION_MINOR 7)
8-
set(VERSION_PATCH 7)
8+
set(VERSION_PATCH 8)
99

1010
# Build Options
1111
option(BUILD_TESTS "Create Test Application with library" OFF)

app/tng/tng_atcacert_client.c

+13-12
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ int tng_atcacert_max_device_cert_size(size_t* max_cert_size)
3939
int ret = ATCACERT_E_WRONG_CERT_DEF;
4040
int index = 0;
4141
size_t cert_size = 0;
42+
size_t current_max_cert_size = 0;
4243
const atcacert_def_t* cert_def;
4344

4445
if (NULL != max_cert_size)
@@ -50,13 +51,14 @@ int tng_atcacert_max_device_cert_size(size_t* max_cert_size)
5051
if (NULL != cert_def)
5152
{
5253
ret = atcacert_max_cert_size(cert_def, &cert_size);
53-
if (ATCACERT_E_SUCCESS == ret)
54+
if (ATCACERT_E_SUCCESS != ret)
5455
{
55-
*max_cert_size = cert_size;
56+
break;
5657
}
57-
else
58+
59+
if (cert_size > current_max_cert_size)
5860
{
59-
break;
61+
current_max_cert_size = cert_size;
6062
}
6163

6264
if (index < INT_MAX)
@@ -70,6 +72,11 @@ int tng_atcacert_max_device_cert_size(size_t* max_cert_size)
7072
}
7173
}
7274
} while ((NULL != cert_def) && (ret == ATCACERT_E_SUCCESS));
75+
76+
if (ret == ATCACERT_E_SUCCESS)
77+
{
78+
*max_cert_size = current_max_cert_size;
79+
}
7380
}
7481

7582
return ret;
@@ -165,19 +172,13 @@ int tng_atcacert_read_signer_cert(uint8_t* cert, size_t* cert_size)
165172
{
166173
int ret;
167174
const atcacert_def_t* cert_def = NULL;
168-
uint8_t* ca_public_key = NULL;
169-
cal_buffer ca_pubkey = CAL_BUF_INIT(ATCA_ECCP256_PUBKEY_SIZE, NULL);
175+
const cal_buffer ca_public_key = cal_buf_init_const_ptr(ATCA_ECCP256_PUBKEY_SIZE, &g_cryptoauth_root_ca_002_cert[CRYPTOAUTH_ROOT_CA_002_PUBLIC_KEY_OFFSET]);
170176

171177
ret = tng_get_device_cert_def(&cert_def);
172178
if (ATCA_SUCCESS == ret)
173179
{
174180
cert_def = cert_def->ca_cert_def;
175-
176-
// Get the CA (root) public key
177-
ca_public_key = &g_cryptoauth_root_ca_002_cert[CRYPTOAUTH_ROOT_CA_002_PUBLIC_KEY_OFFSET];
178-
179-
ca_pubkey.buf = ca_public_key;
180-
ret = atcacert_read_cert(cert_def, &ca_pubkey, cert, cert_size);
181+
ret = atcacert_read_cert(cert_def, &ca_public_key, cert, cert_size);
181182
}
182183

183184
return ret;

cryptoauthlib-manual.pdf

-4.19 KB
Binary file not shown.

harmony/config/cryptoauthlib.py

+5
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,11 @@ def instantiateComponent(calComponent):
402402
calDebugPrint.setLabel("Enable Debug Print?")
403403
calDebugPrint.setVisible(True)
404404

405+
calEnableCheckParams = calComponent.createBooleanSymbol("CAL_ENABLE_CHECK_PARAMS", None)
406+
calEnableCheckParams.setLabel("Enable Check Params?")
407+
calEnableCheckParams.setVisible(True)
408+
calEnableCheckParams.setDefaultValue(True)
409+
405410
calPreprocessorWarning = calComponent.createBooleanSymbol("CAL_ENABLE_PREPROCESSOR_WARNING", None)
406411
calPreprocessorWarning.setLabel("Enable Preprocessor Warning?")
407412
calPreprocessorWarning.setVisible(True)

harmony/templates/atca_config.h.ftl

+13-6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
#endif
5454
</#if>
5555

56+
/** Define if the library is not to use malloc/free */
57+
<#if CAL_ENABLE_CHECK_PARAMS == false>
58+
<#lt>#define ATCA_CHECK_PARAMS_EN (FEATURE_DISABLED)
59+
<#else>
60+
<#lt>#define ATCA_CHECK_PARAMS_EN (FEATURE_ENABLED)
61+
</#if>
62+
5663
/** Symmetric Commands Configurations */
5764

5865
/* AES Command */
@@ -530,8 +537,8 @@
530537
#define PLIB_I2C_TRANSFER_SETUP I2C_TRANSFER_SETUP
531538
</#if>
532539

533-
typedef bool (* atca_i2c_plib_read)( uint16_t, uint8_t *, ${size_var} );
534-
typedef bool (* atca_i2c_plib_write)( uint16_t, uint8_t *, ${size_var} );
540+
typedef bool (* atca_i2c_plib_read)( uint16_t address, uint8_t * data, ${size_var} datalen);
541+
typedef bool (* atca_i2c_plib_write)( uint16_t address, uint8_t * data, ${size_var} datalen);
535542
typedef bool (* atca_i2c_plib_is_busy)( void );
536543
typedef PLIB_I2C_ERROR (* atca_i2c_error_get)( void );
537544
typedef bool (* atca_i2c_plib_transfer_setup)(PLIB_I2C_TRANSFER_SETUP* setup, uint32_t srcClkFreq);
@@ -550,8 +557,8 @@ typedef struct atca_plib_i2c_api
550557

551558
<#if plib_info[plib_info?size-1] == "spi">
552559
<#if is_atca_plib_spi_exists == "False">
553-
typedef bool (* atca_spi_plib_read)( void * , size_t );
554-
typedef bool (* atca_spi_plib_write)( void *, size_t );
560+
typedef bool (* atca_spi_plib_read)( void * data, size_t datalen);
561+
typedef bool (* atca_spi_plib_write)( void * data, size_t datalen);
555562
typedef bool (* atca_spi_plib_is_busy)( void );
556563
typedef void (* atca_spi_plib_select)(uint32_t pin, bool value);
557564

@@ -597,8 +604,8 @@ typedef struct atca_plib_spi_api
597604
#define PLIB_SWI_EVENT USART_EVENT
598605
</#if>
599606

600-
typedef size_t (* atca_uart_plib_read)( uint8_t *, const size_t );
601-
typedef size_t (* atca_uart_plib_write)( uint8_t *, const size_t );
607+
typedef size_t (* atca_uart_plib_read)( uint8_t * data, const size_t datalen);
608+
typedef size_t (* atca_uart_plib_write)( uint8_t * data, const size_t datalen);
602609
typedef PLIB_SWI_ERROR (* atca_uart_error_get)( void );
603610
typedef bool (* atca_uart_plib_serial_setup)(PLIB_SWI_SERIAL_SETUP* , uint32_t );
604611
typedef size_t (* atca_uart_plib_readcount_get)( void );

harmony/templates/hal_cortex_m_delay.c.ftl

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ void _delay_cycles(void *const hw, uint32_t cycles)
154154
/**
155155
* \brief Perform delay in us
156156
*/
157-
void hal_delay_us(const uint32_t us)
157+
void hal_delay_us(uint32_t delay)
158158
{
159-
uint32_t cycles = (GET_CYCLES_FOR_US_INTERNAL(us,CONF_CPU_FREQUENCY));
159+
uint32_t cycles = (GET_CYCLES_FOR_US_INTERNAL(delay,CONF_CPU_FREQUENCY));
160160
DELAY_CYCLES_US(cycles);
161161
}
162162

163163
/**
164164
* \brief Perform delay in ms
165165
*/
166-
void hal_delay_ms(const uint32_t ms)
166+
void hal_delay_ms(uint32_t delay)
167167
{
168-
_delay_cycles((void*)0,(_get_cycles_for_ms(ms)/ MS_CYCLE_COUNT_DIVIDER));
168+
_delay_cycles((void*)0,(_get_cycles_for_ms(delay)/ MS_CYCLE_COUNT_DIVIDER));
169169
}

lib/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.10.0)
1+
cmake_minimum_required(VERSION 3.20.0)
22
project(cryptoauth C)
33

44
include(CheckSymbolExists)
@@ -18,6 +18,7 @@ option(ATCA_JWT_EN "Enable jwt functionality")
1818
option(ATCA_PKCS11 "Build PKCS11 Library")
1919
option(ATCA_BUILD_SHARED_LIBS "Build CryptoAuthLib as shared library" ON)
2020
option(ATCA_NO_HEAP "Do not use dynamic (heap) allocation functions" OFF)
21+
option(ATCA_CHECK_PARAMS_EN "Check parameters" ON)
2122
option(ATCA_USE_ATCAB_FUNCTIONS "Build the atcab_ api functions rather than using macros" OFF)
2223
option(ATCA_ENABLE_DEPRECATED "Enable the use of older APIs that that been replaced" OFF)
2324
option(ATCA_STRICT_C99 "Enable strict C99 compliance for the libray" OFF)
@@ -327,6 +328,10 @@ include_directories(cryptoauth PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
327328
../third_party/hidapi/hidapi
328329
${USB_INCLUDE_DIR})
329330

331+
if(APPLE)
332+
include_directories(cryptoauth PUBLIC ../third_party/hidapi/mac)
333+
endif()
334+
330335
if(ATCA_MBEDTLS)
331336
target_link_libraries(cryptoauth mbedtls)
332337
endif()

lib/atca_basic.c

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
#endif
3838
#endif
3939

40+
#ifdef __COVERITY__
41+
#pragma coverity compliance block deviate "MISRA C-2012 Rule 8.4" "The object prototype is defined "
42+
#endif
43+
4044
SHARED_LIB_EXPORT ATCADevice g_atcab_device_ptr = NULL;
4145

4246
#ifdef ATCA_NO_HEAP
@@ -4629,3 +4633,7 @@ ATCA_STATUS atcab_write_config_counter(uint16_t counter_id, uint32_t counter_val
46294633
return status;
46304634
}
46314635
#endif /* ATCAB_WRITE_CONFIG_BYTES_ZONE */
4636+
4637+
#ifdef __COVERITY__
4638+
#pragma coverity compliance end_block "MISRA C-2012 Rule 8.4"
4639+
#endif

lib/atca_compiler.h

+7
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
#define SHARED_LIB_IMPORT extern
8989
#endif
9090

91+
#ifdef __APPLE__
92+
#define ATCA_VECTOR_NO_PRAGMA_PACK
93+
#endif
94+
9195
//#elif defined(__ICC) || defined(__INTEL_COMPILER)
9296
/* Intel ICC/ICPC. ------------------------------------------ */
9397

@@ -139,6 +143,9 @@
139143
#define SHARED_LIB_IMPORT extern
140144
#endif
141145

146+
#ifdef __APPLE__
147+
#define ATCA_VECTOR_NO_PRAGMA_PACK
148+
#endif
142149

143150
//#elif defined(__HP_cc) || defined(__HP_aCC)
144151
/* Hewlett-Packard C/aC++. ---------------------------------- */

lib/atca_config.h.in

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ selected plus however additional slots one would like */
6060
/** Enable preprocessor warning messages */
6161
#cmakedefine01 ATCA_PREPROCESSOR_WARNING
6262

63+
/** Enable check params */
64+
#cmakedefine01 ATCA_CHECK_PARAMS_EN
65+
6366
/** Enable jwt functionality */
6467
#cmakedefine ATCA_JWT_EN
6568

lib/atca_device.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ struct atca_device
7070

7171
typedef struct atca_device * ATCADevice;
7272

73-
ATCA_STATUS initATCADevice(ATCAIfaceCfg* cfg, ATCADevice ca_dev);
73+
#ifdef ATCA_HEAP
7474
ATCADevice newATCADevice(ATCAIfaceCfg *cfg);
75-
ATCA_STATUS releaseATCADevice(ATCADevice ca_dev);
7675
void deleteATCADevice(ATCADevice *ca_dev);
76+
#endif
77+
ATCA_STATUS initATCADevice(ATCAIfaceCfg* cfg, ATCADevice ca_dev);
78+
ATCA_STATUS releaseATCADevice(ATCADevice ca_dev);
7779

7880
ATCAIface atGetIFace(ATCADevice dev);
7981

lib/atca_helpers.c

+1
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ size_t atcab_pointer_delta(const void* start, const void* end)
905905
}
906906
else
907907
{
908+
/* coverity[misra_c_2012_rule_10_8_violation:FALSE] The code is intended to measure the difference between `start` and `end` addresses in bytes, which is a legitimate use of pointer casting for arithmetic */
908909
return (size_t)((const uint8_t*)start - (const uint8_t*)end);
909910
}
910911
}

lib/atca_helpers.h

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ extern "C" {
4848
#define IS_MUL_SAFE_UINT64_T(a,b) ((((a) <= UINT64_MAX / (b))) ? true : false)
4949
#define IS_MUL_SAFE_SIZE_T(a,b) ((((a) <= SIZE_MAX / (b))) ? true : false)
5050

51+
#define ABS_VAL(x) (((x) < 0) ? -(x) : (x))
52+
5153
ATCA_STATUS atcab_bin2hex(const uint8_t* bin, size_t bin_size, char* hex, size_t* hex_size);
5254
ATCA_STATUS atcab_bin2hex_(const uint8_t* bin, size_t bin_size, char* hex, size_t* hex_size, bool is_pretty, bool is_space, bool is_upper);
5355
ATCA_STATUS atcab_hex2bin(const char* ascii_hex, size_t ascii_hex_len, uint8_t* binary, size_t* bin_len);

lib/atca_iface.h

+2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ typedef struct atca_iface
210210

211211
ATCA_STATUS initATCAIface(ATCAIfaceCfg *cfg, ATCAIface ca_iface);
212212
ATCA_STATUS releaseATCAIface(ATCAIface ca_iface);
213+
#ifdef ATCA_HEAP
213214
void deleteATCAIface(ATCAIface *ca_iface);
215+
#endif
214216

215217
#if defined(ATCA_HEAP) && defined(ENABLE_NEWATCAIFACE)
216218
ATCAIface newATCAIface(ATCAIfaceCfg *cfg);

lib/atca_version.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
#define ATCA_VERSION_H
3131

3232
// Version format yyyymmdd
33-
#define ATCA_LIBRARY_VERSION_DATE "20250210"
33+
#define ATCA_LIBRARY_VERSION_DATE "20250505"
3434
#define ATCA_LIBRARY_VERSION_MAJOR 3
3535
#define ATCA_LIBRARY_VERSION_MINOR 7
36-
#define ATCA_LIBRARY_VERSION_BUILD 7
36+
#define ATCA_LIBRARY_VERSION_BUILD 8
3737

3838
#endif /* ATCA_VERSION_H */

lib/atcacert/atcacert_date.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,9 @@ ATCA_STATUS atcacert_date_dec_compcert_ext(const uint8_t comp_cert[AT
13611361
issue_date->tm_year = (int)((uint8_t)((((comp_cert[64] & (uint8_t)0xF8u) >> 3u)) + 100u));
13621362
expire_years = (comp_cert[66] & (uint8_t)0x1F);
13631363
}
1364-
issue_date->tm_mon = (int)((uint8_t)((uint8_t)((((comp_cert[64] & (uint8_t)0x07) << 1u) | ((comp_cert[65] & (uint8_t)0x80) >> 7u)) - 1u)) & 0x0Fu);
1364+
/* coverity[cert_int31_c_violation] value of tm_mon within range */
1365+
/* coverity[misra_c_2012_rule_10_8_violation] tm_mon is known to be a positive value within range */
1366+
issue_date->tm_mon = (int)((uint8_t)((uint8_t)((uint8_t)(((comp_cert[64] & (uint8_t)0x07) << 1u) | ((comp_cert[65] & (uint8_t)0x80) >> 7u)) - 1u)) & 0x0Fu);
13651367
issue_date->tm_mday = (int)((uint8_t)((comp_cert[65] & (uint8_t)0x7C) >> 2u));
13661368
issue_date->tm_hour = (int)((uint8_t)(((comp_cert[65] & (uint8_t)0x03) << 3u) | ((comp_cert[66] & (uint8_t)0xE0) >> 5u)));
13671369

0 commit comments

Comments
 (0)