Changeset View
Changeset View
Standalone View
Standalone View
source/ps/ModIo.cpp
/* Copyright (C) 2021 Wildfire Games. | /* Copyright (C) 2022 Wildfire Games. | ||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
* "Software"), to deal in the Software without restriction, including | * "Software"), to deal in the Software without restriction, including | ||||
* without limitation the rights to use, copy, modify, merge, publish, | * without limitation the rights to use, copy, modify, merge, publish, | ||||
* distribute, sublicense, and/or sell copies of the Software, and to | * distribute, sublicense, and/or sell copies of the Software, and to | ||||
* permit persons to whom the Software is furnished to do so, subject to | * permit persons to whom the Software is furnished to do so, subject to | ||||
* the following conditions: | * the following conditions: | ||||
▲ Show 20 Lines • Show All 800 Lines • ▼ Show 20 Lines | for (const std::string& file_sig : minisigs) | ||||
// We only _really_ care about the second line which is the signature of the file (b64-encoded) | // We only _really_ care about the second line which is the signature of the file (b64-encoded) | ||||
// Also handling the other signature is nice, but not really required. | // Also handling the other signature is nice, but not really required. | ||||
const std::string& msg_sig = sig_lines[1]; | const std::string& msg_sig = sig_lines[1]; | ||||
size_t bin_len = 0; | size_t bin_len = 0; | ||||
if (sodium_base642bin((unsigned char*)&sig, sizeof sig, msg_sig.c_str(), msg_sig.size(), NULL, &bin_len, NULL, sodium_base64_VARIANT_ORIGINAL) != 0 || bin_len != sizeof sig) | if (sodium_base642bin((unsigned char*)&sig, sizeof sig, msg_sig.c_str(), msg_sig.size(), NULL, &bin_len, NULL, sodium_base64_VARIANT_ORIGINAL) != 0 || bin_len != sizeof sig) | ||||
FAIL("Failed to decode base64 sig."); | FAIL("Failed to decode base64 sig."); | ||||
cassert(sizeof pk.keynum == sizeof sig.keynum); | static_assert(sizeof pk.keynum == sizeof sig.keynum); | ||||
if (memcmp(&pk.keynum, &sig.keynum, sizeof sig.keynum) != 0) | if (memcmp(&pk.keynum, &sig.keynum, sizeof sig.keynum) != 0) | ||||
continue; // mismatched key, try another one | continue; // mismatched key, try another one | ||||
if (memcmp(&sig.sig_alg, "ED", 2) != 0) | if (memcmp(&sig.sig_alg, "ED", 2) != 0) | ||||
FAIL("Only hashed minisign signatures are supported."); | FAIL("Only hashed minisign signatures are supported."); | ||||
// Signature matches our public key | // Signature matches our public key | ||||
Show All 34 Lines |
Wildfire Games · Phabricator