Files
U2FDevice/monitor.cpp
2018-08-05 19:32:07 +00:00

61 lines
1.2 KiB
C++

#include <cstdio>
#include <memory>
#include <stdexcept>
#include <array>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <map>
#include "u2f.hpp"
#include "Constants.hpp"
#include "U2FMessage.hpp"
#include "U2F_CMD.hpp"
#include "Storage.hpp"
#include "U2F_Init_CMD.hpp"
#include "U2F_Init_Response.hpp"
#include "U2F_Msg_CMD.hpp"
using namespace std;
int main(int argc, char** argv)
{
Storage::init();
auto initFrame = U2F_Init_CMD::get();
U2F_Init_Response resp{};
resp.cid = 0xF1D0F1D0;
resp.nonce = initFrame.nonce;
resp.protocolVer = 2;
resp.majorDevVer = 1;
resp.minorDevVer = 0;
resp.buildDevVer = 1;
resp.capabilities = CAPFLAG_WINK;
resp.write();
size_t msgCount = (argc == 2 ? stoul(argv[1]) : 3u);
for (size_t i = 0; i < msgCount; i++)
{
auto reg = U2F_Msg_CMD::get();
cout << "U2F CMD ins: " << static_cast<uint32_t>(reg->ins) << endl;
reg->respond();
clog << "Fully responded" << endl;
}
/*auto m = U2FMessage::read();
cout << "U2F CMD: " << static_cast<uint32_t>(m.cmd) << endl;
for (const auto d : m.data)
clog << static_cast<uint16_t>(d) << endl;*/
Storage::save();
}