summaryrefslogtreecommitdiff
path: root/src/node_crypto.h
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2014-08-27 18:01:01 +0400
committerFedor Indutny <fedor@indutny.com>2014-08-29 00:27:09 +0400
commit6e453fad87c51dc15327628aa75886d3fbb3fa1c (patch)
treea750ea46af04a3107132a3e21eb6047675a15178 /src/node_crypto.h
parentf7d6147e43b8a80a0d627f2034271239db500d9f (diff)
downloadandroid-node-v8-6e453fad87c51dc15327628aa75886d3fbb3fa1c.tar.gz
android-node-v8-6e453fad87c51dc15327628aa75886d3fbb3fa1c.tar.bz2
android-node-v8-6e453fad87c51dc15327628aa75886d3fbb3fa1c.zip
crypto: introduce ECDH
Diffstat (limited to 'src/node_crypto.h')
-rw-r--r--src/node_crypto.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/node_crypto.h b/src/node_crypto.h
index 2a02c89bc2..178afc80ea 100644
--- a/src/node_crypto.h
+++ b/src/node_crypto.h
@@ -39,6 +39,8 @@
#include "v8.h"
#include <openssl/ssl.h>
+#include <openssl/ec.h>
+#include <openssl/ecdh.h>
#ifndef OPENSSL_NO_ENGINE
# include <openssl/engine.h>
#endif // !OPENSSL_NO_ENGINE
@@ -635,6 +637,42 @@ class DiffieHellman : public BaseObject {
DH* dh;
};
+class ECDH : public BaseObject {
+ public:
+ ~ECDH() {
+ if (key_ != NULL)
+ EC_KEY_free(key_);
+ key_ = NULL;
+ group_ = NULL;
+ }
+
+ static void Initialize(Environment* env, v8::Handle<v8::Object> target);
+
+ protected:
+ ECDH(Environment* env, v8::Local<v8::Object> wrap, EC_KEY* key)
+ : BaseObject(env, wrap),
+ generated_(false),
+ key_(key),
+ group_(EC_KEY_get0_group(key_)) {
+ MakeWeak<ECDH>(this);
+ ASSERT(group_ != NULL);
+ }
+
+ static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void GenerateKeys(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void ComputeSecret(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void GetPrivateKey(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void SetPrivateKey(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void GetPublicKey(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void SetPublicKey(const v8::FunctionCallbackInfo<v8::Value>& args);
+
+ EC_POINT* BufferToPoint(char* data, size_t len);
+
+ bool generated_;
+ EC_KEY* key_;
+ const EC_GROUP* group_;
+};
+
class Certificate : public AsyncWrap {
public:
static void Initialize(Environment* env, v8::Handle<v8::Object> target);