| 136 | } |
| 137 | |
| 138 | PublicKey::PublicKey(PemEncoded, StringRef pem) { |
| 139 | ASSERT(!pem.empty()); |
| 140 | auto mem = AutoCPointer(::BIO_new_mem_buf(pem.begin(), pem.size()), &::BIO_free); |
| 141 | if (!mem) |
| 142 | traceAndThrowDecode("PemMemBioInitError"); |
| 143 | auto key = ::PEM_read_bio_PUBKEY(mem, nullptr, nullptr, nullptr); |
| 144 | if (!key) |
| 145 | traceAndThrowDecode("PemReadPublicKeyError"); |
| 146 | ptr = std::shared_ptr<EVP_PKEY>(key, &::EVP_PKEY_free); |
| 147 | if (algorithm() == PKeyAlgorithm::UNSUPPORTED) { |
| 148 | TraceEvent(SevWarnAlways, "UnsupportedPKeyAlgorithm") |
| 149 | .suppressFor(10) |
| 150 | .detail("Algorithm", ::OBJ_nid2sn(EVP_PKEY_base_id(ptr.get()))); |
| 151 | throw pkey_decode_error(); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | PublicKey::PublicKey(DerEncoded, StringRef der) { |
| 156 | ASSERT(!der.empty()); |
nothing calls this directly
no test coverage detected