| 31 | |
| 32 | template <typename T, typename WriteFunc> |
| 33 | WasiCryptoExpect<T> writeKeyToBio(EVP_PKEY *Key, WriteFunc &&Func) { |
| 34 | BioPtr Bio{BIO_new(BIO_s_mem())}; |
| 35 | opensslCheck(Func(Bio.get(), Key)); |
| 36 | |
| 37 | BUF_MEM *Mem = nullptr; |
| 38 | opensslCheck(BIO_get_mem_ptr(Bio.get(), &Mem)); |
| 39 | |
| 40 | T Ret(Mem->length); |
| 41 | size_t Size; |
| 42 | if (BIO_read_ex(Bio.get(), Ret.data(), Ret.size(), &Size) && |
| 43 | Size == Ret.size()) { |
| 44 | return Ret; |
| 45 | } |
| 46 | return WasiCryptoUnexpect(__WASI_CRYPTO_ERRNO_ALGORITHM_FAILURE); |
| 47 | } |
| 48 | |
| 49 | } // namespace |
| 50 |
nothing calls this directly
no test coverage detected