@@ -104,7 +104,7 @@ ParseKeyResult TryParsePublicKey(EVPKeyPointer* pkey,
104104ParseKeyResult ParsePublicKeyPEM (EVPKeyPointer* pkey,
105105 const char * key_pem,
106106 int key_pem_len) {
107- BIOPointer bp ( BIO_new_mem_buf ( const_cast < char *>( key_pem) , key_pem_len) );
107+ auto bp = BIOPointer::New ( key_pem, key_pem_len);
108108 if (!bp)
109109 return ParseKeyResult::kParseKeyFailed ;
110110
@@ -218,7 +218,7 @@ ParseKeyResult ParsePrivateKey(EVPKeyPointer* pkey,
218218 const ByteSource* passphrase = config.passphrase_ .get ();
219219
220220 if (config.format_ == kKeyFormatPEM ) {
221- BIOPointer bio ( BIO_new_mem_buf ( key, key_len) );
221+ auto bio = BIOPointer::New ( key, key_len);
222222 if (!bio)
223223 return ParseKeyResult::kParseKeyFailed ;
224224
@@ -233,7 +233,7 @@ ParseKeyResult ParsePrivateKey(EVPKeyPointer* pkey,
233233 const unsigned char * p = reinterpret_cast <const unsigned char *>(key);
234234 pkey->reset (d2i_PrivateKey (EVP_PKEY_RSA, nullptr , &p, key_len));
235235 } else if (config.type_ .ToChecked () == kKeyEncodingPKCS8 ) {
236- BIOPointer bio ( BIO_new_mem_buf ( key, key_len) );
236+ auto bio = BIOPointer::New ( key, key_len);
237237 if (!bio)
238238 return ParseKeyResult::kParseKeyFailed ;
239239
@@ -292,7 +292,7 @@ MaybeLocal<Value> BIOToStringOrBuffer(
292292MaybeLocal<Value> WritePrivateKey (Environment* env,
293293 OSSL3_CONST EVP_PKEY* pkey,
294294 const PrivateKeyEncodingConfig& config) {
295- BIOPointer bio ( BIO_new ( BIO_s_mem ()) );
295+ auto bio = BIOPointer::NewMem ( );
296296 CHECK (bio);
297297
298298 // If an empty string was passed as the passphrase, the ByteSource might
@@ -422,7 +422,7 @@ bool WritePublicKeyInner(OSSL3_CONST EVP_PKEY* pkey,
422422MaybeLocal<Value> WritePublicKey (Environment* env,
423423 OSSL3_CONST EVP_PKEY* pkey,
424424 const PublicKeyEncodingConfig& config) {
425- BIOPointer bio ( BIO_new ( BIO_s_mem ()) );
425+ auto bio = BIOPointer::NewMem ( );
426426 CHECK (bio);
427427
428428 if (!WritePublicKeyInner (pkey, bio, config)) {
@@ -1448,7 +1448,7 @@ WebCryptoKeyExportStatus PKEY_SPKI_Export(
14481448 CHECK_EQ (key_data->GetKeyType (), kKeyTypePublic );
14491449 ManagedEVPPKey m_pkey = key_data->GetAsymmetricKey ();
14501450 Mutex::ScopedLock lock (*m_pkey.mutex ());
1451- BIOPointer bio ( BIO_new ( BIO_s_mem ()) );
1451+ auto bio = BIOPointer::NewMem ( );
14521452 CHECK (bio);
14531453 if (!i2d_PUBKEY_bio (bio.get (), m_pkey.get ()))
14541454 return WebCryptoKeyExportStatus::FAILED;
@@ -1464,7 +1464,7 @@ WebCryptoKeyExportStatus PKEY_PKCS8_Export(
14641464 ManagedEVPPKey m_pkey = key_data->GetAsymmetricKey ();
14651465 Mutex::ScopedLock lock (*m_pkey.mutex ());
14661466
1467- BIOPointer bio ( BIO_new ( BIO_s_mem ()) );
1467+ auto bio = BIOPointer::NewMem ( );
14681468 CHECK (bio);
14691469 PKCS8Pointer p8inf (EVP_PKEY2PKCS8 (m_pkey.get ()));
14701470 if (!i2d_PKCS8_PRIV_KEY_INFO_bio (bio.get (), p8inf.get ()))
0 commit comments