feat: tick up protocol minor version, always return response on shbc config so RPS can fall-back to non-shbc configuration.

This commit is contained in:
Mudit Vats
2021-08-06 09:18:54 -07:00
parent e0fe219646
commit 706a512bc7
4 changed files with 41 additions and 34 deletions

View File

@@ -33,7 +33,7 @@ bool get_response_payload(std::string cert_algo, std::string cert_hash, web::jso
return true;
}
bool shbc_create_response(std::string cert_algo, std::string cert_hash, std::string& response)
bool shbc_create_response(std::string cert_algo, std::string cert_hash, bool config_status, std::string& response)
{
web::json::value msg;
@@ -49,21 +49,32 @@ bool shbc_create_response(std::string cert_algo, std::string cert_hash, std::str
tmp = utility::conversions::convertstring(PROTOCOL_VERSION);
msg[U("protocolVersion")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("");
msg[U("status")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("");
msg[U("message")] = web::json::value::string(tmp);
// get the activation payload
web::json::value responsePayload;
if (!get_response_payload(cert_algo, cert_hash, responsePayload)) return false;
if (config_status)
{
// get the activation payload
web::json::value responsePayload;
if (!get_response_payload(cert_algo, cert_hash, responsePayload)) return false;
// serialize payload
std::string serializedPayload = utility::conversions::to_utf8string(responsePayload.serialize());
std::string encodedPayload = util_encode_base64(serializedPayload);
utility::string_t payload = utility::conversions::to_string_t(encodedPayload);
msg[U("payload")] = web::json::value::string(payload);
// serialize payload
std::string serializedPayload = utility::conversions::to_utf8string(responsePayload.serialize());
std::string encodedPayload = util_encode_base64(serializedPayload);
utility::string_t payload = utility::conversions::to_string_t(encodedPayload);
msg[U("payload")] = web::json::value::string(payload);
tmp = utility::conversions::convertstring("success");
msg[U("status")] = web::json::value::string(tmp);
}
else
{
tmp = utility::conversions::convertstring("");
msg[U("payload")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("failed");
msg[U("status")] = web::json::value::string(tmp);
}
// serialize the entire message
response = utility::conversions::to_utf8string(msg.serialize());