@@ -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
@@ -461,14 +447,7 @@ class KeyObject : public BaseObject {
461447 v8::MaybeLocal<v8::Value> ExportPrivateKey (
462448 const PrivateKeyEncodingConfig& config) const ;
463449
464- KeyObject (Environment* env,
465- v8::Local<v8::Object> wrap,
466- KeyType key_type)
467- : BaseObject(env, wrap),
468- key_type_ (key_type),
469- symmetric_key_(nullptr , nullptr ) {
470- MakeWeak ();
471- }
450+ KeyObject (Environment* env, v8::Local<v8::Object> wrap, KeyType key_type);
472451
473452 private:
474453 const KeyType key_type_;
@@ -542,17 +521,7 @@ class CipherBase : public BaseObject {
542521 static void SetAuthTag (const v8::FunctionCallbackInfo<v8::Value>& args);
543522 static void SetAAD (const v8::FunctionCallbackInfo<v8::Value>& args);
544523
545- CipherBase (Environment* env,
546- v8::Local<v8::Object> wrap,
547- CipherKind kind)
548- : BaseObject(env, wrap),
549- ctx_ (nullptr ),
550- kind_(kind),
551- auth_tag_state_(kAuthTagUnknown ),
552- auth_tag_len_(kNoAuthTagLength ),
553- pending_auth_failed_(false ) {
554- MakeWeak ();
555- }
524+ CipherBase (Environment* env, v8::Local<v8::Object> wrap, CipherKind kind);
556525
557526 private:
558527 DeleteFnPtr<EVP_CIPHER_CTX, EVP_CIPHER_CTX_free> ctx_;
@@ -582,18 +551,16 @@ class Hmac : public BaseObject {
582551 static void HmacUpdate (const v8::FunctionCallbackInfo<v8::Value>& args);
583552 static void HmacDigest (const v8::FunctionCallbackInfo<v8::Value>& args);
584553
585- Hmac (Environment* env, v8::Local<v8::Object> wrap)
586- : BaseObject(env, wrap),
587- ctx_ (nullptr ) {
588- MakeWeak ();
589- }
554+ Hmac (Environment* env, v8::Local<v8::Object> wrap);
590555
591556 private:
592557 DeleteFnPtr<HMAC_CTX, HMAC_CTX_free> ctx_;
593558};
594559
595- class Hash : public BaseObject {
560+ class Hash final : public BaseObject {
596561 public:
562+ ~Hash () override ;
563+
597564 static void Initialize (Environment* env, v8::Local<v8::Object> target);
598565
599566 // TODO(joyeecheung): track the memory used by OpenSSL types
@@ -609,18 +576,7 @@ class Hash : public BaseObject {
609576 static void HashUpdate (const v8::FunctionCallbackInfo<v8::Value>& args);
610577 static void HashDigest (const v8::FunctionCallbackInfo<v8::Value>& args);
611578
612- Hash (Environment* env, v8::Local<v8::Object> wrap)
613- : BaseObject(env, wrap),
614- mdctx_ (nullptr ),
615- has_md_(false ),
616- md_value_(nullptr ) {
617- MakeWeak ();
618- }
619-
620- ~Hash () override {
621- if (md_value_ != nullptr )
622- OPENSSL_clear_free (md_value_, md_len_);
623- }
579+ Hash (Environment* env, v8::Local<v8::Object> wrap);
624580
625581 private:
626582 EVPMDPointer mdctx_;
@@ -642,9 +598,7 @@ class SignBase : public BaseObject {
642598 kSignMalformedSignature
643599 } Error;
644600
645- SignBase (Environment* env, v8::Local<v8::Object> wrap)
646- : BaseObject(env, wrap) {
647- }
601+ SignBase (Environment* env, v8::Local<v8::Object> wrap);
648602
649603 Error Init (const char * sign_type);
650604 Error Update (const char * data, int len);
@@ -690,9 +644,7 @@ class Sign : public SignBase {
690644 static void SignUpdate (const v8::FunctionCallbackInfo<v8::Value>& args);
691645 static void SignFinal (const v8::FunctionCallbackInfo<v8::Value>& args);
692646
693- Sign (Environment* env, v8::Local<v8::Object> wrap) : SignBase(env, wrap) {
694- MakeWeak ();
695- }
647+ Sign (Environment* env, v8::Local<v8::Object> wrap);
696648};
697649
698650class Verify : public SignBase {
@@ -712,9 +664,7 @@ class Verify : public SignBase {
712664 static void VerifyUpdate (const v8::FunctionCallbackInfo<v8::Value>& args);
713665 static void VerifyFinal (const v8::FunctionCallbackInfo<v8::Value>& args);
714666
715- Verify (Environment* env, v8::Local<v8::Object> wrap) : SignBase(env, wrap) {
716- MakeWeak ();
717- }
667+ Verify (Environment* env, v8::Local<v8::Object> wrap);
718668};
719669
720670class PublicKeyCipher {
@@ -771,11 +721,7 @@ class DiffieHellman : public BaseObject {
771721 static void VerifyErrorGetter (
772722 const v8::FunctionCallbackInfo<v8::Value>& args);
773723
774- DiffieHellman (Environment* env, v8::Local<v8::Object> wrap)
775- : BaseObject(env, wrap),
776- verifyError_ (0 ) {
777- MakeWeak ();
778- }
724+ DiffieHellman (Environment* env, v8::Local<v8::Object> wrap);
779725
780726 // TODO(joyeecheung): track the memory used by OpenSSL types
781727 SET_NO_MEMORY_INFO ()
@@ -794,11 +740,9 @@ class DiffieHellman : public BaseObject {
794740 DHPointer dh_;
795741};
796742
797- class ECDH : public BaseObject {
743+ class ECDH final : public BaseObject {
798744 public:
799- ~ECDH () override {
800- group_ = nullptr ;
801- }
745+ ~ECDH () override ;
802746
803747 static void Initialize (Environment* env, v8::Local<v8::Object> target);
804748 static ECPointPointer BufferToPoint (Environment* env,
@@ -811,13 +755,7 @@ class ECDH : public BaseObject {
811755 SET_SELF_SIZE (ECDH)
812756
813757 protected:
814- ECDH (Environment* env, v8::Local<v8::Object> wrap, ECKeyPointer&& key)
815- : BaseObject(env, wrap),
816- key_ (std::move(key)),
817- group_(EC_KEY_get0_group(key_.get())) {
818- MakeWeak ();
819- CHECK_NOT_NULL (group_);
820- }
758+ ECDH (Environment* env, v8::Local<v8::Object> wrap, ECKeyPointer&& key);
821759
822760 static void New (const v8::FunctionCallbackInfo<v8::Value>& args);
823761 static void GenerateKeys (const v8::FunctionCallbackInfo<v8::Value>& args);
0 commit comments