mirror of
https://github.com/vicliu624/trail-mate.git
synced 2026-10-23 05:32:18 +00:00
WIP: checkpoint geocaching before main integration
This commit is contained in:
1 parent
d7a2f35328
commit
3d65ece83d
244 files changed
+25291
-126
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#include "geocaching/protocol/verify_record.h"
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
struct UnavailableCrypto : geocaching::protocol::RecordCrypto
|
||||
{
|
||||
bool sha256(geocaching::ByteView, std::uint8_t[32]) override { return false; }
|
||||
geocaching::protocol::VerificationResult verifyEd25519(
|
||||
geocaching::ByteView, geocaching::ByteView, geocaching::ByteView) override
|
||||
{
|
||||
return geocaching::protocol::VerificationResult::CryptoUnavailable;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
assert(argc == 2);
|
||||
std::ifstream file(argv[1], std::ios::binary);
|
||||
assert(file.good());
|
||||
std::vector<std::uint8_t> bytes((std::istreambuf_iterator<char>(file)), {});
|
||||
std::vector<std::uint8_t> workspace(4200);
|
||||
UnavailableCrypto crypto;
|
||||
geocaching::protocol::VerifiedRecordView out;
|
||||
using namespace geocaching::protocol;
|
||||
assert(verifyGeocache({bytes.data(), bytes.size()}, crypto, workspace.data(), 1, out) ==
|
||||
VerificationResult::WorkspaceTooSmall);
|
||||
assert(verifyGeocache({bytes.data(), bytes.size()}, crypto, workspace.data(), workspace.size(), out) ==
|
||||
VerificationResult::CryptoUnavailable);
|
||||
assert(out.record.encoded.data == nullptr);
|
||||
bytes.pop_back();
|
||||
assert(verifyGeocache({bytes.data(), bytes.size()}, crypto, workspace.data(), workspace.size(), out) ==
|
||||
VerificationResult::InvalidRecord);
|
||||
}
|
||||
Reference in new issue
Block a user