1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 21:13:05 +01:00
Files
OpenRCT2/src/openrct2/network/NetworkKey.h
2017-09-18 17:05:28 +02:00

59 lines
1.7 KiB
C++

#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
#ifndef NETWORKKEY_H
#define NETWORKKEY_H
#ifndef DISABLE_NETWORK
#ifdef __cplusplus
#include "../common.h"
#include <string>
typedef struct evp_pkey_st EVP_PKEY;
typedef struct evp_pkey_ctx_st EVP_PKEY_CTX;
interface IStream;
class NetworkKey final
{
public:
NetworkKey();
~NetworkKey();
bool Generate();
bool LoadPrivate(IStream * stream);
bool LoadPublic(IStream * stream);
bool SavePrivate(IStream * stream);
bool SavePublic(IStream * stream);
std::string PublicKeyString();
std::string PublicKeyHash();
void Unload();
bool Sign(const uint8 * md, const size_t len, char ** signature, size_t * out_size);
bool Verify(const uint8 * md, const size_t len, const char * sig, const size_t siglen);
private:
NetworkKey (const NetworkKey &) = delete;
EVP_PKEY_CTX * _ctx = nullptr;
EVP_PKEY * _key = nullptr;
};
#endif
#endif // DISABLE_NETWORK
#endif // NETWORKKEY_H