@@ -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
@@ -463,14 +449,7 @@ class KeyObject : public BaseObject {
463449 v8::MaybeLocal<v8::Value> ExportPrivateKey (
464450 const PrivateKeyEncodingConfig& config) const ;
465451
466- KeyObject (Environment* env,
467- v8::Local<v8::Object> wrap,
468- KeyType key_type)
469- : BaseObject(env, wrap),
470- key_type_ (key_type),
471- symmetric_key_(nullptr , nullptr ) {
472- MakeWeak ();
473- }
452+ KeyObject (Environment* env, v8::Local<v8::Object> wrap, KeyType key_type);
474453
475454 private:
476455 const KeyType key_type_;
@@ -544,17 +523,7 @@ class CipherBase : public BaseObject {
544523 static void SetAuthTag (const v8::FunctionCallbackInfo<v8::Value>& args);
545524 static void SetAAD (const v8::FunctionCallbackInfo<v8::Value>& args);
546525
547- CipherBase (Environment* env,
548- v8::Local<v8::Object> wrap,
549- CipherKind kind)
550- : BaseObject(env, wrap),
551- ctx_ (nullptr ),
552- kind_(kind),
553- auth_tag_state_(kAuthTagUnknown ),
554- auth_tag_len_(kNoAuthTagLength ),
555- pending_auth_failed_(false ) {
556- MakeWeak ();
557- }
526+ CipherBase (Environment* env, v8::Local<v8::Object> wrap, CipherKind kind);
558527
559528 private:
560529 DeleteFnPtr<EVP_CIPHER_CTX, EVP_CIPHER_CTX_free> ctx_;
@@ -584,18 +553,16 @@ class Hmac : public BaseObject {
584553 static void HmacUpdate (const v8::FunctionCallbackInfo<v8::Value>& args);
585554 static void HmacDigest (const v8::FunctionCallbackInfo<v8::Value>& args);
586555
587- Hmac (Environment* env, v8::Local<v8::Object> wrap)
588- : BaseObject(env, wrap),
589- ctx_ (nullptr ) {
590- MakeWeak ();
591- }
556+ Hmac (Environment* env, v8::Local<v8::Object> wrap);
592557
593558 private:
594559 DeleteFnPtr<HMAC_CTX, HMAC_CTX_free> ctx_;
595560};
596561
597- class Hash : public BaseObject {
562+ class Hash final : public BaseObject {
598563 public:
564+ ~Hash () override ;
565+
599566 static void Initialize (Environment* env, v8::Local<v8::Object> target);
600567
601568 // TODO(joyeecheung): track the memory used by OpenSSL types
@@ -611,18 +578,7 @@ class Hash : public BaseObject {
611578 static void HashUpdate (const v8::FunctionCallbackInfo<v8::Value>& args);
612579 static void HashDigest (const v8::FunctionCallbackInfo<v8::Value>& args);
613580
614- Hash (Environment* env, v8::Local<v8::Object> wrap)
615- : BaseObject(env, wrap),
616- mdctx_ (nullptr ),
617- has_md_(false ),
618- md_value_(nullptr ) {
619- MakeWeak ();
620- }
621-
622- ~Hash () override {
623- if (md_value_ != nullptr )
624- OPENSSL_clear_free (md_value_, md_len_);
625- }
581+ Hash (Environment* env, v8::Local<v8::Object> wrap);
626582
627583 private:
628584 EVPMDPointer mdctx_;
@@ -644,9 +600,7 @@ class SignBase : public BaseObject {
644600 kSignMalformedSignature
645601 } Error;
646602
647- SignBase (Environment* env, v8::Local<v8::Object> wrap)
648- : BaseObject(env, wrap) {
649- }
603+ SignBase (Environment* env, v8::Local<v8::Object> wrap);
650604
651605 Error Init (const char * sign_type);
652606 Error Update (const char * data, int len);
@@ -692,9 +646,7 @@ class Sign : public SignBase {
692646 static void SignUpdate (const v8::FunctionCallbackInfo<v8::Value>& args);
693647 static void SignFinal (const v8::FunctionCallbackInfo<v8::Value>& args);
694648
695- Sign (Environment* env, v8::Local<v8::Object> wrap) : SignBase(env, wrap) {
696- MakeWeak ();
697- }
649+ Sign (Environment* env, v8::Local<v8::Object> wrap);
698650};
699651
700652class Verify : public SignBase {
@@ -713,9 +665,7 @@ class Verify : public SignBase {
713665 static void VerifyUpdate (const v8::FunctionCallbackInfo<v8::Value>& args);
714666 static void VerifyFinal (const v8::FunctionCallbackInfo<v8::Value>& args);
715667
716- Verify (Environment* env, v8::Local<v8::Object> wrap) : SignBase(env, wrap) {
717- MakeWeak ();
718- }
668+ Verify (Environment* env, v8::Local<v8::Object> wrap);
719669};
720670
721671class PublicKeyCipher {
@@ -772,11 +722,7 @@ class DiffieHellman : public BaseObject {
772722 static void VerifyErrorGetter (
773723 const v8::FunctionCallbackInfo<v8::Value>& args);
774724
775- DiffieHellman (Environment* env, v8::Local<v8::Object> wrap)
776- : BaseObject(env, wrap),
777- verifyError_ (0 ) {
778- MakeWeak ();
779- }
725+ DiffieHellman (Environment* env, v8::Local<v8::Object> wrap);
780726
781727 // TODO(joyeecheung): track the memory used by OpenSSL types
782728 SET_NO_MEMORY_INFO ()
@@ -795,11 +741,9 @@ class DiffieHellman : public BaseObject {
795741 DHPointer dh_;
796742};
797743
798- class ECDH : public BaseObject {
744+ class ECDH final : public BaseObject {
799745 public:
800- ~ECDH () override {
801- group_ = nullptr ;
802- }
746+ ~ECDH () override ;
803747
804748 static void Initialize (Environment* env, v8::Local<v8::Object> target);
805749 static ECPointPointer BufferToPoint (Environment* env,
@@ -812,13 +756,7 @@ class ECDH : public BaseObject {
812756 SET_SELF_SIZE (ECDH)
813757
814758 protected:
815- ECDH (Environment* env, v8::Local<v8::Object> wrap, ECKeyPointer&& key)
816- : BaseObject(env, wrap),
817- key_ (std::move(key)),
818- group_(EC_KEY_get0_group(key_.get())) {
819- MakeWeak ();
820- CHECK_NOT_NULL (group_);
821- }
759+ ECDH (Environment* env, v8::Local<v8::Object> wrap, ECKeyPointer&& key);
822760
823761 static void New (const v8::FunctionCallbackInfo<v8::Value>& args);
824762 static void GenerateKeys (const v8::FunctionCallbackInfo<v8::Value>& args);
0 commit comments