forked from arduino-libraries/Arduino_CloudUtils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsn.cpp
33 lines (27 loc) · 784 Bytes
/
csn.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
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"
#include "hex/hex.h"
namespace arduino { namespace csn {
bool get(uint8_t *in, uint32_t size) {
#if CRYPTO_SN_SIZE == 0
(void)in;
(void)size;
return false;
#else
if (size < CRYPTO_SN_SIZE) {
return false;
}
SecureElement se;
if (!se.begin() || !arduino::hex::decode(se.serialNumber(), in, size)) {
return false;
}
return true;
#endif
}
}} // arduino::csn