Skip to content

Commit 44b6f86

Browse files
Generalization of Secure Element usage
tranistion from ECCX08 to SecureElement instance usage
1 parent 20ea673 commit 44b6f86

9 files changed

Lines changed: 18 additions & 45 deletions

src/ArduinoBearSSLConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define ARDUINO_BEARSSL_CONFIG_H_
1313

1414
/* Enabling this define allows the usage of ArduinoBearSSL without crypto chip. */
15-
//#define ARDUINO_DISABLE_ECCX08
15+
//#define ARDUINO_DISABLE_SECURE_ELEMENT
1616

1717
/* Enable/Disable global instances*/
1818
#define ARDUINO_BEARSSL_DISABLE_AES128

src/tls/BearSSLClientProfile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
******************************************************************************/
1414

1515
#include <AIoTC_Config.h>
16-
#ifdef BOARD_HAS_ECCX08
16+
#ifdef BOARD_HAS_SECURE_ELEMENT
1717

1818
#include "bearssl/inner.h"
1919

@@ -88,4 +88,4 @@ void aiotc_client_profile_init(br_ssl_client_context *cc, br_x509_minimal_contex
8888
br_ssl_engine_set_default_aes_gcm(&cc->eng);
8989
}
9090

91-
#endif /* #ifdef BOARD_HAS_ECCX08 */
91+
#endif /* #ifdef BOARD_HAS_SECURE_ELEMENT */

src/tls/BearSSLClientProfile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
******************************************************************************/
1717

1818
#include <AIoTC_Config.h>
19-
#ifdef BOARD_HAS_ECCX08
19+
#ifdef BOARD_HAS_SECURE_ELEMENT
2020

2121
extern "C" void aiotc_client_profile_init(br_ssl_client_context *cc, br_x509_minimal_context *xc, const br_x509_trust_anchor *trust_anchors, size_t trust_anchors_num);
2222

23-
#endif /* #ifdef BOARD_HAS_ECCX08 */
23+
#endif /* #ifdef BOARD_HAS_SECURE_ELEMENT */
2424

2525
#endif /* _BEAR_SSL_CLIENT_PROFILE_H_ */
2626

src/tls/BearSSLTrustAnchors.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
******************************************************************************/
1717

1818
#include <AIoTC_Config.h>
19-
#ifdef BOARD_HAS_ECCX08
19+
#ifdef BOARD_HAS_SECURE_ELEMENT
2020

2121
#include "bearssl/bearssl_ssl.h"
2222

@@ -98,6 +98,6 @@ static const br_x509_trust_anchor ArduinoIoTCloudTrustAnchor[2] = {
9898

9999
#define ArduinoIoTCloudTrustAnchor_NUM (2)
100100

101-
#endif /* #ifdef BOARD_HAS_ECCX08 */
101+
#endif /* #ifdef BOARD_HAS_SECURE_ELEMENT */
102102

103103
#endif /* _BEAR_SSL_TRUST_ANCHOR_H_ */

src/tls/utility/TLSClientMqtt.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
#include "tls/AIoTCUPCert.h"
1919
#endif
2020

21-
#if defined(BOARD_HAS_SE050) || defined(BOARD_HAS_SOFTSE)
21+
#if defined(BOARD_HAS_SOFTSE)
2222
#include "tls/AIoTCSSCert.h"
2323
#endif
2424

25-
#ifdef BOARD_HAS_ECCX08
25+
#ifdef BOARD_HAS_SECURE_ELEMENT
2626
#include "tls/BearSSLTrustAnchors.h"
2727
#include "tls/BearSSLClientProfile.h"
2828
extern "C" {
@@ -38,19 +38,12 @@ void TLSClientMqtt::begin(ConnectionHandler & connection, ArduinoIoTAuthenticati
3838
* https://github.com/arduino/nina-fw/blob/master/arduino/libraries/ArduinoBearSSL/src/BearSSLTrustAnchors.h
3939
*/
4040
(void)authMode;
41-
#elif defined(BOARD_HAS_ECCX08)
41+
#elif defined(BOARD_HAS_SECURE_ELEMENT)
4242
(void)authMode;
4343
setClient(connection.getClient());
4444
setProfile(aiotc_client_profile_init);
4545
setTrustAnchors(ArduinoIoTCloudTrustAnchor, ArduinoIoTCloudTrustAnchor_NUM);
4646
ArduinoBearSSL.onGetTime(getTime);
47-
#elif defined(ARDUINO_PORTENTA_C33)
48-
(void)authMode;
49-
setClient(connection.getClient());
50-
setCACert(AIoTSSCert);
51-
#elif defined(ARDUINO_NICLA_VISION)
52-
(void)authMode;
53-
appendCustomCACert(AIoTSSCert);
5447
#elif defined(ARDUINO_EDGE_CONTROL)
5548
(void)authMode;
5649
appendCustomCACert(AIoTUPCert);

src/tls/utility/TLSClientMqtt.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enum class ArduinoIoTAuthenticationMode
2626
*/
2727
#include "WiFiSSLClient.h"
2828
class TLSClientMqtt : public WiFiBearSSLClient {
29-
#elif defined(BOARD_HAS_ECCX08)
29+
#elif defined(BOARD_HAS_SECURE_ELEMENT)
3030
/*
3131
* Arduino MKR GSM 1400
3232
* Arduino MKR NB 1500
@@ -38,18 +38,6 @@ enum class ArduinoIoTAuthenticationMode
3838
#include <ArduinoBearSSLConfig.h>
3939
#include <ArduinoBearSSL.h>
4040
class TLSClientMqtt : public BearSSLClient {
41-
#elif defined(ARDUINO_PORTENTA_C33)
42-
/*
43-
* Arduino Portenta C33
44-
*/
45-
#include <SSLClient.h>
46-
class TLSClientMqtt : public SSLClient {
47-
#elif defined(ARDUINO_NICLA_VISION)
48-
/*
49-
* Arduino Nicla Vision
50-
*/
51-
#include <WiFiSSLSE050Client.h>
52-
class TLSClientMqtt : public WiFiSSLSE050Client {
5341
#elif defined(ARDUINO_EDGE_CONTROL)
5442
/*
5543
* Arduino Edge Control

src/tls/utility/TLSClientOta.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "tls/AIoTCSSCert.h"
2323
#endif
2424

25-
#ifdef BOARD_HAS_ECCX08
25+
#ifdef BOARD_HAS_SECURE_ELEMENT
2626
#include "tls/BearSSLTrustAnchors.h"
2727
#include "tls/BearSSLClientProfile.h"
2828
extern "C" {
@@ -35,16 +35,14 @@ void TLSClientOta::begin(ConnectionHandler &connection) {
3535
/* AWS Root CAs are configured in nina-fw
3636
* https://github.com/arduino/nina-fw/blob/master/data/roots.pem
3737
*/
38-
#elif defined(BOARD_HAS_ECCX08)
38+
#elif defined(BOARD_HAS_SECURE_ELEMENT)
3939
setClient(*getNewClient(connection.getInterface()));
4040
setProfile(aiotc_client_profile_init);
4141
setTrustAnchors(ArduinoIoTCloudTrustAnchor, ArduinoIoTCloudTrustAnchor_NUM);
4242
ArduinoBearSSL.onGetTime(getTime);
4343
#elif defined(ARDUINO_PORTENTA_C33)
4444
setClient(*getNewClient(connection.getInterface()));
4545
setCACert(AIoTSSCert);
46-
#elif defined(ARDUINO_NICLA_VISION)
47-
appendCustomCACert(AIoTSSCert);
4846
#elif defined(ARDUINO_EDGE_CONTROL)
4947
appendCustomCACert(AIoTUPCert);
5048
#elif defined(ARDUINO_UNOR4_WIFI)

src/tls/utility/TLSClientOta.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
#include "WiFiSSLClient.h"
2222
class TLSClientOta : public WiFiBearSSLClient {
23-
#elif defined(BOARD_HAS_ECCX08)
23+
#elif defined(BOARD_HAS_SECURE_ELEMENT)
2424
/*
2525
* Arduino MKR GSM 1400
2626
* Arduino MKR NB 1500
@@ -38,12 +38,6 @@
3838
*/
3939
#include <SSLClient.h>
4040
class TLSClientOta : public SSLClient {
41-
#elif defined(ARDUINO_NICLA_VISION)
42-
/*
43-
* Arduino Nicla Vision
44-
*/
45-
#include <WiFiSSLSE050Client.h>
46-
class TLSClientOta : public WiFiSSLSE050Client {
4741
#elif defined(ARDUINO_EDGE_CONTROL)
4842
/*
4943
* Arduino Edge Control

src/utility/time/NTPUtils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#include "NTPUtils.h"
1919

2020
#include <Arduino.h>
21-
#ifdef BOARD_HAS_ECCX08
22-
#include <ArduinoECCX08.h>
21+
#ifdef BOARD_HAS_SECURE_ELEMENT
22+
#include <Arduino_SecureElement.h>
2323
#endif
2424

2525
/******************************************************************************
@@ -91,8 +91,8 @@ void NTPUtils::sendNTPpacket(UDP & udp)
9191

9292
int NTPUtils::getRandomPort(int const min_port, int const max_port)
9393
{
94-
#if defined (BOARD_HAS_ECCX08)
95-
return ECCX08.random(min_port, max_port);
94+
#if defined (BOARD_HAS_SECURE_ELEMENT)
95+
return SecureElement.random(min_port, max_port);
9696
#elif defined (ARDUINO_ARCH_ESP8266) || (ARDUINO_ARCH_ESP32)
9797
/* Uses HW Random Number Generator */
9898
return random(min_port, max_port);

0 commit comments

Comments
 (0)