MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / LoadPublic

Method LoadPublic

src/openrct2/network/NetworkKey.cpp:79–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77 }
78
79 bool Key::LoadPublic(IStream* stream)
80 {
81 Guard::ArgumentNotNull(stream);
82
83 size_t size = static_cast<size_t>(stream->GetLength());
84 if (size == static_cast<size_t>(-1))
85 {
86 LOG_ERROR("unknown size, refusing to load key");
87 return false;
88 }
89 if (size > 4 * 1024 * 1024)
90 {
91 LOG_ERROR("Key file suspiciously large, refusing to load it");
92 return false;
93 }
94
95 std::string pem(size, '\0');
96 stream->Read(pem.data(), pem.size());
97
98 try
99 {
100 _key = Crypt::CreateRSAKey();
101 _key->SetPublic(pem);
102 return true;
103 }
104 catch (const std::exception& e)
105 {
106 LOG_ERROR("Network::Key::LoadPublic failed: %s", e.what());
107 return false;
108 }
109 }
110
111 bool Key::SavePrivate(IStream* stream)
112 {

Callers 1

ServerHandleAuthMethod · 0.80

Calls 8

ArgumentNotNullFunction · 0.85
CreateRSAKeyFunction · 0.50
GetLengthMethod · 0.45
ReadMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
SetPublicMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected