@@ -3302,15 +3302,18 @@ Local<Function> KeyObject::Initialize(Environment* env, Local<Object> target) {
3302
3302
return function;
3303
3303
}
3304
3304
3305
- Local <Object> KeyObject::Create (Environment* env,
3306
- KeyType key_type,
3307
- const ManagedEVPPKey& pkey) {
3305
+ MaybeLocal <Object> KeyObject::Create (Environment* env,
3306
+ KeyType key_type,
3307
+ const ManagedEVPPKey& pkey) {
3308
3308
CHECK_NE (key_type, kKeyTypeSecret );
3309
3309
Local<Value> type = Integer::New (env->isolate (), key_type);
3310
- Local<Object> obj =
3311
- env->crypto_key_object_constructor ()->NewInstance (env->context (),
3312
- 1 , &type)
3313
- .ToLocalChecked ();
3310
+ Local<Object> obj;
3311
+ if (!env->crypto_key_object_constructor ()
3312
+ ->NewInstance (env->context (), 1 , &type)
3313
+ .ToLocal (&obj)) {
3314
+ return MaybeLocal<Object>();
3315
+ }
3316
+
3314
3317
KeyObject* key = Unwrap<KeyObject>(obj);
3315
3318
CHECK (key);
3316
3319
if (key_type == kKeyTypePublic )
@@ -5798,24 +5801,22 @@ class GenerateKeyPairJob : public CryptoJob {
5798
5801
if (public_key_encoding_.output_key_object_ ) {
5799
5802
// Note that this has the downside of containing sensitive data of the
5800
5803
// private key.
5801
- *pubkey = KeyObject::Create (env, kKeyTypePublic , pkey_);
5804
+ if (!KeyObject::Create (env, kKeyTypePublic , pkey_).ToLocal (pubkey))
5805
+ return false ;
5802
5806
} else {
5803
- MaybeLocal<Value> maybe_pubkey =
5804
- WritePublicKey (env, pkey_.get (), public_key_encoding_);
5805
- if (maybe_pubkey.IsEmpty ())
5807
+ if (!WritePublicKey (env, pkey_.get (), public_key_encoding_)
5808
+ .ToLocal (pubkey))
5806
5809
return false ;
5807
- *pubkey = maybe_pubkey.ToLocalChecked ();
5808
5810
}
5809
5811
5810
5812
// Now do the same for the private key.
5811
5813
if (private_key_encoding_.output_key_object_ ) {
5812
- *privkey = KeyObject::Create (env, kKeyTypePrivate , pkey_);
5814
+ if (!KeyObject::Create (env, kKeyTypePrivate , pkey_).ToLocal (privkey))
5815
+ return false ;
5813
5816
} else {
5814
- MaybeLocal<Value> maybe_privkey =
5815
- WritePrivateKey (env, pkey_.get (), private_key_encoding_);
5816
- if (maybe_privkey.IsEmpty ())
5817
+ if (!WritePrivateKey (env, pkey_.get (), private_key_encoding_)
5818
+ .ToLocal (privkey))
5817
5819
return false ;
5818
- *privkey = maybe_privkey.ToLocalChecked ();
5819
5820
}
5820
5821
5821
5822
return true ;
0 commit comments