Files
U2FDevice/IO.cpp
Michael Kuc 86af080ba6 Added registration.
Currently doesn't return any valid result, hence host believes device
failed to register, however, insecure storage of keys does occur.
2018-07-31 00:09:25 +00:00

27 lines
531 B
C++

#include "IO.hpp"
#include "Streams.hpp"
#include <iostream>
using namespace std;
vector<uint8_t> readBytes(const size_t count)
{
vector<uint8_t> bytes(count);
size_t readByteCount;
do
{
readByteCount = fread(bytes.data(), 1, count, getHostStream().get());
fwrite(bytes.data(), 1, bytes.size(), getComHostStream().get());
} while (readByteCount == 0);
clog << "Read " << readByteCount << " bytes" << endl;
if (readByteCount != count)
throw runtime_error{ "Failed to read sufficient bytes" };
return bytes;
}