Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
crypto: add openssl_1_1_0f implementation
  • Loading branch information
danbev committed Jun 13, 2017
commit 39fac636d3df7d12373807672ef5b8e9d560907a
7 changes: 6 additions & 1 deletion node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -654,14 +654,19 @@
'test/cctest/test_util.cc',
'test/cctest/test_url.cc',
'test/cctest/test_crypto_factory.cc',
'test/cctest/test_crypto_openssl_1_0_2e.cc',
],

'sources!': [
'src/node_main.cc'
],

'conditions': [
[ 'node_crypto_version=="openssl_1_0_2e"', {
'sources+': ['test/cctest/test_openssl_1_0_2e.cc'],
}],
[ 'node_crypto_version=="openssl_1_1_0f"', {
'sources+': ['test/cctest/test_openssl_1_1_0f.cc'],
}],
['v8_enable_inspector==1', {
'sources': [
'test/cctest/test_inspector_socket.cc',
Expand Down
7 changes: 6 additions & 1 deletion node.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
'src/node_crypto_factory.h',
'src/node_crypto_factory.cc',
'src/crypto_impl/openssl.h',
'src/crypto_impl/openssl_1_0_2e.cc',
'src/crypto_impl/node_crypto.cc',
'src/crypto_impl/node_crypto_bio.cc',
'src/crypto_impl/node_crypto_clienthello.cc',
Expand All @@ -113,6 +112,12 @@
'src/crypto_impl/tls_wrap.h'
],
'conditions': [
[ 'node_crypto_version=="openssl_1_0_2e"', {
'sources+': ['src/crypto_impl/openssl_1_0_2e.cc'],
}],
[ 'node_crypto_version=="openssl_1_1_0f"', {
'sources+': ['src/crypto_impl/openssl_1_1_0f.cc'],
}],
['openssl_fips != ""', {
'defines': [ 'NODE_FIPS_MODE' ],
}],
Expand Down
71 changes: 71 additions & 0 deletions src/crypto_impl/openssl_1_1_0f.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include "openssl.h"
#include "../node_crypto_factory.h"
#include "node_crypto.h"

namespace node {
namespace crypto {

constexpr char version_[] = "openssl_1_1_0f";

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

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

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

bool OpenSSL::HasSNI() {
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
return true;
#else
return false;
#endif
}

bool OpenSSL::HasNPN() {
#ifndef OPENSSL_NO_NEXTPROTONEG
return true;
#else
return false;
#endif
}

bool OpenSSL::HasALPN() {
#ifndef TLSEXT_TYPE_application_layer_protocol_negotiation
return true;
#else
return false;
#endif
}

bool OpenSSL::HasOCSP() {
#if !defined(OPENSSL_NO_TLSEXT) && defined(SSL_CTX_set_tlsext_status_cb)
return true;
#else
return false;
#endif
}

OpenSSL::OpenSSL() {
}

OpenSSL::~OpenSSL() {
}

void OpenSSL::UseExtraCaCerts(const std::string& file) {
crypto::UseExtraCaCerts(file);
}

v8::EntropySource OpenSSL::GetEntropySource() {
return crypto::EntropySource;
}

} // namespace crypto
} // namespace node
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ using node::crypto::OpenSSL;

const char version[] = "openssl_1_0_2e";

TEST(CryptFactoryTest, Version) {
TEST(OpenSSL_1_0_2e, Version) {
EXPECT_EQ(CryptoFactory::Get(version)->Version(), version);
}

TEST(CryptFactoryTest, Name) {
TEST(OpenSSL_1_0_2e, Name) {
EXPECT_EQ(CryptoFactory::Get(version)->Name(), "openssl");
}

TEST(CryptFactoryTest, HasSNI) {
TEST(OpenSSL_1_0_2e, HasSNI) {
EXPECT_TRUE(CryptoFactory::Get(version)->HasSNI());
}

TEST(CryptFactoryTest, HasNPN) {
TEST(OpenSSL_1_0_2e, HasNPN) {
EXPECT_TRUE(CryptoFactory::Get(version)->HasNPN());
}

TEST(CryptFactoryTest, HasALPN) {
TEST(OpenSSL_1_0_2e, HasALPN) {
EXPECT_FALSE(CryptoFactory::Get(version)->HasALPN());
}

TEST(CryptFactoryTest, HasOCSP) {
TEST(OpenSSL_1_0_2e, HasOCSP) {
EXPECT_TRUE(CryptoFactory::Get(version)->HasOCSP());
}
34 changes: 34 additions & 0 deletions test/cctest/test_openssl_1_1_0f.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "gtest/gtest.h"
#include "libplatform/libplatform.h"
#include "node_crypto_factory.h"
#include "crypto_impl/openssl.h"

using node::crypto::CryptoFactory;
using node::crypto::Crypto;
using node::crypto::OpenSSL;

const char version[] = "openssl_1_1_0f";

TEST(OpenSSL_1_1_0e, Version) {
EXPECT_EQ(CryptoFactory::Get(version)->Version(), version);
}

TEST(OpenSSL_1_1_0e, Name) {
EXPECT_EQ(CryptoFactory::Get(version)->Name(), "openssl");
}

TEST(OpenSSL_1_1_0e, HasSNI) {
EXPECT_TRUE(CryptoFactory::Get(version)->HasSNI());
}

TEST(OpenSSL_1_1_0e, HasNPN) {
EXPECT_TRUE(CryptoFactory::Get(version)->HasNPN());
}

TEST(OpenSSL_1_1_0e, HasALPN) {
EXPECT_FALSE(CryptoFactory::Get(version)->HasALPN());
}

TEST(OpenSSL_1_1_0e, HasOCSP) {
EXPECT_TRUE(CryptoFactory::Get(version)->HasOCSP());
}