Skip to content

secureId: simplify code #6

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions src/secureId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/

#include "secureId.h"
#include <Arduino_HEX.h>

bool secureId::begin() {
return !!_se.begin();
Expand All @@ -24,7 +23,7 @@ bool secureId::get(uint8_t *in, uint32_t size) {
if (size < CRYPTO_SN_SIZE) {
return false;
}
if (!THEXT::decode((_se.serialNumber()).substring(0, CRYPTO_SN_SIZE*2), in, size)) {
if (!_se.serialNumber(in, size)) {
return false;
}
return true;
Expand Down
14 changes: 5 additions & 9 deletions src/secureId.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,15 @@
defined(ARDUINO_SAMD_MKRWAN1300) || \
defined(ARDUINO_SAMD_MKRWAN1310) || \
defined(ARDUINO_SAMD_MKRNB1500) || \
defined(ARDUINO_SAMD_MKR1000) || \
defined(ARDUINO_PORTENTA_H7_M7) || \
defined(ARDUINO_SAMD_MKR1000) || \
defined(ARDUINO_PORTENTA_C33) || \
defined(ARDUINO_NICLA_VISION) || \
defined(ARDUINO_UNOR4_WIFI) || \
defined(ARDUINO_OPTA) || \
defined(ARDUINO_GIGA)
#include <Arduino_SecureElement.h>
#define CRYPTO_SN_SIZE 9
#elif defined(ARDUINO_PORTENTA_C33) || \
defined(ARDUINO_NICLA_VISION)
#include <Arduino_SecureElement.h>
#define CRYPTO_SN_SIZE 18
#elif defined(ARDUINO_UNOR4_WIFI)
#include <Arduino_SecureElement.h>
#define CRYPTO_SN_SIZE 6
#define CRYPTO_SN_SIZE SE_SN_LENGTH
#else
#define CRYPTO_SN_SIZE 0
#endif
Expand Down
Loading