OpenTTD Source
20241121-master-g67a0fccfad
|
Implementation of signature validation routines. More...
#include "stdafx.h"
#include "signature.h"
#include "debug.h"
#include "fileio_func.h"
#include "string_func.h"
#include "3rdparty/monocypher/monocypher.h"
#include "3rdparty/monocypher/monocypher-ed25519.h"
#include "3rdparty/nlohmann/json.hpp"
#include "safeguards.h"
Go to the source code of this file.
Functions | |
static std::string | CalculateHashV1 (const std::string &filename) |
Calculate the 32-byte blake2b hash of a file. More... | |
static bool | ValidateChecksum (const std::string &filename, const std::string &checksum) |
Validate whether the checksum of a file is the same. More... | |
static bool | ValidateSignature (const std::string &signature, const nlohmann::json &files, const std::string &filename) |
Validate whether the signature is valid for this set of files. More... | |
static bool | ValidateSchema (const nlohmann::json &signatures, const std::string &filename) |
Validate the signatures file complies with the JSON schema. More... | |
static bool | _ValidateSignatureFile (const std::string &filename) |
Validate that the signatures mentioned in the signature file are matching the files in question. More... | |
bool | ValidateSignatureFile (const std::string &filename) |
Validate that the signatures mentioned in the signature file are matching the files in question. More... | |
Variables | |
static const std::initializer_list< std::array< uint8_t, 32 > > | _public_keys_v1 |
The public keys used for signature validation. More... | |
Implementation of signature validation routines.
Definition in file signature.cpp.
|
static |
Validate that the signatures mentioned in the signature file are matching the files in question.
Definition at line 194 of file signature.cpp.
References Debug, FioFOpenFile(), FS2OTTD(), NO_DIRECTORY, OTTD2FS(), ValidateSchema(), and ValidateSignature().
Referenced by ValidateSignatureFile().
|
static |
Calculate the 32-byte blake2b hash of a file.
filename | The filename to calculate the hash of. |
Definition at line 36 of file signature.cpp.
References FioFOpenFile(), FormatArrayAsHex(), and NO_DIRECTORY.
Referenced by ValidateChecksum().
|
static |
Validate whether the checksum of a file is the same.
filename | The filename to validate the checksum of. |
checksum | The expected checksum. |
Definition at line 63 of file signature.cpp.
References CalculateHashV1(), and Debug.
|
static |
Validate the signatures file complies with the JSON schema.
signatures | The signatures JSON to validate. |
filename | The filename of the signatures file (for error-reporting). |
Definition at line 145 of file signature.cpp.
References Debug.
Referenced by _ValidateSignatureFile().
|
static |
Validate whether the signature is valid for this set of files.
signature | The signature to validate. |
files | The files to validate the signature against. |
filename | The filename of the signatures file (for error-reporting). |
Definition at line 101 of file signature.cpp.
References _public_keys_v1, ConvertHexToBytes(), and Debug.
Referenced by _ValidateSignatureFile().
bool ValidateSignatureFile | ( | const std::string & | filename | ) |
Validate that the signatures mentioned in the signature file are matching the files in question.
Definition at line 267 of file signature.cpp.
References _ValidateSignatureFile().
|
static |
The public keys used for signature validation.
Definition at line 25 of file signature.cpp.
Referenced by ValidateSignature().