Skip to content

Commit 01dad9e

Browse files
committed
send public key before uhwid
1 parent 4183137 commit 01dad9e

File tree

1 file changed

+38
-34
lines changed

1 file changed

+38
-34
lines changed

examples/utility/Provisioning_2.0/ClaimingHandler.cpp

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -92,43 +92,47 @@ void ClaimingHandlerClass::poll() {
9292
}
9393

9494
void ClaimingHandlerClass::getIdReqHandler() {
95-
if (_ts != 0) {
96-
byte _uhwidBytes[32];
97-
hex::decode(_uhwid->c_str(), _uhwidBytes, _uhwid->length());
98-
//Send UHWID
99-
ProvisioningOutputMessage idMsg = {MessageOutputType::UHWID};
100-
idMsg.m.uhwid = _uhwidBytes;
101-
_agentManager.sendMsg(idMsg);
102-
103-
String token = generateToken();
104-
if (token == "") {
105-
DEBUG_ERROR("CH::%s Error: token not created", __FUNCTION__);
106-
sendStatus(StatusMessage::ERROR);
107-
return;
108-
}
109-
110-
//Send JWT
111-
ProvisioningOutputMessage jwtMsg = {MessageOutputType::JWT};
112-
jwtMsg.m.jwt = token.c_str();
113-
_agentManager.sendMsg(jwtMsg);
114-
_ts = 0;
115-
116-
SElementJWS sejws;
117-
String publicKey = sejws.publicKey(*_secureElement, 1, false);
118-
if (publicKey == "") {
119-
DEBUG_ERROR("CH::%s Error: public key not created", __FUNCTION__);
120-
sendStatus(StatusMessage::ERROR);
121-
return;
122-
}
123-
124-
//Send public key
125-
ProvisioningOutputMessage publicKeyMsg = {MessageOutputType::PROV_PUBLIC_KEY};
126-
publicKeyMsg.m.provPublicKey = publicKey.c_str();
127-
_agentManager.sendMsg(publicKeyMsg);
128-
} else {
95+
if (_ts == 0) {
12996
DEBUG_ERROR("CH::%s Error: timestamp not provided" , __FUNCTION__);
13097
sendStatus(StatusMessage::PARAMS_NOT_FOUND);
98+
return;
99+
}
100+
101+
byte _uhwidBytes[32];
102+
hex::decode(_uhwid->c_str(), _uhwidBytes, _uhwid->length());
103+
104+
String token = generateToken();
105+
if (token == "") {
106+
DEBUG_ERROR("CH::%s Error: token not created", __FUNCTION__);
107+
sendStatus(StatusMessage::ERROR);
108+
return;
131109
}
110+
111+
SElementJWS sejws;
112+
String publicKey = sejws.publicKey(*_secureElement, 1, false);
113+
if (publicKey == "") {
114+
DEBUG_ERROR("CH::%s Error: public key not created", __FUNCTION__);
115+
sendStatus(StatusMessage::ERROR);
116+
return;
117+
}
118+
119+
//Send public key
120+
ProvisioningOutputMessage publicKeyMsg = {MessageOutputType::PROV_PUBLIC_KEY};
121+
publicKeyMsg.m.provPublicKey = publicKey.c_str();
122+
_agentManager.sendMsg(publicKeyMsg);
123+
124+
125+
//Send UHWID
126+
ProvisioningOutputMessage idMsg = {MessageOutputType::UHWID};
127+
idMsg.m.uhwid = _uhwidBytes;
128+
_agentManager.sendMsg(idMsg);
129+
130+
//Send JWT
131+
ProvisioningOutputMessage jwtMsg = {MessageOutputType::JWT};
132+
jwtMsg.m.jwt = token.c_str();
133+
_agentManager.sendMsg(jwtMsg);
134+
_ts = 0;
135+
132136
}
133137

134138
void ClaimingHandlerClass::resetStoredCredReqHandler() {

0 commit comments

Comments
 (0)