39
39
for the same purpose.
40
40
*/
41
41
42
- boolean ATECCX08A::begin (uint8_t i2caddr, TwoWire &wirePort, Stream &serialPort)
42
+ bool ATECCX08A::begin (uint8_t i2caddr, TwoWire &wirePort, Stream &serialPort)
43
43
{
44
44
// Bring in the user's choices
45
45
_i2cPort = &wirePort; // Grab which port the user wants us to use
@@ -68,7 +68,7 @@ boolean ATECCX08A::begin(uint8_t i2caddr, TwoWire &wirePort, Stream &serialPort)
68
68
respond with a status, we are gonna use wakeUp() for the same purpose.
69
69
*/
70
70
71
- boolean ATECCX08A::wakeUp ()
71
+ bool ATECCX08A::wakeUp ()
72
72
{
73
73
_i2cPort->beginTransmission (0x00 ); // set up to write to address "0x00",
74
74
// This creates a "wake condition" where SDA is held low for at least tWLO
@@ -122,7 +122,7 @@ void ATECCX08A::idleMode()
122
122
silicon revision.
123
123
*/
124
124
125
- boolean ATECCX08A::getInfo ()
125
+ bool ATECCX08A::getInfo ()
126
126
{
127
127
if (!sendCommand (COMMAND_OPCODE_INFO, 0x00 , 0x0000 )) // param1 - 0x00 (revision mode).
128
128
{
@@ -156,7 +156,7 @@ boolean ATECCX08A::getInfo()
156
156
and listens for success response (0x00).
157
157
*/
158
158
159
- boolean ATECCX08A::lockConfig ()
159
+ bool ATECCX08A::lockConfig ()
160
160
{
161
161
return lock (LOCK_MODE_ZONE_CONFIG);
162
162
}
@@ -172,7 +172,7 @@ boolean ATECCX08A::lockConfig()
172
172
This function also updates global variables for these other things.
173
173
*/
174
174
175
- boolean ATECCX08A::readConfigZone (boolean debug)
175
+ bool ATECCX08A::readConfigZone (bool debug)
176
176
{
177
177
// read block 0, the first 32 bytes of config zone into inputBuffer
178
178
read (ZONE_CONFIG, ADDRESS_CONFIG_READ_BLOCK_0, CONFIG_ZONE_READ_SIZE);
@@ -236,7 +236,7 @@ boolean ATECCX08A::readConfigZone(boolean debug)
236
236
and listens for success response (0x00).
237
237
*/
238
238
239
- boolean ATECCX08A::lockDataAndOTP ()
239
+ bool ATECCX08A::lockDataAndOTP ()
240
240
{
241
241
return lock (LOCK_MODE_ZONE_DATA_AND_OTP);
242
242
}
@@ -249,7 +249,7 @@ boolean ATECCX08A::lockDataAndOTP()
249
249
and listens for success response (0x00).
250
250
*/
251
251
252
- boolean ATECCX08A::lockDataSlot0 ()
252
+ bool ATECCX08A::lockDataSlot0 ()
253
253
{
254
254
return lock (LOCK_MODE_SLOT0);
255
255
}
@@ -262,7 +262,7 @@ boolean ATECCX08A::lockDataSlot0()
262
262
and listens for success response (0x00).
263
263
*/
264
264
265
- boolean ATECCX08A::lock (uint8_t zone)
265
+ bool ATECCX08A::lock (uint8_t zone)
266
266
{
267
267
if (!sendCommand (COMMAND_OPCODE_LOCK, zone, 0x0000 ))
268
268
return false ;
@@ -289,7 +289,7 @@ boolean ATECCX08A::lock(uint8_t zone)
289
289
290
290
/* * \brief
291
291
292
- updateRandom32Bytes(boolean debug)
292
+ updateRandom32Bytes(bool debug)
293
293
294
294
This function pulls a complete random number (all 32 bytes)
295
295
It stores it in a global array called random32Bytes[]
@@ -300,7 +300,7 @@ boolean ATECCX08A::lock(uint8_t zone)
300
300
They are getRandomByte(), getRandomInt(), and getRandomLong().
301
301
*/
302
302
303
- boolean ATECCX08A::updateRandom32Bytes (boolean debug)
303
+ bool ATECCX08A::updateRandom32Bytes (bool debug)
304
304
{
305
305
if (!sendCommand (COMMAND_OPCODE_RANDOM, 0x00 , 0x0000 ))
306
306
return false ;
@@ -343,28 +343,28 @@ boolean ATECCX08A::updateRandom32Bytes(boolean debug)
343
343
344
344
/* * \brief
345
345
346
- getRandomByte(boolean debug)
346
+ getRandomByte(bool debug)
347
347
348
348
This function returns a random byte.
349
349
It calls updateRandom32Bytes(), then uses the first byte in that array for a return value.
350
350
*/
351
351
352
- byte ATECCX08A::getRandomByte (boolean debug)
352
+ byte ATECCX08A::getRandomByte (bool debug)
353
353
{
354
354
updateRandom32Bytes (debug);
355
355
return random32Bytes[0 ];
356
356
}
357
357
358
358
/* * \brief
359
359
360
- getRandomInt(boolean debug)
360
+ getRandomInt(bool debug)
361
361
362
362
This function returns a random Int.
363
363
It calls updateRandom32Bytes(), then uses the first 2 bytes in that array for a return value.
364
364
It bitwize ORS the first two bytes of the array into the return value.
365
365
*/
366
366
367
- int ATECCX08A::getRandomInt (boolean debug)
367
+ int ATECCX08A::getRandomInt (bool debug)
368
368
{
369
369
updateRandom32Bytes (debug);
370
370
int return_val;
@@ -376,14 +376,14 @@ int ATECCX08A::getRandomInt(boolean debug)
376
376
377
377
/* * \brief
378
378
379
- getRandomLong(boolean debug)
379
+ getRandomLong(bool debug)
380
380
381
381
This function returns a random Long.
382
382
It calls updateRandom32Bytes(), then uses the first 4 bytes in that array for a return value.
383
383
It bitwize ORS the first 4 bytes of the array into the return value.
384
384
*/
385
385
386
- long ATECCX08A::getRandomLong (boolean debug)
386
+ long ATECCX08A::getRandomLong (bool debug)
387
387
{
388
388
updateRandom32Bytes (debug);
389
389
long return_val;
@@ -430,7 +430,7 @@ long ATECCX08A::random(long min, long max)
430
430
431
431
/* * \brief
432
432
433
- receiveResponseData(uint8_t length, boolean debug)
433
+ receiveResponseData(uint8_t length, bool debug)
434
434
435
435
This function receives messages from the ATECCX08a IC (up to 128 Bytes)
436
436
It will return true if it receives the correct amount of data and good CRCs.
@@ -443,7 +443,7 @@ long ATECCX08A::random(long min, long max)
443
443
It needs length argument:
444
444
length: length of data to receive (includes count + DATA + 2 crc bytes)
445
445
*/
446
- boolean ATECCX08A::receiveResponseData (uint8_t length, boolean debug)
446
+ bool ATECCX08A::receiveResponseData (uint8_t length, bool debug)
447
447
{
448
448
449
449
// pull in data 32 bytes at at time. (necessary to avoid overflow on atmega328)
@@ -506,14 +506,14 @@ boolean ATECCX08A::receiveResponseData(uint8_t length, boolean debug)
506
506
507
507
/* * \brief
508
508
509
- checkCount(boolean debug)
509
+ checkCount(bool debug)
510
510
511
511
This function checks that the count byte received in the most recent message equals countGlobal
512
512
Call receiveResponseData, and then imeeditately call this to check the count of the complete message.
513
513
Returns true if inputBuffer[0] == countGlobal.
514
514
*/
515
515
516
- boolean ATECCX08A::checkCount (boolean debug)
516
+ bool ATECCX08A::checkCount (bool debug)
517
517
{
518
518
if (debug)
519
519
{
@@ -535,13 +535,13 @@ boolean ATECCX08A::checkCount(boolean debug)
535
535
536
536
/* * \brief
537
537
538
- checkCrc(boolean debug)
538
+ checkCrc(bool debug)
539
539
540
540
This function checks that the CRC bytes received in the most recent message equals a calculated CRCs
541
541
Call receiveResponseData, then call immediately call this to check the CRCs of the complete message.
542
542
*/
543
543
544
- boolean ATECCX08A::checkCrc (boolean debug)
544
+ bool ATECCX08A::checkCrc (bool debug)
545
545
{
546
546
// Check CRC[0] and CRC[1] are good to go.
547
547
atca_calculate_crc (countGlobal - CRC_SIZE, inputBuffer); // first calculate it
@@ -622,7 +622,7 @@ void ATECCX08A::cleanInputBuffer()
622
622
Sparkfun Default Configuration Sketch calls this, and then locks the data/otp zones and slot 0.
623
623
*/
624
624
625
- boolean ATECCX08A::createNewKeyPair (uint16_t slot)
625
+ bool ATECCX08A::createNewKeyPair (uint16_t slot)
626
626
{
627
627
if (!sendCommand (COMMAND_OPCODE_GENKEY, GENKEY_MODE_NEW_PRIVATE, slot))
628
628
return false ;
@@ -651,7 +651,7 @@ boolean ATECCX08A::createNewKeyPair(uint16_t slot)
651
651
652
652
/* * \brief
653
653
654
- generatePublicKey(uint16_t slot, boolean debug)
654
+ generatePublicKey(uint16_t slot, bool debug)
655
655
656
656
This function uses the GENKEY command in "Public Key Computation" mode.
657
657
@@ -664,7 +664,7 @@ boolean ATECCX08A::createNewKeyPair(uint16_t slot)
664
664
a global variable named publicKey64Bytes for later use.
665
665
*/
666
666
667
- boolean ATECCX08A::generatePublicKey (uint16_t slot, boolean debug)
667
+ bool ATECCX08A::generatePublicKey (uint16_t slot, bool debug)
668
668
{
669
669
if (!sendCommand (COMMAND_OPCODE_GENKEY, GENKEY_MODE_PUBLIC, slot))
670
670
return false ;
@@ -711,20 +711,20 @@ boolean ATECCX08A::generatePublicKey(uint16_t slot, boolean debug)
711
711
712
712
/* * \brief
713
713
714
- read(uint8_t zone, uint16_t address, uint8_t length, boolean debug)
714
+ read(uint8_t zone, uint16_t address, uint8_t length, bool debug)
715
715
716
716
Reads data from the IC at a specific zone and address.
717
717
Your data response will be available at inputBuffer[].
718
718
719
719
For more info on address encoding, see datasheet pg 58.
720
720
*/
721
721
722
- boolean ATECCX08A::read (uint8_t zone, uint16_t address, uint8_t length, boolean debug)
722
+ bool ATECCX08A::read (uint8_t zone, uint16_t address, uint8_t length, bool debug)
723
723
{
724
724
return read_output (zone, address, length, NULL , debug);
725
725
}
726
726
727
- boolean ATECCX08A::read_output (uint8_t zone, uint16_t address, uint8_t length, uint8_t * output, boolean debug)
727
+ bool ATECCX08A::read_output (uint8_t zone, uint16_t address, uint8_t length, uint8_t * output, bool debug)
728
728
{
729
729
int i;
730
730
// adjust zone as needed for whether it's 4 or 32 bytes length read
@@ -776,7 +776,7 @@ boolean ATECCX08A::read_output(uint8_t zone, uint16_t address, uint8_t length, u
776
776
For more info on zone and address encoding, see datasheet pg 58.
777
777
*/
778
778
779
- boolean ATECCX08A::write (uint8_t zone, uint16_t address, uint8_t *data, uint8_t length_of_data)
779
+ bool ATECCX08A::write (uint8_t zone, uint16_t address, uint8_t *data, uint8_t length_of_data)
780
780
{
781
781
// adjust zone as needed for whether it's 4 or 32 bytes length write
782
782
// bit 7 of param1 needs to be set correctly
@@ -833,7 +833,7 @@ boolean ATECCX08A::write(uint8_t zone, uint16_t address, uint8_t *data, uint8_t
833
833
receives the signature and copies it to signature[].
834
834
*/
835
835
836
- boolean ATECCX08A::createSignature (uint8_t *data, uint16_t slot)
836
+ bool ATECCX08A::createSignature (uint8_t *data, uint16_t slot)
837
837
{
838
838
if (!loadTempKey (data) || !signTempKey (slot))
839
839
return false ;
@@ -855,7 +855,7 @@ boolean ATECCX08A::createSignature(uint8_t *data, uint16_t slot)
855
855
when it requests data, and this will allow us to create a unique data + signature for every communication.
856
856
*/
857
857
858
- boolean ATECCX08A::loadTempKey (uint8_t *data)
858
+ bool ATECCX08A::loadTempKey (uint8_t *data)
859
859
{
860
860
if (!sendCommand (COMMAND_OPCODE_NONCE, NONCE_MODE_PASSTHROUGH, 0x0000 , data, 32 ))
861
861
return false ;
@@ -891,7 +891,7 @@ boolean ATECCX08A::loadTempKey(uint8_t *data)
891
891
The response from this command (the signature) is stored in global varaible signature[].
892
892
*/
893
893
894
- boolean ATECCX08A::signTempKey (uint16_t slot)
894
+ bool ATECCX08A::signTempKey (uint16_t slot)
895
895
{
896
896
if (!sendCommand (COMMAND_OPCODE_SIGN, SIGN_MODE_TEMPKEY, slot))
897
897
return false ;
@@ -939,7 +939,7 @@ boolean ATECCX08A::signTempKey(uint16_t slot)
939
939
Note, it acutally uses loadTempKey, then uses the verify command in "external public key" mode.
940
940
*/
941
941
942
- boolean ATECCX08A::verifySignature (uint8_t *message, uint8_t *signature, uint8_t *publicKey)
942
+ bool ATECCX08A::verifySignature (uint8_t *message, uint8_t *signature, uint8_t *publicKey)
943
943
{
944
944
uint8_t data_sigAndPub[128 ];
945
945
@@ -975,7 +975,7 @@ boolean ATECCX08A::verifySignature(uint8_t *message, uint8_t *signature, uint8_t
975
975
return true ;
976
976
}
977
977
978
- boolean ATECCX08A::sha256 (uint8_t * plain, size_t len, uint8_t * hash)
978
+ bool ATECCX08A::sha256 (uint8_t * plain, size_t len, uint8_t * hash)
979
979
{
980
980
int i;
981
981
size_t chunks = len / SHA_BLOCK_SIZE + !!(len % SHA_BLOCK_SIZE);
@@ -1051,11 +1051,11 @@ boolean ATECCX08A::sha256(uint8_t * plain, size_t len, uint8_t * hash)
1051
1051
Returns true if write commands were successful.
1052
1052
*/
1053
1053
1054
- boolean ATECCX08A::writeConfigSparkFun ()
1054
+ bool ATECCX08A::writeConfigSparkFun ()
1055
1055
{
1056
1056
// keep track of our write command results.
1057
- boolean result1;
1058
- boolean result2;
1057
+ bool result1;
1058
+ bool result2;
1059
1059
1060
1060
// set keytype on slot 0 and 1 to 0x3300
1061
1061
// Lockable, ECC, PuInfo set (public key always allowed to be generated), contains a private Key
@@ -1084,7 +1084,7 @@ boolean ATECCX08A::writeConfigSparkFun()
1084
1084
So those specific transmissions are handled in unique functions.
1085
1085
*/
1086
1086
1087
- boolean ATECCX08A::sendCommand (uint8_t command_opcode, uint8_t param1, uint16_t param2, uint8_t *data, size_t length_of_data)
1087
+ bool ATECCX08A::sendCommand (uint8_t command_opcode, uint8_t param1, uint16_t param2, uint8_t *data, size_t length_of_data)
1088
1088
{
1089
1089
// build packet array (total_transmission) to send a communication to IC, with opcode COMMAND
1090
1090
// It expects to see: word address, count, command opcode, param1, param2, data (optional), CRC[0], CRC[1]
0 commit comments