Skip to content

Commit caf67be

Browse files
committed
Release v3.7.7 (20250213)
1 parent dfdeaed commit caf67be

File tree

183 files changed

+12314
-2957
lines changed

Some content is hidden

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

183 files changed

+12314
-2957
lines changed

CMakeLists.txt

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

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

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

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ device. The family of devices supported currently are:
88

99
|CryptoAuth |CryptoAuth2 |
1010
|-----------------------------------------------:|:-----------------------------------------|
11-
|[ATECC608B](https://www.microchip.com/ATECC608B)|[ECC204](https://www.microchip.com/ECC204)|
12-
|[ATECC608A](http://www.microchip.com/ATECC608A) |[ECC206](https://www.microchip.com/ECC206)|
13-
|[ATECC508A](http://www.microchip.com/ATECC508A) |[SHA104](https://www.microchip.com/SHA104)|
14-
|[ATECC108A](http://www.microchip.com/ATECC108A) |[SHA105](https://www.microchip.com/SHA105)|
15-
|[ATSHA204A](http://www.microchip.com/ATSHA204A) |[SHA106](https://www.microchip.com/SHA106)|
16-
|[ATSHA206A](https://www.microchip.com/ATSHA206A)|[RNG90](https://www.microchip.com/RNG90) |
11+
|[ATECC608C](https://www.microchip.com/ATECC608C)|[ECC204](https://www.microchip.com/ECC204)|
12+
|[ATECC608B](https://www.microchip.com/ATECC608B)|[ECC206](https://www.microchip.com/ECC206)|
13+
|[ATECC608A](http://www.microchip.com/ATECC608A) |[SHA104](https://www.microchip.com/SHA104)|
14+
|[ATECC508A](http://www.microchip.com/ATECC508A) |[SHA105](https://www.microchip.com/SHA105)|
15+
|[ATECC108A](http://www.microchip.com/ATECC108A) |[SHA106](https://www.microchip.com/SHA106)|
16+
|[ATSHA204A](http://www.microchip.com/ATSHA204A) |[RNG90](https://www.microchip.com/RNG90) |
17+
|[ATSHA206A](https://www.microchip.com/ATSHA206A)| |
1718

1819
The best place to start is with the [Microchip Trust Platform](https://www.microchip.com/design-centers/security-ics/trust-platform)
1920

app/tng/tflxtls_cert_def_4_device.c

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "tngtls_cert_def_1_signer.h"
3030
#include "tflxtls_cert_def_4_device.h"
3131

32+
#if ATCACERT_COMPCERT_EN
33+
3234
const uint8_t g_tflxtls_cert_template_4_device[500] = {
3335
0x30, 0x82, 0x01, 0xF0, 0x30, 0x82, 0x01, 0x97, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x55,
3436
0xCE, 0x2E, 0x8F, 0xF6, 0x1C, 0x62, 0x50, 0xB7, 0xE1, 0x68, 0x03, 0x54, 0x14, 0x1C, 0x94, 0x30,
@@ -177,3 +179,4 @@ const atcacert_def_t g_tflxtls_cert_def_4_device = {
177179
.cert_template_size = (uint16_t)(sizeof(g_tflxtls_cert_template_4_device)),
178180
.ca_cert_def = &g_tngtls_cert_def_1_signer
179181
};
182+
#endif

app/tng/tng_atca.c

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "tflxtls_cert_def_4_device.h"
3636
#include "atcacert/atcacert_def.h"
3737

38+
#if ATCACERT_COMPCERT_EN
3839

3940
typedef struct
4041
{
@@ -129,3 +130,5 @@ ATCA_STATUS tng_get_device_pubkey(uint8_t *public_key)
129130

130131
return status;
131132
}
133+
134+
#endif

app/tng/tng_atca.h

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ extern "C" {
3737

3838
#define ATCA_OTP_CODE_SIZE (8u)
3939

40+
#if ((defined(ATCA_TNG_LEGACY_SUPPORT) || defined(ATCA_TFLEX_SUPPORT) || \
41+
defined(ATCA_TNGTLS_SUPPORT) || defined(ATCA_TNGLORA_SUPPORT)) && !ATCACERT_COMPCERT_EN)
42+
#error "Enable ATCACERT_COMPCERT_EN to handle TNG"
43+
#endif
44+
4045
/** \defgroup tng_ TNG API (tng_)
4146
*
4247
* \brief These methods provide some convenience functions (mostly around

app/tng/tng_atcacert_client.c

+14-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include "tng_root_cert.h"
3333
#include <limits.h>
3434

35+
#if ATCACERT_COMPCERT_EN
36+
3537
int tng_atcacert_max_device_cert_size(size_t* max_cert_size)
3638
{
3739
int ret = ATCACERT_E_WRONG_CERT_DEF;
@@ -48,10 +50,14 @@ int tng_atcacert_max_device_cert_size(size_t* max_cert_size)
4850
if (NULL != cert_def)
4951
{
5052
ret = atcacert_max_cert_size(cert_def, &cert_size);
51-
if (cert_size > *max_cert_size)
53+
if (ATCACERT_E_SUCCESS == ret)
5254
{
5355
*max_cert_size = cert_size;
5456
}
57+
else
58+
{
59+
break;
60+
}
5561

5662
if (index < INT_MAX)
5763
{
@@ -110,7 +116,7 @@ int tng_atcacert_read_device_cert(uint8_t* cert, size_t* cert_size, const uint8_
110116
}
111117
}
112118

113-
return atcacert_read_cert(cert_def, ca_public_key, cert, cert_size);
119+
return atcacert_read_cert(cert_def, &ca_pubkey, cert, cert_size);
114120
}
115121

116122
int tng_atcacert_device_public_key(uint8_t* public_key, uint8_t* cert)
@@ -159,7 +165,8 @@ int tng_atcacert_read_signer_cert(uint8_t* cert, size_t* cert_size)
159165
{
160166
int ret;
161167
const atcacert_def_t* cert_def = NULL;
162-
const uint8_t* ca_public_key = NULL;
168+
uint8_t* ca_public_key = NULL;
169+
cal_buffer ca_pubkey = CAL_BUF_INIT(ATCA_ECCP256_PUBKEY_SIZE, NULL);
163170

164171
ret = tng_get_device_cert_def(&cert_def);
165172
if (ATCA_SUCCESS == ret)
@@ -169,7 +176,8 @@ int tng_atcacert_read_signer_cert(uint8_t* cert, size_t* cert_size)
169176
// Get the CA (root) public key
170177
ca_public_key = &g_cryptoauth_root_ca_002_cert[CRYPTOAUTH_ROOT_CA_002_PUBLIC_KEY_OFFSET];
171178

172-
ret = atcacert_read_cert(cert_def, ca_public_key, cert, cert_size);
179+
ca_pubkey.buf = ca_public_key;
180+
ret = atcacert_read_cert(cert_def, &ca_pubkey, cert, cert_size);
173181
}
174182

175183
return ret;
@@ -263,3 +271,5 @@ int tng_atcacert_root_public_key(uint8_t* public_key)
263271

264272
return ATCACERT_E_SUCCESS;
265273
}
274+
275+
#endif

app/tng/tnglora_cert_def_1_signer.c

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "tngtls_cert_def_1_signer.h"
3030
#include "tnglora_cert_def_1_signer.h"
3131

32+
#if ATCACERT_COMPCERT_EN
33+
3234
SHARED_LIB_EXPORT const atcacert_def_t g_tnglora_cert_def_1_signer = {
3335
.type = CERTTYPE_X509,
3436
.template_id = 1,
@@ -103,3 +105,5 @@ SHARED_LIB_EXPORT const atcacert_def_t g_tnglora_cert_def_1_signer = {
103105
.cert_template_size = TNGTLS_CERT_TEMPLATE_1_SIGNER_SIZE,
104106
.ca_cert_def = NULL
105107
};
108+
109+
#endif

app/tng/tnglora_cert_def_2_device.c

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "tnglora_cert_def_1_signer.h"
3232
#include "tnglora_cert_def_2_device.h"
3333

34+
#if ATCACERT_COMPCERT_EN
35+
3436
SHARED_LIB_EXPORT const atcacert_def_t g_tnglora_cert_def_2_device = {
3537
.type = CERTTYPE_X509,
3638
.template_id = 2,
@@ -105,3 +107,5 @@ SHARED_LIB_EXPORT const atcacert_def_t g_tnglora_cert_def_2_device = {
105107
.cert_template_size = TNGTLS_CERT_TEMPLATE_2_DEVICE_SIZE,
106108
.ca_cert_def = &g_tnglora_cert_def_1_signer
107109
};
110+
111+
#endif

app/tng/tnglora_cert_def_4_device.c

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "tnglora_cert_def_4_device.h"
3030
#include "tnglora_cert_def_1_signer.h"
3131

32+
#if ATCACERT_COMPCERT_EN
33+
3234
SHARED_LIB_EXPORT const uint8_t g_tnglora_cert_template_4_device[TNGLORA_CERT_TEMPLATE_4_DEVICE_SIZE] = {
3335
0x30, 0x82, 0x02, 0x24, 0x30, 0x82, 0x01, 0xc9, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x55,
3436
0xce, 0x2e, 0x8f, 0xf6, 0x1c, 0x62, 0x50, 0xb7, 0xe1, 0x68, 0x03, 0x54, 0x14, 0x1c, 0x94, 0x30,
@@ -198,3 +200,5 @@ SHARED_LIB_EXPORT const atcacert_def_t g_tnglora_cert_def_4_device = {
198200
.cert_template_size = (uint16_t)(sizeof(g_tnglora_cert_template_4_device)),
199201
.ca_cert_def = &g_tnglora_cert_def_1_signer
200202
};
203+
204+
#endif

app/tng/tngtls_cert_def_1_signer.c

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "atcacert/atcacert_def.h"
2929
#include "tngtls_cert_def_1_signer.h"
3030

31+
#if ATCACERT_COMPCERT_EN
32+
3133
SHARED_LIB_EXPORT const uint8_t g_tngtls_cert_template_1_signer[TNGTLS_CERT_TEMPLATE_1_SIGNER_SIZE] = {
3234
0x30, 0x82, 0x02, 0x04, 0x30, 0x82, 0x01, 0xaa, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x44,
3335
0x0e, 0xe4, 0x17, 0x0c, 0xb5, 0x45, 0xce, 0x59, 0x69, 0x8e, 0x30, 0x56, 0x99, 0x0a, 0x5d, 0x30,
@@ -151,3 +153,5 @@ SHARED_LIB_EXPORT const atcacert_def_t g_tngtls_cert_def_1_signer = {
151153
.cert_template_size = (uint16_t)(sizeof(g_tngtls_cert_template_1_signer)),
152154
.ca_cert_def = NULL
153155
};
156+
157+
#endif

app/tng/tngtls_cert_def_2_device.c

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "tngtls_cert_def_2_device.h"
3030
#include "tngtls_cert_def_1_signer.h"
3131

32+
#if ATCACERT_COMPCERT_EN
33+
3234
SHARED_LIB_EXPORT const uint8_t g_tngtls_cert_template_2_device[TNGTLS_CERT_TEMPLATE_2_DEVICE_SIZE] = {
3335
0x30, 0x82, 0x01, 0xf5, 0x30, 0x82, 0x01, 0x9b, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x55,
3436
0xce, 0x2e, 0x8f, 0xf6, 0x1c, 0x62, 0x50, 0xb7, 0xe1, 0x68, 0x03, 0x54, 0x14, 0x1c, 0x94, 0x30,
@@ -177,3 +179,5 @@ SHARED_LIB_EXPORT const atcacert_def_t g_tngtls_cert_def_2_device = {
177179
.cert_template_size = (uint16_t)(sizeof(g_tngtls_cert_template_2_device)),
178180
.ca_cert_def = &g_tngtls_cert_def_1_signer
179181
};
182+
183+
#endif

app/tng/tngtls_cert_def_3_device.c

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "tngtls_cert_def_3_device.h"
3030
#include "tngtls_cert_def_1_signer.h"
3131

32+
#if ATCACERT_COMPCERT_EN
33+
3234
SHARED_LIB_EXPORT const uint8_t g_tngtls_cert_template_3_device[TNGTLS_CERT_TEMPLATE_3_DEVICE_SIZE] = {
3335
0x30, 0x82, 0x02, 0x1e, 0x30, 0x82, 0x01, 0xc5, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x55,
3436
0xce, 0x2e, 0x8f, 0xf6, 0x1c, 0x62, 0x50, 0xb7, 0xe1, 0x68, 0x03, 0x54, 0x14, 0x1c, 0x94, 0x30,
@@ -198,3 +200,5 @@ SHARED_LIB_EXPORT const atcacert_def_t g_tngtls_cert_def_3_device = {
198200
.cert_template_size = (uint16_t)(sizeof(g_tngtls_cert_template_3_device)),
199201
.ca_cert_def = &g_tngtls_cert_def_1_signer
200202
};
203+
204+
#endif

app/wpc/wpc_apis.c

+37-23
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#if WPC_MSG_PR_EN
3434

35-
#define CA2_TRANSPORT_KEY 0x8000
35+
#define CA2_TRANSPORT_KEY 0x8000
3636

3737
/** \brief WPC API - Builds the CHALLENGE message
3838
*
@@ -46,7 +46,7 @@ ATCA_STATUS wpc_msg_challenge(
4646
)
4747
{
4848
ATCA_STATUS status = ATCA_BAD_PARAM;
49-
uint8_t nonce[32] = {0U};
49+
uint8_t nonce[32] = { 0U };
5050

5151
ATCA_CHECK_INVALID_MSG((!message || !msg_len), ATCA_BAD_PARAM, "NULL pointer received");
5252

@@ -61,16 +61,16 @@ ATCA_STATUS wpc_msg_challenge(
6161
else
6262
#endif
6363
{
64-
if(true == atcab_is_ca2_device(atcab_get_device_type_ext(device)))
64+
if (true == atcab_is_ca2_device(atcab_get_device_type_ext(device)))
6565
{
6666
#if ATCA_CA2_SUPPORT
67-
uint8_t num_in[20] = {0u};
68-
status = ATCA_TRACE(calib_nonce_gen_session_key(device, CA2_TRANSPORT_KEY, num_in ,nonce), "atcab_nonce_rand failed");
67+
uint8_t num_in[20] = { 0u };
68+
status = ATCA_TRACE(calib_nonce_gen_session_key(device, CA2_TRANSPORT_KEY, num_in, nonce), "atcab_nonce_rand failed");
6969
#endif
7070
}
7171
else
7272
{
73-
#if ATCA_ECC_SUPPORT
73+
#if (ATCA_ECC_SUPPORT || ATCA_TA_SUPPORT)
7474
status = ATCA_TRACE(atcab_random_ext(device, nonce), "atcab_random failed");
7575
#endif
7676
}
@@ -181,12 +181,12 @@ ATCA_STATUS wpc_msg_challenge_auth(
181181
response[0] = WPC_CHALLENGE_AUTH_HEADER;
182182
response[1] = (WPC_PROTOCOL_MAX_VERSION << 4) | wpccert_get_slots_populated();
183183

184-
if (ATCA_SUCCESS != (status = wpccert_get_slot_info(&handle, &cert_def, NULL, NULL, slot)))
184+
if (ATCA_SUCCESS != (status = wpccert_get_slot_info(&handle, &cert_def, NULL, NULL, NULL, slot)))
185185
{
186186
return wpc_msg_error(response, resp_len, WPC_ERROR_INVALID_REQUEST, 0);
187187
}
188188

189-
if(NULL == cert_def)
189+
if (NULL == cert_def)
190190
{
191191
status = ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer received for cert def");
192192
return status;
@@ -238,7 +238,7 @@ ATCA_STATUS wpc_msg_digests(
238238
uint8_t slot_mask = (1 << slot);
239239
if (request[1] & slot_mask)
240240
{
241-
if (ATCA_SUCCESS == wpccert_get_slot_info(&handle, NULL, NULL, NULL, slot))
241+
if (ATCA_SUCCESS == wpccert_get_slot_info(&handle, NULL, NULL, NULL, NULL, slot))
242242
{
243243
if (ATCA_SUCCESS != (status = atcab_read_bytes_zone_ext(device, ATCA_ZONE_DATA, handle, 0,
244244
digest, ATCA_SHA256_DIGEST_SIZE)))
@@ -288,18 +288,32 @@ ATCA_STATUS wpc_msg_certificate(
288288
uint16_t length;
289289
uint8_t * data;
290290
const atcacert_def_t * cert_def;
291-
uint8_t* mfg_cert;
292-
uint8_t root_digest[32] = {0};
291+
uint8_t* mfg_cert = NULL;
292+
uint8_t root_digest[32] = { 0 };
293+
uint16_t root_digest_handle = 0;
293294

294295
ATCA_CHECK_INVALID_MSG((!buffer || !request || !response || !resp_len),
295296
ATCA_BAD_PARAM, "NULL pointer received");
296297

297-
if (ATCA_SUCCESS != (status = wpccert_get_slot_info(NULL, &cert_def, &mfg_cert, root_digest, request[1] & 0x03)))
298+
#if (ATCA_TA_SUPPORT)
299+
if (ATCA_SUCCESS != (status = wpccert_get_slot_info(NULL, &cert_def, NULL, NULL, &root_digest_handle, request[1] & 0x03)))
300+
#else
301+
if (ATCA_SUCCESS != (status = wpccert_get_slot_info(NULL, &cert_def, &mfg_cert, root_digest, NULL, request[1] & 0x03)))
302+
#endif
298303
{
299304
return wpc_msg_error(response, resp_len, WPC_ERROR_INVALID_REQUEST, 0);
300305
}
301306

302-
if(NULL == cert_def)
307+
#if ATCA_TA_SUPPORT
308+
if (ATCA_SUCCESS != (status = atcab_read_bytes_zone_ext(device, ATCA_ZONE_DATA, root_digest_handle, 0,
309+
root_digest, ATCA_SHA256_DIGEST_SIZE)))
310+
{
311+
ATCA_TRACE(status, "atcab_read_bytes_zone execution failed");
312+
return wpc_msg_error(response, resp_len, WPC_ERROR_UNSPECIFIED, 0);
313+
}
314+
#endif
315+
316+
if (NULL == cert_def)
303317
{
304318
status = ATCA_TRACE(ATCA_BAD_PARAM, "NULL pointer received for Product cert def");
305319
return status;
@@ -331,10 +345,10 @@ ATCA_STATUS wpc_msg_certificate(
331345
/* Get the product certificate length if the read will include it or the total chain length */
332346
if ((length == 0) || (offset < 2) || ((WPC_CONST_OS_MC < offset) && ((0x600 <= offset) || (n_mc < offset + length))))
333347
{
334-
if(ATCA_SUCCESS != wpccert_read_cert_size(device, cert_def, &n_puc))
348+
if (ATCA_SUCCESS != wpccert_read_cert_size(device, cert_def, &n_puc))
335349
{
336-
status = ATCA_TRACE(status, "wpccert_read_cert_size execution is failed for pdu cert");
337-
return status;
350+
status = ATCA_TRACE(status, "wpccert_read_cert_size execution is failed for pdu cert");
351+
return status;
338352
}
339353
}
340354
ATCA_CHECK_INVALID_MSG((n_puc > buflen || n_mc > buflen), ATCA_SMALL_BUFFER, "temporary buffer is too small for certificates");
@@ -394,7 +408,7 @@ ATCA_STATUS wpc_msg_certificate(
394408
{
395409
uint16_t mc_length = length < n_mc ? length : n_mc;
396410

397-
if((NULL != mfg_cert) && (NULL == cert_def->ca_cert_def))
411+
if ((NULL != mfg_cert) && (NULL == cert_def->ca_cert_def))
398412
{
399413
memcpy(buffer, mfg_cert, mc_length);
400414
}
@@ -459,12 +473,12 @@ ATCA_STATUS wpc_msg_certificate(
459473
* \return ATCA_SUCCESS on success, otherwise an error code.
460474
*/
461475
ATCA_STATUS wpc_auth_signature(
462-
ATCADevice device, /**< [in] Device Context */
463-
const uint8_t *chain_digest, /**< [in] WPC Authentication Cert Chain digest*/
464-
const uint16_t private_key_slot, /**< [in] WPC Authentication private key slot*/
465-
const uint8_t *request, /**< [in] WPC authentication challenge request from host */
466-
const uint8_t *other_data, /**< [in] Challegen response b0, b1 and Digest LSB*/
467-
uint8_t *const signature /**< [out] Signature for WPC authentication TBS */
476+
ATCADevice device, /**< [in] Device Context */
477+
const uint8_t * chain_digest, /**< [in] WPC Authentication Cert Chain digest*/
478+
const uint16_t private_key_slot, /**< [in] WPC Authentication private key slot*/
479+
const uint8_t * request, /**< [in] WPC authentication challenge request from host */
480+
const uint8_t * other_data, /**< [in] Challegen response b0, b1 and Digest LSB*/
481+
uint8_t *const signature /**< [out] Signature for WPC authentication TBS */
468482
)
469483
{
470484
ATCA_STATUS status;

0 commit comments

Comments
 (0)