diff --git a/platformio.ini b/platformio.ini
index 2ac06440b..0c48f7917 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -65,6 +65,7 @@ lib_deps =
${env.lib_deps}
; Portduino is using meshtastic fork for now
jgromes/RadioLib@5.4.1
+ sparkfun/SparkFun ATECCX08a Arduino Library@^1.3.0
build_flags = ${env.build_flags} -Os
-DRADIOLIB_SPI_PARANOID=0
diff --git a/src/configuration.h b/src/configuration.h
index 524dbec36..2aeb0f4a5 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -110,6 +110,13 @@ along with this program. If not, see .
#define INA_ADDR_ALTERNATE 0x41
#define QMC6310_ADDR 0x1C
#define QMI8658_ADDR 0x6B
+
+// -----------------------------------------------------------------------------
+// Security
+// -----------------------------------------------------------------------------
+
+#define ATECC608B_ADDR 0x35
+
// -----------------------------------------------------------------------------
// GPS
// -----------------------------------------------------------------------------
diff --git a/src/detect/i2cScan.h b/src/detect/i2cScan.h
index 3adb44277..69fc1a8a8 100644
--- a/src/detect/i2cScan.h
+++ b/src/detect/i2cScan.h
@@ -9,6 +9,39 @@
#endif
#if HAS_WIRE
+
+void printATECCInfo()
+{
+ atecc.readConfigZone(false);
+
+ DEBUG_MSG("ATECC608B Serial Number: ");
+ for (int i = 0 ; i < 9 ; i++) {
+ DEBUG_MSG("%02x",atecc.serialNumber[i]);
+ }
+
+ DEBUG_MSG(", Rev Number: ");
+ for (int i = 0 ; i < 4 ; i++) {
+ DEBUG_MSG("%02x",atecc.revisionNumber[i]);
+ }
+ DEBUG_MSG("\n");
+
+ DEBUG_MSG("ATECC608B Config %s",atecc.configLockStatus ? "Locked" : "Unlocked");
+ DEBUG_MSG(", Data %s",atecc.dataOTPLockStatus ? "Locked" : "Unlocked");
+ DEBUG_MSG(", Slot 0 %s\n",atecc.slot0LockStatus ? "Locked" : "Unlocked");
+
+ if (atecc.configLockStatus && atecc.dataOTPLockStatus && atecc.slot0LockStatus) {
+ if (atecc.generatePublicKey() == false) {
+ DEBUG_MSG("ATECC608B Error generating public key\n");
+ } else {
+ DEBUG_MSG("ATECC608B Public Key: ");
+ for (int i = 0 ; i < 64 ; i++) {
+ DEBUG_MSG("%02x",atecc.publicKey64Bytes[i]);
+ }
+ DEBUG_MSG("\n");
+ }
+ }
+}
+
uint16_t getRegisterValue(uint8_t address, uint8_t reg, uint8_t length) {
uint16_t value = 0x00;
Wire.beginTransmission(address);
@@ -79,6 +112,15 @@ void scanI2Cdevice(void)
DEBUG_MSG("unknown display found\n");
}
}
+ if (addr == ATECC608B_ADDR){
+ keystore_found = addr;
+ if (atecc.begin(keystore_found) == true) {
+ DEBUG_MSG("ATECC608B initialized\n");
+ } else {
+ DEBUG_MSG("ATECC608B initialization failed\n");
+ }
+ printATECCInfo();
+ }
#ifdef RV3028_RTC
if (addr == RV3028_RTC){
rtc_found = addr;
diff --git a/src/main.cpp b/src/main.cpp
index c3f892bce..a17de7eca 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -80,6 +80,10 @@ uint8_t kb_model;
// The I2C address of the RTC Module (if found)
uint8_t rtc_found;
+// Keystore Chips
+uint8_t keystore_found;
+ATECCX08A atecc;
+
bool eink_found = true;
uint32_t serialSinceMsec;
diff --git a/src/main.h b/src/main.h
index f3f9c62c9..f0f18a943 100644
--- a/src/main.h
+++ b/src/main.h
@@ -6,18 +6,22 @@
#include "PowerStatus.h"
#include "graphics/Screen.h"
#include "mesh/generated/telemetry.pb.h"
+#include
extern uint8_t screen_found;
extern uint8_t screen_model;
extern uint8_t cardkb_found;
extern uint8_t kb_model;
extern uint8_t rtc_found;
+extern uint8_t keystore_found;
extern bool eink_found;
extern bool pmu_found;
extern bool isCharging;
extern bool isUSBPowered;
+extern ATECCX08A atecc;
+
extern uint8_t nodeTelemetrySensorsMap[TelemetrySensorType_QMI8658+1];
extern int TCPPort; // set by Portduino