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

Method Generate

src/openrct2/core/Crypt.OpenSSL.cpp:128–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126 }
127
128 void Generate() override
129 {
130 auto ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, nullptr);
131 if (ctx == nullptr)
132 {
133 throw std::runtime_error("EVP_PKEY_CTX_new_id failed");
134 }
135
136 try
137 {
138 auto status = EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, 2048);
139 if (status == 0)
140 {
141 throw std::runtime_error("EVP_PKEY_CTX_set_rsa_keygen_bits failed");
142 }
143
144 status = EVP_PKEY_keygen_init(ctx);
145 OpenSSLThrowOnBadStatus("EVP_PKEY_keygen_init", status);
146
147 EVP_PKEY* key{};
148 status = EVP_PKEY_keygen(ctx, &key);
149 OpenSSLThrowOnBadStatus("EVP_PKEY_keygen", status);
150
151 EVP_PKEY_free(_evpKey);
152 _evpKey = key;
153
154 EVP_PKEY_CTX_free(ctx);
155 }
156 catch (const std::exception&)
157 {
158 EVP_PKEY_CTX_free(ctx);
159 throw;
160 }
161 }
162
163 void SetPrivate(std::string_view pem) override
164 {

Callers

nothing calls this directly

Calls 1

OpenSSLThrowOnBadStatusFunction · 0.85

Tested by

no test coverage detected