Skip to content

Commit ef67f7c

Browse files
danbevaddaleax
authored andcommitted
src: move crypto_bio/clienthello to crypto ns
Currently, node_crypto_bio and node_crypto_clienthello are not in the crypto namespace but simply in the node namespace. Not sure if this was intentional or not, but I think it would make sense to move them to be consistent. PR-URL: #13957 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 071ecb0 commit ef67f7c

File tree

7 files changed

+25
-13
lines changed

7 files changed

+25
-13
lines changed

‎src/node_crypto_bio.cc‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include<string.h>
2828

2929
namespacenode{
30+
namespacecrypto{
3031

3132
const BIO_METHOD NodeBIO::method ={
3233
BIO_TYPE_MEM,
@@ -488,4 +489,5 @@ NodeBIO::~NodeBIO(){
488489
write_head_ = nullptr;
489490
}
490491

492+
} // namespace crypto
491493
} // namespace node

‎src/node_crypto_bio.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include"v8.h"
3333

3434
namespacenode{
35+
namespacecrypto{
3536

3637
classNodeBIO{
3738
public:
@@ -156,6 +157,7 @@ class NodeBIO{
156157
Buffer* write_head_;
157158
};
158159

160+
} // namespace crypto
159161
} // namespace node
160162

161163
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

‎src/node_crypto_clienthello-inl.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include"util-inl.h"
2929

3030
namespacenode{
31+
namespacecrypto{
3132

3233
inlinevoidClientHelloParser::Reset(){
3334
frame_len_ = 0;
@@ -74,6 +75,7 @@ inline bool ClientHelloParser::IsPaused() const{
7475
return state_ == kPaused;
7576
}
7677

78+
} // namespace crypto
7779
} // namespace node
7880

7981
#endif// defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

‎src/node_crypto_clienthello.cc‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include"node_crypto_clienthello-inl.h"
2424

2525
namespacenode{
26+
namespacecrypto{
2627

2728
voidClientHelloParser::Parse(constuint8_t* data, size_t avail){
2829
switch (state_){
@@ -244,4 +245,5 @@ bool ClientHelloParser::ParseTLSClientHello(const uint8_t* data, size_t avail){
244245
returntrue;
245246
}
246247

248+
} // namespace crypto
247249
} // namespace node

‎src/node_crypto_clienthello.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include<stdlib.h>// nullptr
3131

3232
namespacenode{
33+
namespacecrypto{
3334

3435
classClientHelloParser{
3536
public:
@@ -133,6 +134,7 @@ class ClientHelloParser{
133134
constuint8_t* tls_ticket_;
134135
};
135136

137+
} // namespace crypto
136138
} // namespace node
137139

138140
#endif// defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

‎src/tls_wrap.cc‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ void TLSWrap::NewSessionDoneCb(){
138138

139139
voidTLSWrap::InitSSL(){
140140
// Initialize SSL
141-
enc_in_ = NodeBIO::New();
142-
enc_out_ = NodeBIO::New();
143-
NodeBIO::FromBIO(enc_in_)->AssignEnvironment(env());
144-
NodeBIO::FromBIO(enc_out_)->AssignEnvironment(env());
141+
enc_in_ = crypto::NodeBIO::New();
142+
enc_out_ = crypto::NodeBIO::New();
143+
crypto::NodeBIO::FromBIO(enc_in_)->AssignEnvironment(env());
144+
crypto::NodeBIO::FromBIO(enc_out_)->AssignEnvironment(env());
145145

146146
SSL_set_bio(ssl_, enc_in_, enc_out_);
147147

@@ -170,15 +170,15 @@ void TLSWrap::InitSSL(){
170170
SSL_set_accept_state(ssl_);
171171
} elseif (is_client()){
172172
// Enough space for server response (hello, cert)
173-
NodeBIO::FromBIO(enc_in_)->set_initial(kInitialClientBufferLength);
173+
crypto::NodeBIO::FromBIO(enc_in_)->set_initial(kInitialClientBufferLength);
174174
SSL_set_connect_state(ssl_);
175175
} else{
176176
// Unexpected
177177
ABORT();
178178
}
179179

180180
// Initialize ring for queud clear data
181-
clear_in_ = newNodeBIO();
181+
clear_in_ = newcrypto::NodeBIO();
182182
clear_in_->AssignEnvironment(env());
183183
}
184184

@@ -310,7 +310,9 @@ void TLSWrap::EncOut(){
310310
char* data[kSimultaneousBufferCount];
311311
size_t size[arraysize(data)];
312312
size_t count = arraysize(data);
313-
write_size_ = NodeBIO::FromBIO(enc_out_)->PeekMultiple(data, size, &count);
313+
write_size_ = crypto::NodeBIO::FromBIO(enc_out_)->PeekMultiple(data,
314+
size,
315+
&count);
314316
CHECK(write_size_ != 0 && count != 0);
315317

316318
Local<Object> req_wrap_obj =
@@ -356,7 +358,7 @@ void TLSWrap::EncOutCb(WriteWrap* req_wrap, int status){
356358
}
357359

358360
// Commit
359-
NodeBIO::FromBIO(wrap->enc_out_)->Read(nullptr, wrap->write_size_);
361+
crypto::NodeBIO::FromBIO(wrap->enc_out_)->Read(nullptr, wrap->write_size_);
360362

361363
// Ensure that the progress will be made and `InvokeQueued` will be called.
362364
wrap->ClearIn();
@@ -674,7 +676,7 @@ void TLSWrap::OnAllocImpl(size_t suggested_size, uv_buf_t* buf, void* ctx){
674676
}
675677

676678
size_t size = 0;
677-
buf->base = NodeBIO::FromBIO(wrap->enc_in_)->PeekWritable(&size);
679+
buf->base = crypto::NodeBIO::FromBIO(wrap->enc_in_)->PeekWritable(&size);
678680
buf->len = size;
679681
}
680682

@@ -737,7 +739,7 @@ void TLSWrap::DoRead(ssize_t nread,
737739
}
738740

739741
// Commit read data
740-
NodeBIO* enc_in = NodeBIO::FromBIO(enc_in_);
742+
crypto::NodeBIO* enc_in = crypto::NodeBIO::FromBIO(enc_in_);
741743
enc_in->Commit(nread);
742744

743745
// Parse ClientHello first
@@ -808,7 +810,7 @@ void TLSWrap::EnableSessionCallbacks(
808810
"EnableSessionCallbacks after destroySSL");
809811
}
810812
wrap->enable_session_callbacks();
811-
NodeBIO::FromBIO(wrap->enc_in_)->set_initial(kMaxHelloLength);
813+
crypto::NodeBIO::FromBIO(wrap->enc_in_)->set_initial(kMaxHelloLength);
812814
wrap->hello_parser_.Start(SSLWrap<TLSWrap>::OnClientHello,
813815
OnClientHelloParseEnd,
814816
wrap);

‎src/tls_wrap.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
namespacenode{
3939

4040
// Forward-declarations
41-
classNodeBIO;
4241
classWriteWrap;
4342
namespacecrypto{
4443
classSecureContext;
44+
classNodeBIO;
4545
}
4646

4747
classTLSWrap : publicAsyncWrap,
@@ -172,7 +172,7 @@ class TLSWrap : public AsyncWrap,
172172
StreamBase* stream_;
173173
BIO* enc_in_;
174174
BIO* enc_out_;
175-
NodeBIO* clear_in_;
175+
crypto::NodeBIO* clear_in_;
176176
size_t write_size_;
177177
typedef ListHead<WriteItem, &WriteItem::member_> WriteItemList;
178178
WriteItemList write_item_queue_;

0 commit comments

Comments
(0)