Skip to content

Add primitives to compute provisioningID #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions examples/boardID/boardID.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
This file is part of the Arduino_CloudUtils library.

Copyright (c) 2024 Arduino SA

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#include <Arduino_BPId.h>

void setup() {
Serial.begin(9600);
while (!Serial);

#ifdef ARDUINO_OPTA
Ethernet.begin(NULL,0,0);
#endif

}

void loop() {
Serial.println(arduino::bpid::get());
delay(2000);
}
43 changes: 43 additions & 0 deletions examples/sha256/buffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma once

/*
* The following buffer is an hex dump of 1k of random data generated as
* head -c 1k /dev/urandom > /tmp/test
* and dumped with the following command `hexdump extras/test/test_files/test-1k -e '32/1 "0x%02X, ""\n"'`
* The SHA256 is known 1a7004279b162a6321de07de9d0362a66833b16f9acf870a69331e219eeafc7c /tmp/test
*/

uint8_t buffer[] = {
0x58, 0x1A, 0x10, 0xDD, 0x00, 0xBE, 0xE1, 0x2B, 0xE5, 0xA9, 0x62, 0xAF, 0x59, 0x66, 0x9C, 0x84, 0x50, 0x91, 0x30, 0x8E, 0x8F, 0xE4, 0x82, 0xE7, 0xDA, 0x9F, 0x90, 0x7A, 0xA2, 0x78, 0xCF, 0x7D,
0x40, 0x0E, 0x15, 0x5D, 0x2E, 0xF8, 0x6F, 0xA2, 0xEC, 0x50, 0xF1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0x25,
0xA5, 0x42, 0xC5, 0x2E, 0xD3, 0x09, 0xF1, 0x3B, 0x8E, 0x6C, 0x30, 0x29, 0xD0, 0xD4, 0x62, 0x8C, 0xA3, 0x40, 0x21, 0xFA, 0x93, 0x0E, 0x48, 0x81, 0x20, 0x32, 0x1D, 0xF7, 0xD5, 0xF4, 0x50, 0x64,
0x68, 0x15, 0x98, 0xFF, 0x3B, 0xD9, 0x64, 0x50, 0x9C, 0x74, 0x0C, 0x25, 0x1E, 0xED, 0xFF, 0x87, 0x84, 0x0B, 0x6D, 0x0F, 0xF3, 0x5E, 0xF9, 0xB6, 0x84, 0x6E, 0x3D, 0xF4, 0x00, 0x37, 0x4D, 0x68,
};
43 changes: 43 additions & 0 deletions examples/sha256/sha256.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
This file is part of the Arduino_CloudUtils library.

Copyright (c) 2024 Arduino SA

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#include <Arduino_SHA256.h>
#include "buffer.h"

void setup() {
Serial.begin(9600);
while(!Serial);

uint8_t sha[SHA256::HASH_SIZE];

SHA256 sha256;
sha256.begin();
sha256.update(buffer, sizeof(buffer));
sha256.finalize(sha);

Serial.println(hexEncode(sha, sizeof(sha)));

/* One-shot */
arduino::sha256::oneshot(buffer, sizeof(buffer), sha);
Serial.println(hexEncode(sha, sizeof(sha)));
}

static String hexEncode(uint8_t* in, uint32_t size) {
String out;
out.reserve((size * 2) + 1);

char* ptr = out.begin();
for (uint32_t i = 0; i < size; i++) {
ptr += sprintf(ptr, "%02X", in[i]);
}
return String(out.c_str());
}

void loop() { }
12 changes: 12 additions & 0 deletions src/Arduino_BPId.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
This file is part of the Arduino_CloudUtils library.

Copyright (c) 2024 Arduino SA

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once

#include "./bpid/bpid.h"
12 changes: 12 additions & 0 deletions src/Arduino_HEX.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
This file is part of the Arduino_CloudUtils library.

Copyright (c) 2024 Arduino SA

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once

#include "./hex/hex.h"
12 changes: 12 additions & 0 deletions src/Arduino_SHA256.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
This file is part of the Arduino_CloudUtils library.

Copyright (c) 2024 Arduino SA

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once

#include "./sha256/SHA256.h"
46 changes: 46 additions & 0 deletions src/bpid/bpid.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
This file is part of the Arduino_CloudUtils library.

Copyright (c) 2024 Arduino SA

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#include "bpid.h"
#include "../sha256/SHA256.h"
#include "../hex/hex.h"

namespace arduino { namespace bpid {

bool get(uint8_t* in, uint32_t size) {
if (size < BOARD_PROVISIONING_ID_SIZE) {
return false;
}
uint8_t offset = 0;
if (!arduino::ucid::get(&in[offset], size)) {
return false;
}
offset += arduino::ucid::UC_UID_SIZE;
if (!arduino::mac::get(&in[offset], size - offset)) {
return false;
}
offset += arduino::mac::IFACE_MAC_SIZE;
if (!arduino::csn::get(&in[offset], size - offset)) {
return false;
}
return true;
}

String get() {
uint8_t data[BOARD_PROVISIONING_ID_SIZE];
if (!get(data, sizeof(data))) {
return String("");
}
uint8_t out[SHA256::HASH_SIZE];
arduino::sha256::oneshot(data, sizeof(data), out);
return arduino::hex::encode(out, sizeof(out));
}

}} // arduino::bpid
30 changes: 30 additions & 0 deletions src/bpid/bpid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
This file is part of the Arduino_CloudUtils library.

Copyright (c) 2024 Arduino SA

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#pragma once

#include <Arduino.h>
#include "ucid.h"
#include "mac.h"
#include "csn.h"

namespace arduino { namespace bpid {
/*
* This library contains the methods to get board provisioning id
*/

constexpr int BOARD_PROVISIONING_ID_SIZE = arduino::ucid::UC_UID_SIZE +
arduino::mac::IFACE_MAC_SIZE +
arduino::csn::CRYPTO_SN_SIZE;

bool get(uint8_t* in, uint32_t size);
String get();

}} // arduino::bpid
26 changes: 26 additions & 0 deletions src/bpid/csn.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
This file is part of the Arduino_CloudUtils library.
Copyright (c) 2024 Arduino SA
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#include "csn.h"

namespace arduino { namespace csn {

bool get(uint8_t *in, uint32_t size) {
if (size < CRYPTO_SN_SIZE) {
return false;
}
SecureElement se;
if (!se.begin() || !se.serialNumber(in)) {
return false;
}
return true;
}

}} // arduino::csn
39 changes: 39 additions & 0 deletions src/bpid/csn.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
This file is part of the Arduino_CloudUtils library.

Copyright (c) 2024 Arduino SA

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#pragma once

#include <Arduino.h>
#include <Arduino_SecureElement.h>

namespace arduino { namespace csn {
/*
* This library contains the methods to get board microcontroller id
*/

#if defined(ARDUINO_NANO_RP2040_CONNECT) || \
defined(ARDUINO_SAMD_MKRWIFI1010) || \
defined(ARDUINO_SAMD_NANO_33_IOT) || \
defined(ARDUINO_PORTENTA_H7_M7) || \
defined(ARDUINO_OPTA) || \
defined(ARDUINO_GIGA)
constexpr int CRYPTO_SN_SIZE = 9;
#elif defined(ARDUINO_PORTENTA_C33) || \
defined(ARDUINO_NICLA_VISION)
constexpr int CRYPTO_SN_SIZE = SE05X_SN_LENGTH;
#elif defined(ARDUINO_UNOR4_WIFI)
constexpr int CRYPTO_SN_SIZE = 6;
#else
#error "Unknown board"
#endif

bool get(uint8_t *in, uint32_t size);

}} // arduino::csn
37 changes: 37 additions & 0 deletions src/bpid/mac.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
This file is part of the Arduino_CloudUtils library.

Copyright (c) 2024 Arduino SA

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#include "mac.h"

namespace arduino { namespace mac {

bool get(uint8_t *in, uint32_t size) {
if (size < IFACE_MAC_SIZE) {
return false;
}
#if defined(ARDUINO_SAMD_MKRWIFI1010) || \
defined(ARDUINO_SAMD_NANO_33_IOT)
WiFi.macAddress(in);
#elif defined(ARDUINO_PORTENTA_H7_M7) || \
defined(ARDUINO_NICLA_VISION) || \
defined(ARDUINO_GIGA)
WiFi.macAddress(in);
#elif defined(ARDUINO_PORTENTA_C33) || \
defined(ARDUINO_UNOR4_WIFI)
WiFi.macAddress(in);
#elif defined(ARDUINO_NANO_RP2040_CONNECT)
WiFi.macAddress(in);
#elif defined(ARDUINO_OPTA)
Ethernet.MACAddress(in);
#endif
return true;
}

}} // arduino::mac
52 changes: 52 additions & 0 deletions src/bpid/mac.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
This file is part of the Arduino_CloudUtils library.

Copyright (c) 2024 Arduino SA

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#pragma once

#if defined(ARDUINO_NANO_RP2040_CONNECT) || \
defined(ARDUINO_SAMD_MKRWIFI1010) || \
defined(ARDUINO_SAMD_NANO_33_IOT) || \
defined(ARDUINO_PORTENTA_H7_M7) || \
defined(ARDUINO_NICLA_VISION) || \
defined(ARDUINO_GIGA)
#include <WiFi.h>
#define IFACE_MAC_ADDR_LENGTH WL_MAC_ADDR_LENGTH
#elif defined(ARDUINO_PORTENTA_C33)
#include <WiFiC3.h>
#define IFACE_MAC_ADDR_LENGTH WL_MAC_ADDR_LENGTH
#elif defined(ARDUINO_UNOR4_WIFI)
#include <WiFi.h>
#define IFACE_MAC_ADDR_LENGTH WL_MAC_ADDR_LENGTH
#elif defined(ARDUINO_OPTA)
#include <Ethernet.h>
#define IFACE_MAC_ADDR_LENGTH 6
#else
#error "Unknown board"
#endif

namespace arduino { namespace mac {
/*
* This library contains the methods to get board mac address
* ARDUINO_NANO_RP2040_CONNECT: reversed
* ARDUINO_SAMD_MKRWIFI1010: reversed
* ARDUINO_SAMD_NANO_33_IOT: reversed
* ARDUINO_PORTENTA_H7_M7: WiFi.setTimeout(0);WiFi.begin("In33dm4c4ddr35", "In33dm4c4ddr35", ENC_TYPE_TKIP) reversed
* ARDUINO_NICLA_VISION:
* ARDUINO_GIGA:
* ARDUINO_PORTENTA_C33: Interface.begin() not reversed
* ARDUINO_UNOR4_WIFI: not reversed
* ARDUINO_OPTA: Ethernet.begin(NULL,0,0); reversed
*/

constexpr int IFACE_MAC_SIZE = IFACE_MAC_ADDR_LENGTH;

bool get(uint8_t *in, uint32_t size);

}} // arduino::mac
Loading