Separated waiting for message from acting on message.
Necessary refactoring of parameter types propagated through source.
This commit is contained in:
@@ -23,22 +23,22 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
using namespace std;
|
||||
|
||||
U2F_Init_CMD::U2F_Init_CMD(const shared_ptr<U2FMessage> uMsg)
|
||||
U2F_Init_CMD::U2F_Init_CMD(const U2FMessage& uMsg)
|
||||
{
|
||||
if (uMsg->cmd != U2FHID_INIT)
|
||||
if (uMsg.cmd != U2FHID_INIT)
|
||||
throw runtime_error{ "Failed to get U2F Init message" };
|
||||
else if (uMsg->cid != CID_BROADCAST)
|
||||
else if (uMsg.cid != CID_BROADCAST)
|
||||
{
|
||||
U2FMessage::error(uMsg->cid, ERR_OTHER);
|
||||
U2FMessage::error(uMsg.cid, ERR_OTHER);
|
||||
throw runtime_error{ "Invalid CID for init command" };
|
||||
}
|
||||
else if (uMsg->data.size() != INIT_NONCE_SIZE)
|
||||
else if (uMsg.data.size() != INIT_NONCE_SIZE)
|
||||
{
|
||||
U2FMessage::error(uMsg->cid, ERR_INVALID_LEN);
|
||||
U2FMessage::error(uMsg.cid, ERR_INVALID_LEN);
|
||||
throw runtime_error{ "Init nonce is incorrect size" };
|
||||
}
|
||||
|
||||
this->nonce = *reinterpret_cast<const uint64_t*>(uMsg->data.data());
|
||||
this->nonce = *reinterpret_cast<const uint64_t*>(uMsg.data.data());
|
||||
}
|
||||
|
||||
void U2F_Init_CMD::respond(const uint32_t channelID) const
|
||||
|
||||
Reference in New Issue
Block a user