Skip to content

Commit 51fef93

Browse files
committed
use constant for slot of board private key
1 parent 4285899 commit 51fef93

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

examples/utility/Provisioning_2.0/ClaimingHandler.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "utility/HCI.h"
1414
#include <Arduino_HEX.h>
1515

16+
#define SLOT_BOARD_PRIVATE_KEY 1
17+
1618
extern const char *SKETCH_VERSION;
1719

1820
ClaimingHandlerClass::ClaimingHandlerClass():
@@ -109,7 +111,7 @@ void ClaimingHandlerClass::getIdReqHandler() {
109111
}
110112

111113
SElementJWS sejws;
112-
String publicKey = sejws.publicKey(*_secureElement, 1, false);
114+
String publicKey = sejws.publicKey(*_secureElement, SLOT_BOARD_PRIVATE_KEY, false);
113115
if (publicKey == "") {
114116
DEBUG_ERROR("CH::%s Error: public key not created", __FUNCTION__);
115117
sendStatus(StatusMessage::ERROR);
@@ -203,17 +205,16 @@ void ClaimingHandlerClass::getProvSketchVersionRequestCb() {
203205
_receivedEvent = ClaimingReqEvents::GET_PROV_SKETCH_VERSION;
204206
}
205207

206-
String ClaimingHandlerClass::generateToken()
207-
{
208-
String token = getAIoTCloudJWT(*_secureElement, *_uhwid, _ts, 1);
208+
String ClaimingHandlerClass::generateToken() {
209+
String token = getAIoTCloudJWT(*_secureElement, *_uhwid, _ts, SLOT_BOARD_PRIVATE_KEY);
209210
if(token == "") {
210211
byte publicKey[64];
211212
DEBUG_INFO("Generating private key");
212-
if(!_secureElement->generatePrivateKey(1, publicKey)){
213+
if(!_secureElement->generatePrivateKey(SLOT_BOARD_PRIVATE_KEY, publicKey)){
213214
DEBUG_ERROR("CH::%s Error: private key generation failed", __FUNCTION__);
214215
return "";
215216
}
216-
token = getAIoTCloudJWT(*_secureElement, *_uhwid, _ts, 1);
217+
token = getAIoTCloudJWT(*_secureElement, *_uhwid, _ts, SLOT_BOARD_PRIVATE_KEY);
217218
}
218219

219220
return token;

0 commit comments

Comments
 (0)