mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
build: export more OpenSSL symbols on Windows
PR-URL: https://github.com/nodejs/node/pull/45486 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
This commit is contained in:
parent
938341ac61
commit
3abd559c6a
3
node.gyp
3
node.gyp
@ -826,7 +826,8 @@
|
||||
'-CAES,BF,BIO,DES,DH,DSA,EC,ECDH,ECDSA,ENGINE,EVP,HMAC,MD4,MD5,'
|
||||
'PSK,RC2,RC4,RSA,SHA,SHA0,SHA1,SHA256,SHA512,SOCK,STDIO,TLSEXT,'
|
||||
'UI,FP_API,TLS1_METHOD,TLS1_1_METHOD,TLS1_2_METHOD,SCRYPT,OCSP,'
|
||||
'NEXTPROTONEG,RMD160,CAST,DEPRECATEDIN_1_1_0,DEPRECATEDIN_1_2_0',
|
||||
'NEXTPROTONEG,RMD160,CAST,DEPRECATEDIN_1_1_0,DEPRECATEDIN_1_2_0,'
|
||||
'DEPRECATEDIN_3_0',
|
||||
# Defines.
|
||||
'-DWIN32',
|
||||
# Symbols to filter from the export list.
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include <assert.h>
|
||||
#include <node.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <node.h>
|
||||
#include <assert.h>
|
||||
|
||||
namespace {
|
||||
|
||||
@ -19,6 +20,21 @@ inline void RandomBytes(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
||||
info.GetReturnValue().Set(rval > 0);
|
||||
}
|
||||
|
||||
inline void Hash(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
||||
assert(info[0]->IsArrayBufferView());
|
||||
auto view = info[0].As<v8::ArrayBufferView>();
|
||||
auto byte_offset = view->ByteOffset();
|
||||
auto len = view->ByteLength();
|
||||
assert(view->HasBuffer());
|
||||
auto buffer = view->Buffer();
|
||||
auto contents = buffer->GetBackingStore();
|
||||
auto data = static_cast<unsigned char*>(contents->Data()) + byte_offset;
|
||||
unsigned char md[MD5_DIGEST_LENGTH];
|
||||
MD5_CTX c;
|
||||
auto rval = MD5_Init(&c) && MD5_Update(&c, data, len) && MD5_Final(md, &c);
|
||||
info.GetReturnValue().Set(rval > 0);
|
||||
}
|
||||
|
||||
inline void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> module,
|
||||
v8::Local<v8::Context> context) {
|
||||
@ -32,6 +48,12 @@ inline void Initialize(v8::Local<v8::Object> exports,
|
||||
|
||||
const SSL_METHOD* method = TLSv1_2_server_method();
|
||||
assert(method != nullptr);
|
||||
|
||||
key = v8::String::NewFromUtf8(isolate, "hash").ToLocalChecked();
|
||||
value = v8::FunctionTemplate::New(isolate, Hash)
|
||||
->GetFunction(context)
|
||||
.ToLocalChecked();
|
||||
assert(exports->Set(context, key, value).IsJust());
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -9,3 +9,4 @@ const binding = require(`./build/${common.buildType}/binding`);
|
||||
const bytes = new Uint8Array(1024);
|
||||
assert(binding.randomBytes(bytes));
|
||||
assert(bytes.reduce((v, a) => v + a) > 0);
|
||||
assert(binding.hash(bytes));
|
||||
|
Loading…
Reference in New Issue
Block a user