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

Method LoadPrivate

src/openrct2/network/NetworkKey.cpp:47–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45 }
46
47 bool Key::LoadPrivate(IStream* stream)
48 {
49 Guard::ArgumentNotNull(stream);
50
51 size_t size = static_cast<size_t>(stream->GetLength());
52 if (size == static_cast<size_t>(-1))
53 {
54 LOG_ERROR("unknown size, refusing to load key");
55 return false;
56 }
57 if (size > 4 * 1024 * 1024)
58 {
59 LOG_ERROR("Key file suspiciously large, refusing to load it");
60 return false;
61 }
62
63 std::string pem(size, '\0');
64 stream->Read(pem.data(), pem.size());
65
66 try
67 {
68 _key = Crypt::CreateRSAKey();
69 _key->SetPrivate(pem);
70 return true;
71 }
72 catch (const std::exception& e)
73 {
74 LOG_ERROR("Network::Key::LoadPrivate failed: %s", e.what());
75 return false;
76 }
77 }
78
79 bool Key::LoadPublic(IStream* stream)
80 {

Callers 3

BeginClientMethod · 0.80
Client_Handle_TOKENMethod · 0.80
SendPasswordFunction · 0.80

Calls 8

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

Tested by

no test coverage detected