| 190 | } |
| 191 | |
| 192 | PrivateKey::PrivateKey(PemEncoded, StringRef pem) { |
| 193 | ASSERT(!pem.empty()); |
| 194 | auto mem = AutoCPointer(::BIO_new_mem_buf(pem.begin(), pem.size()), &::BIO_free); |
| 195 | if (!mem) |
| 196 | traceAndThrowDecode("PrivateKeyDecodeInitError"); |
| 197 | auto key = ::PEM_read_bio_PrivateKey(mem, nullptr, nullptr, nullptr); |
| 198 | if (!key) |
| 199 | traceAndThrowDecode("PemReadPrivateKeyError"); |
| 200 | ptr = std::shared_ptr<EVP_PKEY>(key, &::EVP_PKEY_free); |
| 201 | if (algorithm() == PKeyAlgorithm::UNSUPPORTED) { |
| 202 | TraceEvent(SevWarnAlways, "UnsupportedPKeyAlgorithm") |
| 203 | .suppressFor(10) |
| 204 | .detail("Algorithm", ::OBJ_nid2sn(EVP_PKEY_base_id(ptr.get()))); |
| 205 | throw pkey_decode_error(); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | PrivateKey::PrivateKey(DerEncoded, StringRef der) { |
| 210 | ASSERT(!der.empty()); |
nothing calls this directly
no test coverage detected