Skip to content

Commit

Permalink
crypto: split crypto into two implementations
Browse files Browse the repository at this point in the history
On implementation for openssl_1_0_2e and one for openssl_1_1_0f. This is
bascally copying the existing impl and updating to compile when linking
to a shared-openssl.

Building for OpenSSL 1.1.0f:

./configure --debug --shared-openssl
--shared-openssl-libpath=/Users/danielbevenius/work/security/build_1_1_0f/lib
--shared-openssl-includes=/Users/danielbevenius/work/security/build_1_1_0f/include
--crypto-version=openssl_1_1_0f && make -j8
  • Loading branch information
danbev committed Jun 13, 2017
1 parent 39fac63 commit 45677ca
Show file tree
Hide file tree
Showing 37 changed files with 9,909 additions and 43 deletions.
1 change: 0 additions & 1 deletion lib/_tls_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ exports.createSecureContext = function createSecureContext(options, context) {
// freelist.)
if (options.singleUse) {
c.singleUse = true;
c.context.setFreeListLength(0);
}

return c;
Expand Down
35 changes: 24 additions & 11 deletions node.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,35 @@
'src/node_crypto.h',
'src/node_crypto_factory.h',
'src/node_crypto_factory.cc',
'src/crypto_impl/openssl.h',
'src/crypto_impl/node_crypto.cc',
'src/crypto_impl/node_crypto_bio.cc',
'src/crypto_impl/node_crypto_clienthello.cc',
'src/crypto_impl/node_crypto.h',
'src/crypto_impl/node_crypto_bio.h',
'src/crypto_impl/node_crypto_clienthello.h',
'src/crypto_impl/tls_wrap.cc',
'src/crypto_impl/tls_wrap.h'
],
'conditions': [
[ 'node_crypto_version=="openssl_1_0_2e"', {
'sources+': ['src/crypto_impl/openssl_1_0_2e.cc'],
'sources+': [
'src/crypto_impl/openssl/1_0_2e/node_crypto.cc',
'src/crypto_impl/openssl/1_0_2e/node_crypto_bio.cc',
'src/crypto_impl/openssl/1_0_2e/node_crypto_clienthello.cc',
'src/crypto_impl/openssl/1_0_2e/node_crypto.h',
'src/crypto_impl/openssl/1_0_2e/node_crypto_bio.h',
'src/crypto_impl/openssl/1_0_2e/node_crypto_clienthello.h',
'src/crypto_impl/openssl/1_0_2e/tls_wrap.cc',
'src/crypto_impl/openssl/1_0_2e/tls_wrap.h',
'src/crypto_impl/openssl/openssl.h',
'src/crypto_impl/openssl/1_0_2e/openssl_1_0_2e.cc',
],
}],
[ 'node_crypto_version=="openssl_1_1_0f"', {
'sources+': ['src/crypto_impl/openssl_1_1_0f.cc'],
'sources+': [
'src/crypto_impl/openssl/1_1_0f/node_crypto.cc',
'src/crypto_impl/openssl/1_1_0f/node_crypto_bio.cc',
'src/crypto_impl/openssl/1_1_0f/node_crypto_clienthello.cc',
'src/crypto_impl/openssl/1_1_0f/node_crypto.h',
'src/crypto_impl/openssl/1_1_0f/node_crypto_bio.h',
'src/crypto_impl/openssl/1_1_0f/node_crypto_clienthello.h',
'src/crypto_impl/openssl/1_1_0f/tls_wrap.cc',
'src/crypto_impl/openssl/1_1_0f/tls_wrap.h',
'src/crypto_impl/openssl/openssl.h',
'src/crypto_impl/openssl/1_1_0f/openssl_1_1_0f.cc',
],
}],
['openssl_fips != ""', {
'defines': [ 'NODE_FIPS_MODE' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1175,8 +1175,9 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo<Value>& args) {

THROW_AND_RETURN_IF_NOT_BUFFER(args[0], "Ticket keys");

if (Buffer::Length(args[0]) != 48) {
return env->ThrowTypeError("Ticket keys length must be 48 bytes");
long length = SSL_CTX_get_tlsext_ticket_keys(wrap->ctx_, NULL, 0);
if (Buffer::Length(args[0]) != (size_t)length) {
return env->ThrowTypeError("Ticket keys length incorrect");
}

if (SSL_CTX_set_tlsext_ticket_keys(wrap->ctx_,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
#include "openssl.h"
#include "../node_crypto_factory.h"
#include "../openssl.h"
#include "../../../node_crypto_factory.h"
#include "node_crypto.h"
#include <string.h>

namespace node {
namespace crypto {

constexpr char version_[] = "openssl_1_0_2e";
constexpr char version_[] = "1.0.2e";
constexpr char typeversion_[] = "openssl_1_0_2e";

const std::string OpenSSL::Version() {
return version_;
}

void Crypto::RegisterCrypto() {
CryptoFactory::Register(version_, []() -> Crypto* {
CryptoFactory::Register(typeversion_, []() -> Crypto* {
return new OpenSSL();
});
}

void Crypto::UnregisterCrypto() {
CryptoFactory::Unregister(version_);
CryptoFactory::Unregister(typeversion_);
}

bool OpenSSL::HasSNI() {
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 45677ca

Please sign in to comment.