1
1
#include < ArduinoCloudV2.h>
2
- #include < utility/ECC508Cert .h>
3
- #include < utility/ECC508TLSConfig .h>
2
+ #include < utility/ECCX08Cert .h>
3
+ #include < utility/ECCX08TLSConfig .h>
4
4
5
5
#include < ArduinoBearSSL.h>
6
- #include < utility/ECC508 .h>
6
+ #include < utility/ECCX08 .h>
7
7
8
8
const int keySlot = 0 ;
9
9
const int compressedCertSlot = 10 ;
@@ -13,36 +13,36 @@ void setup() {
13
13
Serial.begin (9600 );
14
14
while (!Serial);
15
15
16
- if (!ECC508 .begin ()) {
17
- Serial.println (" No ECC508 present!" );
16
+ if (!ECCX08 .begin ()) {
17
+ Serial.println (" No ECCX08 present!" );
18
18
while (1 );
19
19
}
20
20
21
- if (!ECC508 .locked ()) {
22
- Serial.println (" ECC508 is unlocked, locking ..." );
21
+ if (!ECCX08 .locked ()) {
22
+ Serial.println (" ECCX08 is unlocked, locking ..." );
23
23
24
- if (!ECC508 .writeConfiguration (DEFAULT_ECC508_TLS_CONFIG )) {
25
- Serial.println (" Writing ECC508 configuration failed!" );
24
+ if (!ECCX08 .writeConfiguration (DEFAULT_ECCX08_TLS_CONFIG )) {
25
+ Serial.println (" Writing ECCX08 configuration failed!" );
26
26
while (1 );
27
27
}
28
28
29
- if (!ECC508 .lock ()) {
30
- Serial.println (" Locking ECC508 configuration failed!" );
29
+ if (!ECCX08 .lock ()) {
30
+ Serial.println (" Locking ECCX08 configuration failed!" );
31
31
while (1 );
32
32
}
33
33
34
- Serial.println (" ECC508 locked successfully" );
34
+ Serial.println (" ECCX08 locked successfully" );
35
35
Serial.println ();
36
36
}
37
37
38
- if (!ECC508Cert .beginCSR (keySlot, true )) {
38
+ if (!ECCX08Cert .beginCSR (keySlot, true )) {
39
39
Serial.println (" Error starting CSR generation!" );
40
40
while (1 );
41
41
}
42
42
43
- ECC508Cert .setSubjectCommonName (ECC508 .serialNumber ());
43
+ ECCX08Cert .setSubjectCommonName (ECCX08 .serialNumber ());
44
44
45
- String csr = ECC508Cert .endCSR ();
45
+ String csr = ECCX08Cert .endCSR ();
46
46
47
47
if (!csr) {
48
48
Serial.println (" Error generating CSR!" );
@@ -70,43 +70,43 @@ void setup() {
70
70
hexStringToBytes (serialNumber, serialNumberBytes, sizeof (serialNumberBytes));
71
71
hexStringToBytes (signature, signatureBytes, 64 );
72
72
73
- if (!ECC508Cert .beginStorage (compressedCertSlot, serialNumberSlot)) {
74
- Serial.println (" Error starting ECC508 storage!" );
73
+ if (!ECCX08Cert .beginStorage (compressedCertSlot, serialNumberSlot)) {
74
+ Serial.println (" Error starting ECCX08 storage!" );
75
75
while (1 );
76
76
}
77
77
78
- ECC508Cert .setSignature (signatureBytes);
79
- ECC508Cert .setSerialNumber (serialNumberBytes);
80
- ECC508Cert .setIssueYear (issueYear.toInt ());
81
- ECC508Cert .setIssueMonth (issueMonth.toInt ());
82
- ECC508Cert .setIssueDay (issueDay.toInt ());
83
- ECC508Cert .setIssueHour (issueHour.toInt ());
84
- ECC508Cert .setExpireYears (expireYears.toInt ());
78
+ ECCX08Cert .setSignature (signatureBytes);
79
+ ECCX08Cert .setSerialNumber (serialNumberBytes);
80
+ ECCX08Cert .setIssueYear (issueYear.toInt ());
81
+ ECCX08Cert .setIssueMonth (issueMonth.toInt ());
82
+ ECCX08Cert .setIssueDay (issueDay.toInt ());
83
+ ECCX08Cert .setIssueHour (issueHour.toInt ());
84
+ ECCX08Cert .setExpireYears (expireYears.toInt ());
85
85
86
- if (!ECC508Cert .endStorage ()) {
87
- Serial.println (" Error storing ECC508 compressed cert!" );
86
+ if (!ECCX08Cert .endStorage ()) {
87
+ Serial.println (" Error storing ECCX08 compressed cert!" );
88
88
while (1 );
89
89
}
90
90
91
- if (!ECC508Cert .beginReconstruction (keySlot, compressedCertSlot, serialNumberSlot)) {
92
- Serial.println (" Error starting ECC508 cert reconstruction!" );
91
+ if (!ECCX08Cert .beginReconstruction (keySlot, compressedCertSlot, serialNumberSlot)) {
92
+ Serial.println (" Error starting ECCX08 cert reconstruction!" );
93
93
while (1 );
94
94
}
95
95
96
- ECC508Cert .setIssuerCountryName (" US" );
97
- ECC508Cert .setIssuerOrganizationName (" Arduino LLC US" );
98
- ECC508Cert .setIssuerOrganizationalUnitName (" IT" );
99
- ECC508Cert .setIssuerCommonName (" Arduino" );
96
+ ECCX08Cert .setIssuerCountryName (" US" );
97
+ ECCX08Cert .setIssuerOrganizationName (" Arduino LLC US" );
98
+ ECCX08Cert .setIssuerOrganizationalUnitName (" IT" );
99
+ ECCX08Cert .setIssuerCommonName (" Arduino" );
100
100
101
- if (!ECC508Cert .endReconstruction ()) {
102
- Serial.println (" Error reconstructing ECC508 compressed cert!" );
101
+ if (!ECCX08Cert .endReconstruction ()) {
102
+ Serial.println (" Error reconstructing ECCX08 compressed cert!" );
103
103
while (1 );
104
104
}
105
105
106
106
Serial.println (" Compressed cert = " );
107
107
108
- const byte* certData = ECC508Cert .bytes ();
109
- int certLength = ECC508Cert .length ();
108
+ const byte* certData = ECCX08Cert .bytes ();
109
+ int certLength = ECCX08Cert .length ();
110
110
111
111
for (int i = 0 ; i < certLength; i++) {
112
112
byte b = certData[i];
0 commit comments