Skip to content

Commit 5d47880

Browse files
committed
Turning global variable 'ECCX08Cert' into local member variable '_eccx08_cert'
1 parent 3b55be8 commit 5d47880

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

examples/utility/Provisioning/Provisioning.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <ArduinoIoTCloud.h>
2-
#include <utility/crypto/ECCX08Cert.h>
32
#include <utility/crypto/ECCX08TLSConfig.h>
43

54
#include <ArduinoBearSSL.h>
@@ -11,6 +10,8 @@ const int compressedCertSlot = 10;
1110
const int serialNumberAndAuthorityKeyIdentifierSlot = 11;
1211
const int deviceIdSlot = 12;
1312

13+
ECCX08CertClass ECCX08Cert;
14+
1415
void setup() {
1516
Serial.begin(9600);
1617
while (!Serial);

src/ArduinoIoTCloudTCP.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#ifdef BOARD_HAS_ECCX08
2323
#include <ArduinoECCX08.h>
2424
#include "utility/crypto/BearSSLTrustAnchor.h"
25-
#include "utility/crypto/CryptoUtil.h"
2625
#endif
2726

2827
TimeService time_service;
@@ -76,10 +75,10 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort) {
7675
#ifdef BOARD_HAS_ECCX08
7776
if (!ECCX08.begin()) { Debug.print(DBG_ERROR, "Cryptography processor failure. Make sure you have a compatible board."); return 0; }
7877
if (!CryptoUtil::readDeviceId(ECCX08, _device_id, ECCX08Slot::DeviceId)) { Debug.print(DBG_ERROR, "Cryptography processor read failure."); return 0; }
79-
if (!CryptoUtil::reconstructCertificate(ECCX08Cert, _device_id, ECCX08Slot::Key, ECCX08Slot::CompressedCertificate, ECCX08Slot::SerialNumberAndAuthorityKeyIdentifier)) { Debug.print(DBG_ERROR, "Cryptography certificate reconstruction failure."); return 0; }
78+
if (!CryptoUtil::reconstructCertificate(_eccx08_cert, _device_id, ECCX08Slot::Key, ECCX08Slot::CompressedCertificate, ECCX08Slot::SerialNumberAndAuthorityKeyIdentifier)) { Debug.print(DBG_ERROR, "Cryptography certificate reconstruction failure."); return 0; }
8079
ArduinoBearSSL.onGetTime(getTime);
8180
_sslClient = new BearSSLClient(_connection->getClient(), ArduinoIoTCloudTrustAnchor, ArduinoIoTCloudTrustAnchor_NUM);
82-
_sslClient->setEccSlot(static_cast<int>(ECCX08Slot::Key), ECCX08Cert.bytes(), ECCX08Cert.length());
81+
_sslClient->setEccSlot(static_cast<int>(ECCX08Slot::Key), _eccx08_cert.bytes(), _eccx08_cert.length());
8382
#elif defined(BOARD_ESP)
8483
_sslClient = new WiFiClientSecure();
8584
_sslClient->setInsecure();

src/ArduinoIoTCloudTCP.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
#include <ArduinoIoTCloud.h>
2323
#include <Arduino_ConnectionHandler.h>
2424

25-
#ifdef BOARD_HAS_ECCX08 /
25+
#ifdef BOARD_HAS_ECCX08
2626
#include <ArduinoBearSSL.h>
27+
#include "utility/crypto/CryptoUtil.h"
2728
#elif defined(BOARD_ESP)
2829
#include <WiFiClientSecure.h>
2930
#endif
@@ -99,6 +100,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass {
99100
bool _mqtt_data_request_retransmit;
100101

101102
#ifdef BOARD_HAS_ECCX08
103+
ECCX08CertClass _eccx08_cert;
102104
BearSSLClient* _sslClient;
103105
#elif defined(BOARD_ESP)
104106
WiFiClientSecure* _sslClient;

src/utility/crypto/ECCX08Cert.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,4 @@ int ECCX08CertClass::appendEcdsaWithSHA256(byte out[]) {
923923
return 12;
924924
}
925925

926-
ECCX08CertClass ECCX08Cert;
927-
928926
#endif /* BOARD_HAS_ECCX08 */

src/utility/crypto/ECCX08Cert.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ class ECCX08CertClass {
134134
int _length;
135135
};
136136

137-
extern ECCX08CertClass ECCX08Cert;
138-
139137
#endif /* BOARD_HAS_ECCX08 */
140138

141139
#endif /* _ECCX08_CERT_H_ */

0 commit comments

Comments
 (0)