summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFedor Indutny <fedor.indutny@gmail.com>2013-04-08 18:00:18 +0400
committerFedor Indutny <fedor.indutny@gmail.com>2013-04-08 19:45:35 +0400
commit037bcac7ba0b10dac87538e2e6b7cc2177624039 (patch)
tree717793fc87ed0c4f18bad05d90a2bcfeffa1c4d0 /src
parentccabd4a6fa8a6eb79d29bc3bbe9fe2b6531c2d8e (diff)
downloadnode-037bcac7ba0b10dac87538e2e6b7cc2177624039.tar.gz
crypto: dh secret should be left-padded
DH_compute_secret() may return key that is smaller than input buffer, in such cases key should be left-padded because it is a BN (big number). fix #5239
Diffstat (limited to 'src')
-rw-r--r--src/node_crypto.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index eb7e5546c..1b9c7b6b5 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -3586,7 +3586,8 @@ class DiffieHellman : public ObjectWrap {
// allocated buffer.
if (size != dataSize) {
assert(dataSize > size);
- memset(data + size, 0, dataSize - size);
+ memmove(data + dataSize - size, data, size);
+ memset(data, 0, dataSize - size);
}
Local<Value> outString;