Skip to content

Commit edf20d9

Browse files
committed
Rename ECC508 to ECCX08
1 parent 91bb864 commit edf20d9

File tree

6 files changed

+59
-59
lines changed

6 files changed

+59
-59
lines changed

Diff for: src/BearSSLClient.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "ArduinoBearSSL.h"
22
#include "BearSSLTrustAnchors.h"
3-
#include "utility/ECC508.h"
4-
#include "utility/ecc508_asn1.h"
3+
#include "utility/ECCX08.h"
4+
#include "utility/eccX08_asn1.h"
55

66

77
#include "BearSSLClient.h"
@@ -178,17 +178,17 @@ int BearSSLClient::connectSSL(const char* host)
178178
// inject entropy in engine
179179
unsigned char entropy[32];
180180

181-
if (ECC508.begin() && ECC508.locked() && ECC508.random(entropy, sizeof(entropy))) {
181+
if (ECCX08.begin() && ECCX08.locked() && ECCX08.random(entropy, sizeof(entropy))) {
182182
// ECC508 random success, add custom ECDSA vfry and EC sign
183-
br_ssl_engine_set_ecdsa(&_sc.eng, ecc508_vrfy_asn1);
183+
br_ssl_engine_set_ecdsa(&_sc.eng, eccX08_vrfy_asn1);
184184
br_x509_minimal_set_ecdsa(&_xc, br_ssl_engine_get_ec(&_sc.eng), br_ssl_engine_get_ecdsa(&_sc.eng));
185185

186-
// enable client auth using the ECC508
186+
// enable client auth using the ECCX08
187187
if (_ecCert.data_len && _ecKey.xlen) {
188-
br_ssl_client_set_single_ec(&_sc, &_ecCert, 1, &_ecKey, BR_KEYTYPE_KEYX | BR_KEYTYPE_SIGN, BR_KEYTYPE_EC, br_ec_get_default(), ecc508_sign_asn1);
188+
br_ssl_client_set_single_ec(&_sc, &_ecCert, 1, &_ecKey, BR_KEYTYPE_KEYX | BR_KEYTYPE_SIGN, BR_KEYTYPE_EC, br_ec_get_default(), eccX08_sign_asn1);
189189
}
190190
} else {
191-
// no ECC508 or random failed, fallback to pseudo random
191+
// no ECCX08 or random failed, fallback to pseudo random
192192
for (size_t i = 0; i < sizeof(entropy); i++) {
193193
entropy[i] = random(0, 255);
194194
}

Diff for: src/utility/ECC508.cpp renamed to src/utility/ECCX08.cpp

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#include <Arduino.h>
22

3-
#include "ECC508.h"
3+
#include "ECCX08.h"
44

5-
const uint32_t ECC508Class::_wakeupFrequency = 100000u; // 100 kHz
6-
const uint32_t ECC508Class::_normalFrequency = 1000000u; // 1 MHz
5+
const uint32_t ECCX08Class::_wakeupFrequency = 100000u; // 100 kHz
6+
const uint32_t ECCX08Class::_normalFrequency = 1000000u; // 1 MHz
77

8-
ECC508Class::ECC508Class(TwoWire& wire, uint8_t address) :
8+
ECCX08Class::ECCX08Class(TwoWire& wire, uint8_t address) :
99
_wire(&wire),
1010
_address(address)
1111
{
1212
}
1313

14-
ECC508Class::~ECC508Class()
14+
ECCX08Class::~ECCX08Class()
1515
{
1616
}
1717

18-
int ECC508Class::begin()
18+
int ECCX08Class::begin()
1919
{
2020
_wire->begin();
2121

@@ -26,12 +26,12 @@ int ECC508Class::begin()
2626
return 1;
2727
}
2828

29-
void ECC508Class::end()
29+
void ECCX08Class::end()
3030
{
3131
_wire->end();
3232
}
3333

34-
String ECC508Class::serialNumber()
34+
String ECCX08Class::serialNumber()
3535
{
3636
String result = (char*)NULL;
3737
byte sn[12];
@@ -64,7 +64,7 @@ String ECC508Class::serialNumber()
6464
return result;
6565
}
6666

67-
int ECC508Class::random(byte data[], size_t length)
67+
int ECCX08Class::random(byte data[], size_t length)
6868
{
6969
if (!wakeup()) {
7070
return 0;
@@ -97,7 +97,7 @@ int ECC508Class::random(byte data[], size_t length)
9797
return 1;
9898
}
9999

100-
int ECC508Class::generatePrivateKey(int slot, byte publicKey[])
100+
int ECCX08Class::generatePrivateKey(int slot, byte publicKey[])
101101
{
102102
if (!wakeup()) {
103103
return 0;
@@ -120,7 +120,7 @@ int ECC508Class::generatePrivateKey(int slot, byte publicKey[])
120120
return 1;
121121
}
122122

123-
int ECC508Class::generatePublicKey(int slot, byte publicKey[])
123+
int ECCX08Class::generatePublicKey(int slot, byte publicKey[])
124124
{
125125
if (!wakeup()) {
126126
return 0;
@@ -143,7 +143,7 @@ int ECC508Class::generatePublicKey(int slot, byte publicKey[])
143143
return 1;
144144
}
145145

146-
int ECC508Class::ecdsaVerify(const byte message[], const byte signature[], const byte pubkey[])
146+
int ECCX08Class::ecdsaVerify(const byte message[], const byte signature[], const byte pubkey[])
147147
{
148148
if (!challenge(message)) {
149149
return 0;
@@ -156,7 +156,7 @@ int ECC508Class::ecdsaVerify(const byte message[], const byte signature[], const
156156
return 1;
157157
}
158158

159-
int ECC508Class::ecSign(int slot, const byte message[], byte signature[])
159+
int ECCX08Class::ecSign(int slot, const byte message[], byte signature[])
160160
{
161161
byte rand[32];
162162

@@ -175,7 +175,7 @@ int ECC508Class::ecSign(int slot, const byte message[], byte signature[])
175175
return 1;
176176
}
177177

178-
int ECC508Class::readSlot(int slot, byte data[], int length)
178+
int ECCX08Class::readSlot(int slot, byte data[], int length)
179179
{
180180
if (slot < 0 || slot > 15) {
181181
return -1;
@@ -200,7 +200,7 @@ int ECC508Class::readSlot(int slot, byte data[], int length)
200200
return 1;
201201
}
202202

203-
int ECC508Class::writeSlot(int slot, const byte data[], int length)
203+
int ECCX08Class::writeSlot(int slot, const byte data[], int length)
204204
{
205205
if (slot < 0 || slot > 15) {
206206
return -1;
@@ -225,7 +225,7 @@ int ECC508Class::writeSlot(int slot, const byte data[], int length)
225225
return 1;
226226
}
227227

228-
int ECC508Class::locked()
228+
int ECCX08Class::locked()
229229
{
230230
byte config[4];
231231

@@ -240,7 +240,7 @@ int ECC508Class::locked()
240240
return 0;
241241
}
242242

243-
int ECC508Class::writeConfiguration(const byte data[])
243+
int ECCX08Class::writeConfiguration(const byte data[])
244244
{
245245
// skip first 16 bytes, they are not writable
246246
for (int i = 16; i < 128; i += 4) {
@@ -257,7 +257,7 @@ int ECC508Class::writeConfiguration(const byte data[])
257257
return 1;
258258
}
259259

260-
int ECC508Class::readConfiguration(byte data[])
260+
int ECCX08Class::readConfiguration(byte data[])
261261
{
262262
for (int i = 0; i < 128; i += 32) {
263263
if (!read(0, i / 4, &data[i], 32)) {
@@ -268,7 +268,7 @@ int ECC508Class::readConfiguration(byte data[])
268268
return 1;
269269
}
270270

271-
int ECC508Class::lock()
271+
int ECCX08Class::lock()
272272
{
273273
// lock config
274274
if (!lock(0)) {
@@ -283,7 +283,7 @@ int ECC508Class::lock()
283283
return 1;
284284
}
285285

286-
int ECC508Class::wakeup()
286+
int ECCX08Class::wakeup()
287287
{
288288
_wire->setClock(_wakeupFrequency);
289289
_wire->beginTransmission(0x00);
@@ -302,7 +302,7 @@ int ECC508Class::wakeup()
302302
return 1;
303303
}
304304

305-
int ECC508Class::sleep()
305+
int ECCX08Class::sleep()
306306
{
307307
_wire->beginTransmission(_address);
308308
_wire->write(0x01);
@@ -314,7 +314,7 @@ int ECC508Class::sleep()
314314
return 1;
315315
}
316316

317-
int ECC508Class::idle()
317+
int ECCX08Class::idle()
318318
{
319319
_wire->beginTransmission(_address);
320320
_wire->write(0x02);
@@ -326,7 +326,7 @@ int ECC508Class::idle()
326326
return 1;
327327
}
328328

329-
int ECC508Class::version()
329+
int ECCX08Class::version()
330330
{
331331
uint32_t version = 0;
332332

@@ -350,7 +350,7 @@ int ECC508Class::version()
350350
return version;
351351
}
352352

353-
int ECC508Class::challenge(const byte message[])
353+
int ECCX08Class::challenge(const byte message[])
354354
{
355355
uint8_t status;
356356

@@ -379,7 +379,7 @@ int ECC508Class::challenge(const byte message[])
379379
return 1;
380380
}
381381

382-
int ECC508Class::verify(const byte signature[], const byte pubkey[])
382+
int ECCX08Class::verify(const byte signature[], const byte pubkey[])
383383
{
384384
uint8_t status;
385385

@@ -412,7 +412,7 @@ int ECC508Class::verify(const byte signature[], const byte pubkey[])
412412
return 1;
413413
}
414414

415-
int ECC508Class::sign(int slot, byte signature[])
415+
int ECCX08Class::sign(int slot, byte signature[])
416416
{
417417
if (!wakeup()) {
418418
return 0;
@@ -434,7 +434,7 @@ int ECC508Class::sign(int slot, byte signature[])
434434
return 1;
435435
}
436436

437-
int ECC508Class::read(int zone, int address, byte buffer[], int length)
437+
int ECCX08Class::read(int zone, int address, byte buffer[], int length)
438438
{
439439
if (!wakeup()) {
440440
return 0;
@@ -464,7 +464,7 @@ int ECC508Class::read(int zone, int address, byte buffer[], int length)
464464
return length;
465465
}
466466

467-
int ECC508Class::write(int zone, int address, const byte buffer[], int length)
467+
int ECCX08Class::write(int zone, int address, const byte buffer[], int length)
468468
{
469469
uint8_t status;
470470

@@ -500,7 +500,7 @@ int ECC508Class::write(int zone, int address, const byte buffer[], int length)
500500
return 1;
501501
}
502502

503-
int ECC508Class::lock(int zone)
503+
int ECCX08Class::lock(int zone)
504504
{
505505
uint8_t status;
506506

@@ -528,15 +528,15 @@ int ECC508Class::lock(int zone)
528528
return 1;
529529
}
530530

531-
int ECC508Class::addressForSlotOffset(int slot, int offset)
531+
int ECCX08Class::addressForSlotOffset(int slot, int offset)
532532
{
533533
int block = offset / 32;
534534
offset = (offset % 32) / 4;
535535

536536
return (slot << 3) | (block << 8) | (offset);
537537
}
538538

539-
int ECC508Class::sendCommand(uint8_t opcode, uint8_t param1, uint16_t param2, const byte data[], size_t dataLength)
539+
int ECCX08Class::sendCommand(uint8_t opcode, uint8_t param1, uint16_t param2, const byte data[], size_t dataLength)
540540
{
541541
int commandLength = 8 + dataLength; // 1 for type, 1 for length, 1 for opcode, 1 for param1, 2 for param2, 2 for crc
542542
byte command[commandLength];
@@ -560,7 +560,7 @@ int ECC508Class::sendCommand(uint8_t opcode, uint8_t param1, uint16_t param2, co
560560
return 1;
561561
}
562562

563-
int ECC508Class::receiveResponse(void* response, size_t length)
563+
int ECCX08Class::receiveResponse(void* response, size_t length)
564564
{
565565
int retries = 20;
566566
int responseSize = length + 3; // 1 for length header, 2 for CRC
@@ -590,7 +590,7 @@ int ECC508Class::receiveResponse(void* response, size_t length)
590590
return 1;
591591
}
592592

593-
uint16_t ECC508Class::crc16(const byte data[], size_t length)
593+
uint16_t ECCX08Class::crc16(const byte data[], size_t length)
594594
{
595595
if (data == NULL || length == 0) {
596596
return 0;
@@ -619,4 +619,4 @@ uint16_t ECC508Class::crc16(const byte data[], size_t length)
619619
return crc;
620620
}
621621

622-
ECC508Class ECC508(Wire, 0x60);
622+
ECCX08Class ECCX08(Wire, 0x60);

Diff for: src/utility/ECC508.h renamed to src/utility/ECCX08.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
#ifndef _ECC508_H_
2-
#define _ECC508_H_
1+
#ifndef _ECCX08_H_
2+
#define _ECCX08_H_
33

44
#include <Arduino.h>
55
#include <Wire.h>
66

7-
class ECC508Class
7+
class ECCX08Class
88
{
99
public:
10-
ECC508Class(TwoWire& wire, uint8_t address);
11-
virtual ~ECC508Class();
10+
ECCX08Class(TwoWire& wire, uint8_t address);
11+
virtual ~ECCX08Class();
1212

1313
int begin();
1414
void end();
@@ -59,6 +59,6 @@ class ECC508Class
5959
static const uint32_t _normalFrequency;
6060
};
6161

62-
extern ECC508Class ECC508;
62+
extern ECCX08Class ECCX08;
6363

6464
#endif

Diff for: src/utility/ecc508_asn1.h renamed to src/utility/eccX08_asn1.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
#ifndef _ECC508_ASN1_H_
2-
#define _ECC508_ASN1_H_
1+
#ifndef _ECCX08_ASN1_H_
2+
#define _ECCX08_ASN1_H_
33

44
#include "bearssl/bearssl.h"
55

66
size_t
7-
ecc508_sign_asn1(const br_ec_impl *impl,
7+
eccX08_sign_asn1(const br_ec_impl *impl,
88
const br_hash_class *hf, const void *hash_value,
99
const br_ec_private_key *sk, void *sig);
1010

1111
uint32_t
12-
ecc508_vrfy_asn1(const br_ec_impl *impl,
12+
eccX08_vrfy_asn1(const br_ec_impl *impl,
1313
const void *hash, size_t hash_len,
1414
const br_ec_public_key *pk,
1515
const void *sig, size_t sig_len);

Diff for: src/utility/ecc508_sign_asn1.cpp renamed to src/utility/eccX08_sign_asn1.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#include "ecc508_asn1.h"
1+
#include "eccX08_asn1.h"
22

3-
#include "ECC508.h"
3+
#include "ECCX08.h"
44

55
#define BR_MAX_EC_SIZE 528
66
#define ORDER_LEN ((BR_MAX_EC_SIZE + 7) >> 3)
77

88
size_t
9-
ecc508_sign_asn1(const br_ec_impl * /*impl*/,
9+
eccX08_sign_asn1(const br_ec_impl * /*impl*/,
1010
const br_hash_class * /*hf*/, const void *hash_value,
1111
const br_ec_private_key *sk, void *sig)
1212
{
@@ -17,7 +17,7 @@ ecc508_sign_asn1(const br_ec_impl * /*impl*/,
1717
return 0;
1818
}
1919

20-
if (!ECC508.ecSign((int)(sk->x), (const uint8_t*)hash_value, (uint8_t*)rsig)) {
20+
if (!ECCX08.ecSign((int)(sk->x), (const uint8_t*)hash_value, (uint8_t*)rsig)) {
2121
return 0;
2222
}
2323
sig_len = 64;

0 commit comments

Comments
 (0)