diff --git a/src/node_crypto_bio.cc b/src/node_crypto_bio.cc index a862573c280acb..ba19eb6ef2385a 100644 --- a/src/node_crypto_bio.cc +++ b/src/node_crypto_bio.cc @@ -6,6 +6,7 @@ #include namespace node { +namespace crypto { const BIO_METHOD NodeBIO::method = { BIO_TYPE_MEM, @@ -467,4 +468,5 @@ NodeBIO::~NodeBIO() { write_head_ = nullptr; } +} // namespace crypto } // namespace node diff --git a/src/node_crypto_bio.h b/src/node_crypto_bio.h index ed6b46b53237cf..fd70fcc546178f 100644 --- a/src/node_crypto_bio.h +++ b/src/node_crypto_bio.h @@ -11,6 +11,7 @@ #include "v8.h" namespace node { +namespace crypto { class NodeBIO { public: @@ -135,6 +136,7 @@ class NodeBIO { Buffer* write_head_; }; +} // namespace crypto } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS diff --git a/src/node_crypto_clienthello-inl.h b/src/node_crypto_clienthello-inl.h index 108383bf2d542a..0bb668de7a97f1 100644 --- a/src/node_crypto_clienthello-inl.h +++ b/src/node_crypto_clienthello-inl.h @@ -7,6 +7,7 @@ #include "util-inl.h" namespace node { +namespace crypto { inline void ClientHelloParser::Reset() { frame_len_ = 0; @@ -53,6 +54,7 @@ inline bool ClientHelloParser::IsPaused() const { return state_ == kPaused; } +} // namespace crypto } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS diff --git a/src/node_crypto_clienthello.cc b/src/node_crypto_clienthello.cc index 365e61c4f73647..93f0c1de05aebb 100644 --- a/src/node_crypto_clienthello.cc +++ b/src/node_crypto_clienthello.cc @@ -2,6 +2,7 @@ #include "node_crypto_clienthello-inl.h" namespace node { +namespace crypto { void ClientHelloParser::Parse(const uint8_t* data, size_t avail) { switch (state_) { @@ -223,4 +224,5 @@ bool ClientHelloParser::ParseTLSClientHello(const uint8_t* data, size_t avail) { return true; } +} // namespace crypto } // namespace node diff --git a/src/node_crypto_clienthello.h b/src/node_crypto_clienthello.h index 3550807c20d05f..0b0c8b1712c3ee 100644 --- a/src/node_crypto_clienthello.h +++ b/src/node_crypto_clienthello.h @@ -9,6 +9,7 @@ #include // nullptr namespace node { +namespace crypto { class ClientHelloParser { public: @@ -112,6 +113,7 @@ class ClientHelloParser { const uint8_t* tls_ticket_; }; +} // namespace crypto } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 8eab962a66f61c..78ba7126dfebb0 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -117,10 +117,10 @@ void TLSWrap::NewSessionDoneCb() { void TLSWrap::InitSSL() { // Initialize SSL - enc_in_ = NodeBIO::New(); - enc_out_ = NodeBIO::New(); - NodeBIO::FromBIO(enc_in_)->AssignEnvironment(env()); - NodeBIO::FromBIO(enc_out_)->AssignEnvironment(env()); + enc_in_ = crypto::NodeBIO::New(); + enc_out_ = crypto::NodeBIO::New(); + crypto::NodeBIO::FromBIO(enc_in_)->AssignEnvironment(env()); + crypto::NodeBIO::FromBIO(enc_out_)->AssignEnvironment(env()); SSL_set_bio(ssl_, enc_in_, enc_out_); @@ -149,7 +149,7 @@ void TLSWrap::InitSSL() { SSL_set_accept_state(ssl_); } else if (is_client()) { // Enough space for server response (hello, cert) - NodeBIO::FromBIO(enc_in_)->set_initial(kInitialClientBufferLength); + crypto::NodeBIO::FromBIO(enc_in_)->set_initial(kInitialClientBufferLength); SSL_set_connect_state(ssl_); } else { // Unexpected @@ -157,7 +157,7 @@ void TLSWrap::InitSSL() { } // Initialize ring for queud clear data - clear_in_ = new NodeBIO(); + clear_in_ = new crypto::NodeBIO(); clear_in_->AssignEnvironment(env()); } @@ -289,7 +289,9 @@ void TLSWrap::EncOut() { char* data[kSimultaneousBufferCount]; size_t size[arraysize(data)]; size_t count = arraysize(data); - write_size_ = NodeBIO::FromBIO(enc_out_)->PeekMultiple(data, size, &count); + write_size_ = crypto::NodeBIO::FromBIO(enc_out_)->PeekMultiple(data, + size, + &count); CHECK(write_size_ != 0 && count != 0); Local req_wrap_obj = @@ -335,7 +337,7 @@ void TLSWrap::EncOutCb(WriteWrap* req_wrap, int status) { } // Commit - NodeBIO::FromBIO(wrap->enc_out_)->Read(nullptr, wrap->write_size_); + crypto::NodeBIO::FromBIO(wrap->enc_out_)->Read(nullptr, wrap->write_size_); // Ensure that the progress will be made and `InvokeQueued` will be called. wrap->ClearIn(); @@ -653,7 +655,7 @@ void TLSWrap::OnAllocImpl(size_t suggested_size, uv_buf_t* buf, void* ctx) { } size_t size = 0; - buf->base = NodeBIO::FromBIO(wrap->enc_in_)->PeekWritable(&size); + buf->base = crypto::NodeBIO::FromBIO(wrap->enc_in_)->PeekWritable(&size); buf->len = size; } @@ -717,7 +719,7 @@ void TLSWrap::DoRead(ssize_t nread, } // Commit read data - NodeBIO* enc_in = NodeBIO::FromBIO(enc_in_); + crypto::NodeBIO* enc_in = crypto::NodeBIO::FromBIO(enc_in_); enc_in->Commit(nread); // Parse ClientHello first @@ -788,7 +790,7 @@ void TLSWrap::EnableSessionCallbacks( "EnableSessionCallbacks after destroySSL"); } wrap->enable_session_callbacks(); - NodeBIO::FromBIO(wrap->enc_in_)->set_initial(kMaxHelloLength); + crypto::NodeBIO::FromBIO(wrap->enc_in_)->set_initial(kMaxHelloLength); wrap->hello_parser_.Start(SSLWrap::OnClientHello, OnClientHelloParseEnd, wrap); diff --git a/src/tls_wrap.h b/src/tls_wrap.h index fbf664edd530c0..95d26bb91734e3 100644 --- a/src/tls_wrap.h +++ b/src/tls_wrap.h @@ -17,10 +17,10 @@ namespace node { // Forward-declarations -class NodeBIO; class WriteWrap; namespace crypto { class SecureContext; +class NodeBIO; } class TLSWrap : public AsyncWrap, @@ -151,7 +151,7 @@ class TLSWrap : public AsyncWrap, StreamBase* stream_; BIO* enc_in_; BIO* enc_out_; - NodeBIO* clear_in_; + crypto::NodeBIO* clear_in_; size_t write_size_; typedef ListHead WriteItemList; WriteItemList write_item_queue_;