@@ -84,11 +84,9 @@ extern void UseExtraCaCerts(const std::string& file);
8484
8585void InitCryptoOnce ();
8686
87- class SecureContext : public BaseObject {
87+ class SecureContext final : public BaseObject {
8888 public:
89- ~SecureContext () override {
90- Reset ();
91- }
89+ ~SecureContext () override ;
9290
9391 static void Initialize (Environment* env, v8::Local<v8::Object> target);
9492
@@ -177,20 +175,8 @@ class SecureContext : public BaseObject {
177175 HMAC_CTX* hctx,
178176 int enc);
179177
180- SecureContext (Environment* env, v8::Local<v8::Object> wrap)
181- : BaseObject(env, wrap) {
182- MakeWeak ();
183- env->isolate ()->AdjustAmountOfExternalAllocatedMemory (kExternalSize );
184- }
185-
186- inline void Reset () {
187- if (ctx_ != nullptr ) {
188- env ()->isolate ()->AdjustAmountOfExternalAllocatedMemory (-kExternalSize );
189- }
190- ctx_.reset ();
191- cert_.reset ();
192- issuer_.reset ();
193- }
178+ SecureContext (Environment* env, v8::Local<v8::Object> wrap);
179+ void Reset ();
194180};
195181
196182// SSLWrap implicitly depends on the inheriting class' handle having an
@@ -460,14 +446,7 @@ class KeyObject : public BaseObject {
460446 v8::MaybeLocal<v8::Value> ExportPrivateKey (
461447 const PrivateKeyEncodingConfig& config) const ;
462448
463- KeyObject (Environment* env,
464- v8::Local<v8::Object> wrap,
465- KeyType key_type)
466- : BaseObject(env, wrap),
467- key_type_ (key_type),
468- symmetric_key_(nullptr , nullptr ) {
469- MakeWeak ();
470- }
449+ KeyObject (Environment* env, v8::Local<v8::Object> wrap, KeyType key_type);
471450
472451 private:
473452 const KeyType key_type_;
@@ -541,17 +520,7 @@ class CipherBase : public BaseObject {
541520 static void SetAuthTag (const v8::FunctionCallbackInfo<v8::Value>& args);
542521 static void SetAAD (const v8::FunctionCallbackInfo<v8::Value>& args);
543522
544- CipherBase (Environment* env,
545- v8::Local<v8::Object> wrap,
546- CipherKind kind)
547- : BaseObject(env, wrap),
548- ctx_ (nullptr ),
549- kind_(kind),
550- auth_tag_state_(kAuthTagUnknown ),
551- auth_tag_len_(kNoAuthTagLength ),
552- pending_auth_failed_(false ) {
553- MakeWeak ();
554- }
523+ CipherBase (Environment* env, v8::Local<v8::Object> wrap, CipherKind kind);
555524
556525 private:
557526 DeleteFnPtr<EVP_CIPHER_CTX, EVP_CIPHER_CTX_free> ctx_;
@@ -581,18 +550,16 @@ class Hmac : public BaseObject {
581550 static void HmacUpdate (const v8::FunctionCallbackInfo<v8::Value>& args);
582551 static void HmacDigest (const v8::FunctionCallbackInfo<v8::Value>& args);
583552
584- Hmac (Environment* env, v8::Local<v8::Object> wrap)
585- : BaseObject(env, wrap),
586- ctx_ (nullptr ) {
587- MakeWeak ();
588- }
553+ Hmac (Environment* env, v8::Local<v8::Object> wrap);
589554
590555 private:
591556 DeleteFnPtr<HMAC_CTX, HMAC_CTX_free> ctx_;
592557};
593558
594- class Hash : public BaseObject {
559+ class Hash final : public BaseObject {
595560 public:
561+ ~Hash () override ;
562+
596563 static void Initialize (Environment* env, v8::Local<v8::Object> target);
597564
598565 // TODO(joyeecheung): track the memory used by OpenSSL types
@@ -608,18 +575,7 @@ class Hash : public BaseObject {
608575 static void HashUpdate (const v8::FunctionCallbackInfo<v8::Value>& args);
609576 static void HashDigest (const v8::FunctionCallbackInfo<v8::Value>& args);
610577
611- Hash (Environment* env, v8::Local<v8::Object> wrap)
612- : BaseObject(env, wrap),
613- mdctx_ (nullptr ),
614- has_md_(false ),
615- md_value_(nullptr ) {
616- MakeWeak ();
617- }
618-
619- ~Hash () override {
620- if (md_value_ != nullptr )
621- OPENSSL_clear_free (md_value_, md_len_);
622- }
578+ Hash (Environment* env, v8::Local<v8::Object> wrap);
623579
624580 private:
625581 EVPMDPointer mdctx_;
@@ -641,9 +597,7 @@ class SignBase : public BaseObject {
641597 kSignMalformedSignature
642598 } Error;
643599
644- SignBase (Environment* env, v8::Local<v8::Object> wrap)
645- : BaseObject(env, wrap) {
646- }
600+ SignBase (Environment* env, v8::Local<v8::Object> wrap);
647601
648602 Error Init (const char * sign_type);
649603 Error Update (const char * data, int len);
@@ -689,9 +643,7 @@ class Sign : public SignBase {
689643 static void SignUpdate (const v8::FunctionCallbackInfo<v8::Value>& args);
690644 static void SignFinal (const v8::FunctionCallbackInfo<v8::Value>& args);
691645
692- Sign (Environment* env, v8::Local<v8::Object> wrap) : SignBase(env, wrap) {
693- MakeWeak ();
694- }
646+ Sign (Environment* env, v8::Local<v8::Object> wrap);
695647};
696648
697649class Verify : public SignBase {
@@ -710,9 +662,7 @@ class Verify : public SignBase {
710662 static void VerifyUpdate (const v8::FunctionCallbackInfo<v8::Value>& args);
711663 static void VerifyFinal (const v8::FunctionCallbackInfo<v8::Value>& args);
712664
713- Verify (Environment* env, v8::Local<v8::Object> wrap) : SignBase(env, wrap) {
714- MakeWeak ();
715- }
665+ Verify (Environment* env, v8::Local<v8::Object> wrap);
716666};
717667
718668class PublicKeyCipher {
@@ -769,11 +719,7 @@ class DiffieHellman : public BaseObject {
769719 static void VerifyErrorGetter (
770720 const v8::FunctionCallbackInfo<v8::Value>& args);
771721
772- DiffieHellman (Environment* env, v8::Local<v8::Object> wrap)
773- : BaseObject(env, wrap),
774- verifyError_ (0 ) {
775- MakeWeak ();
776- }
722+ DiffieHellman (Environment* env, v8::Local<v8::Object> wrap);
777723
778724 // TODO(joyeecheung): track the memory used by OpenSSL types
779725 SET_NO_MEMORY_INFO ()
@@ -792,11 +738,9 @@ class DiffieHellman : public BaseObject {
792738 DHPointer dh_;
793739};
794740
795- class ECDH : public BaseObject {
741+ class ECDH final : public BaseObject {
796742 public:
797- ~ECDH () override {
798- group_ = nullptr ;
799- }
743+ ~ECDH () override ;
800744
801745 static void Initialize (Environment* env, v8::Local<v8::Object> target);
802746 static ECPointPointer BufferToPoint (Environment* env,
@@ -809,13 +753,7 @@ class ECDH : public BaseObject {
809753 SET_SELF_SIZE (ECDH)
810754
811755 protected:
812- ECDH (Environment* env, v8::Local<v8::Object> wrap, ECKeyPointer&& key)
813- : BaseObject(env, wrap),
814- key_ (std::move(key)),
815- group_(EC_KEY_get0_group(key_.get())) {
816- MakeWeak ();
817- CHECK_NOT_NULL (group_);
818- }
756+ ECDH (Environment* env, v8::Local<v8::Object> wrap, ECKeyPointer&& key);
819757
820758 static void New (const v8::FunctionCallbackInfo<v8::Value>& args);
821759 static void GenerateKeys (const v8::FunctionCallbackInfo<v8::Value>& args);
0 commit comments