summaryrefslogtreecommitdiff
path: root/src/node_crypto.h
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2017-07-10 12:56:37 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2017-07-17 23:09:34 +0200
commitd70f2470d3024c137848e4c90ff2ded26492850e (patch)
treef7a74d751aad2b84219b790e48d0eb1a1737a118 /src/node_crypto.h
parenta3b9f4b452a7dbc122713b7a5a2f550f686f1d8e (diff)
downloadandroid-node-v8-d70f2470d3024c137848e4c90ff2ded26492850e.tar.gz
android-node-v8-d70f2470d3024c137848e4c90ff2ded26492850e.tar.bz2
android-node-v8-d70f2470d3024c137848e4c90ff2ded26492850e.zip
src: remove extra heap allocations in DH functions
Replace allocate + Encode() + free patterns by calls to Malloc + the Buffer::New() overload that takes ownership of the pointer. Avoids unnecessary heap allocations and copying around of data. DRY the accessor functions for the prime, generator, public key and private key properties; deletes about 40 lines of quadruplicated code. PR-URL: https://github.com/nodejs/node/pull/14122 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_crypto.h')
-rw-r--r--src/node_crypto.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/node_crypto.h b/src/node_crypto.h
index eb5ca2b770..01c799a8b1 100644
--- a/src/node_crypto.h
+++ b/src/node_crypto.h
@@ -690,6 +690,8 @@ class DiffieHellman : public BaseObject {
}
private:
+ static void GetField(const v8::FunctionCallbackInfo<v8::Value>& args,
+ BIGNUM* (DH::*field), const char* err_if_null);
bool VerifyContext();
bool initialised_;