crypto: split crypto classes
This commit is contained in:
parent
66280de133
commit
a15cc93ae3
@ -2036,9 +2036,7 @@ Handle<Value> Connection::SetSNICallback(const Arguments& args) {
|
||||
#endif
|
||||
|
||||
|
||||
class Cipher : public ObjectWrap {
|
||||
public:
|
||||
static void Initialize (v8::Handle<v8::Object> target) {
|
||||
void Cipher::Initialize(v8::Handle<v8::Object> target) {
|
||||
HandleScope scope;
|
||||
|
||||
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
||||
@ -2052,10 +2050,10 @@ class Cipher : public ObjectWrap {
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "final", CipherFinal);
|
||||
|
||||
target->Set(String::NewSymbol("Cipher"), t->GetFunction());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CipherInit(char* cipherType, char* key_buf, int key_buf_len) {
|
||||
bool Cipher:: CipherInit(char* cipherType, char* key_buf, int key_buf_len) {
|
||||
cipher = EVP_get_cipherbyname(cipherType);
|
||||
if(!cipher) {
|
||||
fprintf(stderr, "node-crypto : Unknown cipher %s\n", cipherType);
|
||||
@ -2078,10 +2076,10 @@ class Cipher : public ObjectWrap {
|
||||
(unsigned char*)iv, true);
|
||||
initialised_ = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CipherInitIv(char* cipherType,
|
||||
bool Cipher::CipherInitIv(char* cipherType,
|
||||
char* key,
|
||||
int key_len,
|
||||
char* iv,
|
||||
@ -2110,41 +2108,45 @@ class Cipher : public ObjectWrap {
|
||||
(unsigned char*)iv, true);
|
||||
initialised_ = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int CipherUpdate(char* data, int len, unsigned char** out, int* out_len) {
|
||||
|
||||
int Cipher::CipherUpdate(char* data,
|
||||
int len,
|
||||
unsigned char** out,
|
||||
int* out_len) {
|
||||
if (!initialised_) return 0;
|
||||
*out_len=len+EVP_CIPHER_CTX_block_size(&ctx);
|
||||
*out= new unsigned char[*out_len];
|
||||
return EVP_CipherUpdate(&ctx, *out, out_len, (unsigned char*)data, len);
|
||||
}
|
||||
}
|
||||
|
||||
int SetAutoPadding(bool auto_padding) {
|
||||
|
||||
int Cipher::SetAutoPadding(bool auto_padding) {
|
||||
if (!initialised_) return 0;
|
||||
return EVP_CIPHER_CTX_set_padding(&ctx, auto_padding ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
int CipherFinal(unsigned char** out, int *out_len) {
|
||||
|
||||
int Cipher::CipherFinal(unsigned char** out, int *out_len) {
|
||||
if (!initialised_) return 0;
|
||||
*out = new unsigned char[EVP_CIPHER_CTX_block_size(&ctx)];
|
||||
int r = EVP_CipherFinal_ex(&ctx,*out, out_len);
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
initialised_ = false;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
static Handle<Value> New(const Arguments& args) {
|
||||
Handle<Value> Cipher::New(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
Cipher *cipher = new Cipher();
|
||||
cipher->Wrap(args.This());
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> CipherInit(const Arguments& args) {
|
||||
Handle<Value> Cipher::CipherInit(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
Cipher *cipher = ObjectWrap::Unwrap<Cipher>(args.This());
|
||||
@ -2178,10 +2180,10 @@ class Cipher : public ObjectWrap {
|
||||
if (!r) return ThrowCryptoError(ERR_get_error());
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Handle<Value> CipherInitIv(const Arguments& args) {
|
||||
Handle<Value> Cipher::CipherInitIv(const Arguments& args) {
|
||||
Cipher *cipher = ObjectWrap::Unwrap<Cipher>(args.This());
|
||||
|
||||
HandleScope scope;
|
||||
@ -2230,9 +2232,10 @@ class Cipher : public ObjectWrap {
|
||||
if (!r) return ThrowCryptoError(ERR_get_error());
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> CipherUpdate(const Arguments& args) {
|
||||
|
||||
Handle<Value> Cipher::CipherUpdate(const Arguments& args) {
|
||||
Cipher *cipher = ObjectWrap::Unwrap<Cipher>(args.This());
|
||||
|
||||
HandleScope scope;
|
||||
@ -2257,18 +2260,20 @@ class Cipher : public ObjectWrap {
|
||||
if (out) delete [] out;
|
||||
|
||||
return scope.Close(outString);
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> SetAutoPadding(const Arguments& args) {
|
||||
|
||||
Handle<Value> Cipher::SetAutoPadding(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
Cipher *cipher = ObjectWrap::Unwrap<Cipher>(args.This());
|
||||
|
||||
cipher->SetAutoPadding(args.Length() < 1 || args[0]->BooleanValue());
|
||||
|
||||
return Undefined();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> CipherFinal(const Arguments& args) {
|
||||
|
||||
Handle<Value> Cipher::CipherFinal(const Arguments& args) {
|
||||
Cipher *cipher = ObjectWrap::Unwrap<Cipher>(args.This());
|
||||
|
||||
HandleScope scope;
|
||||
@ -2289,33 +2294,10 @@ class Cipher : public ObjectWrap {
|
||||
|
||||
delete [] out_value;
|
||||
return scope.Close(outString);
|
||||
}
|
||||
|
||||
Cipher () : ObjectWrap ()
|
||||
{
|
||||
initialised_ = false;
|
||||
}
|
||||
|
||||
~Cipher () {
|
||||
if (initialised_) {
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
EVP_CIPHER_CTX ctx; /* coverity[member_decl] */
|
||||
const EVP_CIPHER *cipher; /* coverity[member_decl] */
|
||||
bool initialised_;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
class Decipher : public ObjectWrap {
|
||||
public:
|
||||
static void
|
||||
Initialize (v8::Handle<v8::Object> target)
|
||||
{
|
||||
void Decipher::Initialize(v8::Handle<v8::Object> target) {
|
||||
HandleScope scope;
|
||||
|
||||
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
||||
@ -2330,9 +2312,10 @@ class Decipher : public ObjectWrap {
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "setAutoPadding", SetAutoPadding);
|
||||
|
||||
target->Set(String::NewSymbol("Decipher"), t->GetFunction());
|
||||
}
|
||||
}
|
||||
|
||||
bool DecipherInit(char* cipherType, char* key_buf, int key_buf_len) {
|
||||
|
||||
bool Decipher::DecipherInit(char* cipherType, char* key_buf, int key_buf_len) {
|
||||
cipher_ = EVP_get_cipherbyname(cipherType);
|
||||
|
||||
if(!cipher_) {
|
||||
@ -2362,10 +2345,10 @@ class Decipher : public ObjectWrap {
|
||||
(unsigned char*)iv, false);
|
||||
initialised_ = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool DecipherInitIv(char* cipherType,
|
||||
bool Decipher::DecipherInitIv(char* cipherType,
|
||||
char* key,
|
||||
int key_len,
|
||||
char* iv,
|
||||
@ -2394,9 +2377,13 @@ class Decipher : public ObjectWrap {
|
||||
(unsigned char*)iv, false);
|
||||
initialised_ = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int DecipherUpdate(char* data, int len, unsigned char** out, int* out_len) {
|
||||
|
||||
int Decipher::DecipherUpdate(char* data,
|
||||
int len,
|
||||
unsigned char** out,
|
||||
int* out_len) {
|
||||
if (!initialised_) {
|
||||
*out_len = 0;
|
||||
*out = NULL;
|
||||
@ -2407,15 +2394,16 @@ class Decipher : public ObjectWrap {
|
||||
*out= new unsigned char[*out_len];
|
||||
|
||||
return EVP_CipherUpdate(&ctx, *out, out_len, (unsigned char*)data, len);
|
||||
}
|
||||
}
|
||||
|
||||
int SetAutoPadding(bool auto_padding) {
|
||||
|
||||
int Decipher::SetAutoPadding(bool auto_padding) {
|
||||
if (!initialised_) return 0;
|
||||
return EVP_CIPHER_CTX_set_padding(&ctx, auto_padding ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
// coverity[alloc_arg]
|
||||
int DecipherFinal(unsigned char** out, int *out_len) {
|
||||
|
||||
int Decipher::DecipherFinal(unsigned char** out, int *out_len) {
|
||||
int r;
|
||||
|
||||
if (!initialised_) {
|
||||
@ -2429,20 +2417,19 @@ class Decipher : public ObjectWrap {
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
initialised_ = false;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
static Handle<Value> New (const Arguments& args) {
|
||||
Handle<Value> Decipher::New(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
Decipher *cipher = new Decipher();
|
||||
cipher->Wrap(args.This());
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> DecipherInit(const Arguments& args) {
|
||||
|
||||
Handle<Value> Decipher::DecipherInit(const Arguments& args) {
|
||||
Decipher *cipher = ObjectWrap::Unwrap<Decipher>(args.This());
|
||||
|
||||
HandleScope scope;
|
||||
@ -2478,9 +2465,10 @@ class Decipher : public ObjectWrap {
|
||||
}
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> DecipherInitIv(const Arguments& args) {
|
||||
|
||||
Handle<Value> Decipher::DecipherInitIv(const Arguments& args) {
|
||||
Decipher *cipher = ObjectWrap::Unwrap<Decipher>(args.This());
|
||||
|
||||
HandleScope scope;
|
||||
@ -2530,9 +2518,10 @@ class Decipher : public ObjectWrap {
|
||||
}
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> DecipherUpdate(const Arguments& args) {
|
||||
|
||||
Handle<Value> Decipher::DecipherUpdate(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
Decipher *cipher = ObjectWrap::Unwrap<Decipher>(args.This());
|
||||
@ -2567,18 +2556,20 @@ class Decipher : public ObjectWrap {
|
||||
if (alloc_buf) delete [] buf;
|
||||
return scope.Close(outString);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> SetAutoPadding(const Arguments& args) {
|
||||
|
||||
Handle<Value> Decipher::SetAutoPadding(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
Decipher *cipher = ObjectWrap::Unwrap<Decipher>(args.This());
|
||||
|
||||
cipher->SetAutoPadding(args.Length() < 1 || args[0]->BooleanValue());
|
||||
|
||||
return Undefined();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> DecipherFinal(const Arguments& args) {
|
||||
|
||||
Handle<Value> Decipher::DecipherFinal(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
Decipher *cipher = ObjectWrap::Unwrap<Decipher>(args.This());
|
||||
@ -2598,31 +2589,10 @@ class Decipher : public ObjectWrap {
|
||||
outString = Encode(out_value, out_len, BUFFER);
|
||||
delete [] out_value;
|
||||
return scope.Close(outString);
|
||||
}
|
||||
|
||||
Decipher () : ObjectWrap () {
|
||||
initialised_ = false;
|
||||
}
|
||||
|
||||
~Decipher () {
|
||||
if (initialised_) {
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
EVP_CIPHER_CTX ctx;
|
||||
const EVP_CIPHER *cipher_;
|
||||
bool initialised_;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class Hmac : public ObjectWrap {
|
||||
public:
|
||||
static void Initialize (v8::Handle<v8::Object> target) {
|
||||
void Hmac::Initialize(v8::Handle<v8::Object> target) {
|
||||
HandleScope scope;
|
||||
|
||||
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
||||
@ -2634,9 +2604,10 @@ class Hmac : public ObjectWrap {
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "digest", HmacDigest);
|
||||
|
||||
target->Set(String::NewSymbol("Hmac"), t->GetFunction());
|
||||
}
|
||||
}
|
||||
|
||||
bool HmacInit(char* hashType, char* key, int key_len) {
|
||||
|
||||
bool Hmac::HmacInit(char* hashType, char* key, int key_len) {
|
||||
md = EVP_get_digestbyname(hashType);
|
||||
if(!md) {
|
||||
fprintf(stderr, "node-crypto : Unknown message digest %s\n", hashType);
|
||||
@ -2651,35 +2622,36 @@ class Hmac : public ObjectWrap {
|
||||
initialised_ = true;
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int HmacUpdate(char* data, int len) {
|
||||
|
||||
int Hmac::HmacUpdate(char* data, int len) {
|
||||
if (!initialised_) return 0;
|
||||
HMAC_Update(&ctx, (unsigned char*)data, len);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int HmacDigest(unsigned char** md_value, unsigned int *md_len) {
|
||||
|
||||
int Hmac::HmacDigest(unsigned char** md_value, unsigned int *md_len) {
|
||||
if (!initialised_) return 0;
|
||||
*md_value = new unsigned char[EVP_MAX_MD_SIZE];
|
||||
HMAC_Final(&ctx, *md_value, md_len);
|
||||
HMAC_CTX_cleanup(&ctx);
|
||||
initialised_ = false;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
static Handle<Value> New (const Arguments& args) {
|
||||
Handle<Value> Hmac::New(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
Hmac *hmac = new Hmac();
|
||||
hmac->Wrap(args.This());
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> HmacInit(const Arguments& args) {
|
||||
|
||||
Handle<Value> Hmac::HmacInit(const Arguments& args) {
|
||||
Hmac *hmac = ObjectWrap::Unwrap<Hmac>(args.This());
|
||||
|
||||
HandleScope scope;
|
||||
@ -2721,9 +2693,10 @@ class Hmac : public ObjectWrap {
|
||||
}
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> HmacUpdate(const Arguments& args) {
|
||||
|
||||
Handle<Value> Hmac::HmacUpdate(const Arguments& args) {
|
||||
Hmac *hmac = ObjectWrap::Unwrap<Hmac>(args.This());
|
||||
|
||||
HandleScope scope;
|
||||
@ -2743,9 +2716,10 @@ class Hmac : public ObjectWrap {
|
||||
}
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> HmacDigest(const Arguments& args) {
|
||||
|
||||
Handle<Value> Hmac::HmacDigest(const Arguments& args) {
|
||||
Hmac *hmac = ObjectWrap::Unwrap<Hmac>(args.This());
|
||||
|
||||
HandleScope scope;
|
||||
@ -2764,29 +2738,10 @@ class Hmac : public ObjectWrap {
|
||||
|
||||
delete [] md_value;
|
||||
return scope.Close(outString);
|
||||
}
|
||||
|
||||
Hmac () : ObjectWrap () {
|
||||
initialised_ = false;
|
||||
}
|
||||
|
||||
~Hmac () {
|
||||
if (initialised_) {
|
||||
HMAC_CTX_cleanup(&ctx);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
HMAC_CTX ctx; /* coverity[member_decl] */
|
||||
const EVP_MD *md; /* coverity[member_decl] */
|
||||
bool initialised_;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
class Hash : public ObjectWrap {
|
||||
public:
|
||||
static void Initialize (v8::Handle<v8::Object> target) {
|
||||
void Hash::Initialize(v8::Handle<v8::Object> target) {
|
||||
HandleScope scope;
|
||||
|
||||
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
||||
@ -2797,27 +2752,27 @@ class Hash : public ObjectWrap {
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "digest", HashDigest);
|
||||
|
||||
target->Set(String::NewSymbol("Hash"), t->GetFunction());
|
||||
}
|
||||
}
|
||||
|
||||
bool HashInit (const char* hashType) {
|
||||
|
||||
bool Hash::HashInit(const char* hashType) {
|
||||
md = EVP_get_digestbyname(hashType);
|
||||
if(!md) return false;
|
||||
EVP_MD_CTX_init(&mdctx);
|
||||
EVP_DigestInit_ex(&mdctx, md, NULL);
|
||||
initialised_ = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int HashUpdate(char* data, int len) {
|
||||
|
||||
int Hash::HashUpdate(char* data, int len) {
|
||||
if (!initialised_) return 0;
|
||||
EVP_DigestUpdate(&mdctx, data, len);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
static Handle<Value> New (const Arguments& args) {
|
||||
Handle<Value> Hash::New(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
if (args.Length() == 0 || !args[0]->IsString()) {
|
||||
@ -2836,9 +2791,10 @@ class Hash : public ObjectWrap {
|
||||
|
||||
hash->Wrap(args.This());
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> HashUpdate(const Arguments& args) {
|
||||
|
||||
Handle<Value> Hash::HashUpdate(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
Hash *hash = ObjectWrap::Unwrap<Hash>(args.This());
|
||||
@ -2857,9 +2813,10 @@ class Hash : public ObjectWrap {
|
||||
}
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> HashDigest(const Arguments& args) {
|
||||
|
||||
Handle<Value> Hash::HashDigest(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
Hash *hash = ObjectWrap::Unwrap<Hash>(args.This());
|
||||
@ -2880,29 +2837,10 @@ class Hash : public ObjectWrap {
|
||||
outString = Encode(md_value, md_len, BUFFER);
|
||||
|
||||
return scope.Close(outString);
|
||||
}
|
||||
}
|
||||
|
||||
Hash () : ObjectWrap () {
|
||||
initialised_ = false;
|
||||
}
|
||||
|
||||
~Hash () {
|
||||
if (initialised_) {
|
||||
EVP_MD_CTX_cleanup(&mdctx);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
EVP_MD_CTX mdctx; /* coverity[member_decl] */
|
||||
const EVP_MD *md; /* coverity[member_decl] */
|
||||
bool initialised_;
|
||||
};
|
||||
|
||||
class Sign : public ObjectWrap {
|
||||
public:
|
||||
static void
|
||||
Initialize (v8::Handle<v8::Object> target) {
|
||||
void Sign::Initialize(v8::Handle<v8::Object> target) {
|
||||
HandleScope scope;
|
||||
|
||||
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
||||
@ -2914,9 +2852,10 @@ class Sign : public ObjectWrap {
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "sign", SignFinal);
|
||||
|
||||
target->Set(String::NewSymbol("Sign"), t->GetFunction());
|
||||
}
|
||||
}
|
||||
|
||||
bool SignInit (const char* signType) {
|
||||
|
||||
bool Sign::SignInit(const char* signType) {
|
||||
md = EVP_get_digestbyname(signType);
|
||||
if(!md) {
|
||||
printf("Unknown message digest %s\n", signType);
|
||||
@ -2927,15 +2866,17 @@ class Sign : public ObjectWrap {
|
||||
initialised_ = true;
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int SignUpdate(char* data, int len) {
|
||||
|
||||
int Sign::SignUpdate(char* data, int len) {
|
||||
if (!initialised_) return 0;
|
||||
EVP_SignUpdate(&mdctx, data, len);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int SignFinal(unsigned char** md_value,
|
||||
|
||||
int Sign::SignFinal(unsigned char** md_value,
|
||||
unsigned int *md_len,
|
||||
char* key_pem,
|
||||
int key_pemLen) {
|
||||
@ -2955,21 +2896,20 @@ class Sign : public ObjectWrap {
|
||||
EVP_PKEY_free(pkey);
|
||||
BIO_free(bp);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
static Handle<Value> New (const Arguments& args) {
|
||||
Handle<Value> Sign::New(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
Sign *sign = new Sign();
|
||||
sign->Wrap(args.This());
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> SignInit(const Arguments& args) {
|
||||
|
||||
Handle<Value> Sign::SignInit(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
Sign *sign = ObjectWrap::Unwrap<Sign>(args.This());
|
||||
@ -2988,9 +2928,10 @@ class Sign : public ObjectWrap {
|
||||
}
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> SignUpdate(const Arguments& args) {
|
||||
|
||||
Handle<Value> Sign::SignUpdate(const Arguments& args) {
|
||||
Sign *sign = ObjectWrap::Unwrap<Sign>(args.This());
|
||||
|
||||
HandleScope scope;
|
||||
@ -3010,9 +2951,10 @@ class Sign : public ObjectWrap {
|
||||
}
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> SignFinal(const Arguments& args) {
|
||||
|
||||
Handle<Value> Sign::SignFinal(const Arguments& args) {
|
||||
Sign *sign = ObjectWrap::Unwrap<Sign>(args.This());
|
||||
|
||||
HandleScope scope;
|
||||
@ -3043,28 +2985,10 @@ class Sign : public ObjectWrap {
|
||||
|
||||
delete [] md_value;
|
||||
return scope.Close(outString);
|
||||
}
|
||||
}
|
||||
|
||||
Sign () : ObjectWrap () {
|
||||
initialised_ = false;
|
||||
}
|
||||
|
||||
~Sign () {
|
||||
if (initialised_) {
|
||||
EVP_MD_CTX_cleanup(&mdctx);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
EVP_MD_CTX mdctx; /* coverity[member_decl] */
|
||||
const EVP_MD *md; /* coverity[member_decl] */
|
||||
bool initialised_;
|
||||
};
|
||||
|
||||
class Verify : public ObjectWrap {
|
||||
public:
|
||||
static void Initialize (v8::Handle<v8::Object> target) {
|
||||
void Verify::Initialize(v8::Handle<v8::Object> target) {
|
||||
HandleScope scope;
|
||||
|
||||
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
||||
@ -3076,10 +3000,10 @@ class Verify : public ObjectWrap {
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "verify", VerifyFinal);
|
||||
|
||||
target->Set(String::NewSymbol("Verify"), t->GetFunction());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool VerifyInit (const char* verifyType) {
|
||||
bool Verify::VerifyInit(const char* verifyType) {
|
||||
md = EVP_get_digestbyname(verifyType);
|
||||
if(!md) {
|
||||
fprintf(stderr, "node-crypto : Unknown message digest %s\n", verifyType);
|
||||
@ -3089,17 +3013,20 @@ class Verify : public ObjectWrap {
|
||||
EVP_VerifyInit_ex(&mdctx, md, NULL);
|
||||
initialised_ = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int VerifyUpdate(char* data, int len) {
|
||||
int Verify::VerifyUpdate(char* data, int len) {
|
||||
if (!initialised_) return 0;
|
||||
EVP_VerifyUpdate(&mdctx, data, len);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int VerifyFinal(char* key_pem, int key_pemLen, unsigned char* sig, int siglen) {
|
||||
int Verify::VerifyFinal(char* key_pem,
|
||||
int key_pemLen,
|
||||
unsigned char* sig,
|
||||
int siglen) {
|
||||
if (!initialised_) return 0;
|
||||
|
||||
EVP_PKEY* pkey = NULL;
|
||||
@ -3164,22 +3091,20 @@ class Verify : public ObjectWrap {
|
||||
initialised_ = false;
|
||||
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
static Handle<Value> New (const Arguments& args) {
|
||||
Handle<Value> Verify::New(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
Verify *verify = new Verify();
|
||||
verify->Wrap(args.This());
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Handle<Value> VerifyInit(const Arguments& args) {
|
||||
Handle<Value> Verify::VerifyInit(const Arguments& args) {
|
||||
Verify *verify = ObjectWrap::Unwrap<Verify>(args.This());
|
||||
|
||||
HandleScope scope;
|
||||
@ -3198,10 +3123,10 @@ class Verify : public ObjectWrap {
|
||||
}
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Handle<Value> VerifyUpdate(const Arguments& args) {
|
||||
Handle<Value> Verify::VerifyUpdate(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
Verify *verify = ObjectWrap::Unwrap<Verify>(args.This());
|
||||
@ -3221,10 +3146,10 @@ class Verify : public ObjectWrap {
|
||||
}
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Handle<Value> VerifyFinal(const Arguments& args) {
|
||||
Handle<Value> Verify::VerifyFinal(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
Verify *verify = ObjectWrap::Unwrap<Verify>(args.This());
|
||||
@ -3262,29 +3187,10 @@ class Verify : public ObjectWrap {
|
||||
delete [] hbuf;
|
||||
|
||||
return Boolean::New(r && r != -1);
|
||||
}
|
||||
}
|
||||
|
||||
Verify () : ObjectWrap () {
|
||||
initialised_ = false;
|
||||
}
|
||||
|
||||
~Verify () {
|
||||
if (initialised_) {
|
||||
EVP_MD_CTX_cleanup(&mdctx);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
EVP_MD_CTX mdctx; /* coverity[member_decl] */
|
||||
const EVP_MD *md; /* coverity[member_decl] */
|
||||
bool initialised_;
|
||||
|
||||
};
|
||||
|
||||
class DiffieHellman : public ObjectWrap {
|
||||
public:
|
||||
static void Initialize(v8::Handle<v8::Object> target) {
|
||||
void DiffieHellman::Initialize(v8::Handle<v8::Object> target) {
|
||||
HandleScope scope;
|
||||
|
||||
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
||||
@ -3313,18 +3219,20 @@ class DiffieHellman : public ObjectWrap {
|
||||
NODE_SET_PROTOTYPE_METHOD(t2, "getPrivateKey", GetPrivateKey);
|
||||
|
||||
target->Set(String::NewSymbol("DiffieHellmanGroup"), t2->GetFunction());
|
||||
}
|
||||
}
|
||||
|
||||
bool Init(int primeLength) {
|
||||
|
||||
bool DiffieHellman::Init(int primeLength) {
|
||||
dh = DH_new();
|
||||
DH_generate_parameters_ex(dh, primeLength, DH_GENERATOR_2, 0);
|
||||
bool result = VerifyContext();
|
||||
if (!result) return false;
|
||||
initialised_ = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool Init(unsigned char* p, int p_len) {
|
||||
|
||||
bool DiffieHellman::Init(unsigned char* p, int p_len) {
|
||||
dh = DH_new();
|
||||
dh->p = BN_bin2bn(p, p_len, 0);
|
||||
dh->g = BN_new();
|
||||
@ -3333,18 +3241,22 @@ class DiffieHellman : public ObjectWrap {
|
||||
if (!result) return false;
|
||||
initialised_ = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool Init(unsigned char* p, int p_len, unsigned char* g, int g_len) {
|
||||
|
||||
bool DiffieHellman::Init(unsigned char* p,
|
||||
int p_len,
|
||||
unsigned char* g,
|
||||
int g_len) {
|
||||
dh = DH_new();
|
||||
dh->p = BN_bin2bn(p, p_len, 0);
|
||||
dh->g = BN_bin2bn(g, g_len, 0);
|
||||
initialised_ = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
static Handle<Value> DiffieHellmanGroup(const Arguments& args) {
|
||||
|
||||
Handle<Value> DiffieHellman::DiffieHellmanGroup(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
DiffieHellman* diffieHellman = new DiffieHellman();
|
||||
@ -3375,9 +3287,10 @@ class DiffieHellman : public ObjectWrap {
|
||||
diffieHellman->Wrap(args.This());
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> New(const Arguments& args) {
|
||||
|
||||
Handle<Value> DiffieHellman::New(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
DiffieHellman* diffieHellman = new DiffieHellman();
|
||||
@ -3401,9 +3314,10 @@ class DiffieHellman : public ObjectWrap {
|
||||
diffieHellman->Wrap(args.This());
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> GenerateKeys(const Arguments& args) {
|
||||
|
||||
Handle<Value> DiffieHellman::GenerateKeys(const Arguments& args) {
|
||||
DiffieHellman* diffieHellman =
|
||||
ObjectWrap::Unwrap<DiffieHellman>(args.This());
|
||||
|
||||
@ -3430,9 +3344,10 @@ class DiffieHellman : public ObjectWrap {
|
||||
delete[] data;
|
||||
|
||||
return scope.Close(outString);
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> GetPrime(const Arguments& args) {
|
||||
|
||||
Handle<Value> DiffieHellman::GetPrime(const Arguments& args) {
|
||||
DiffieHellman* diffieHellman =
|
||||
ObjectWrap::Unwrap<DiffieHellman>(args.This());
|
||||
|
||||
@ -3453,9 +3368,10 @@ class DiffieHellman : public ObjectWrap {
|
||||
delete[] data;
|
||||
|
||||
return scope.Close(outString);
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> GetGenerator(const Arguments& args) {
|
||||
|
||||
Handle<Value> DiffieHellman::GetGenerator(const Arguments& args) {
|
||||
DiffieHellman* diffieHellman =
|
||||
ObjectWrap::Unwrap<DiffieHellman>(args.This());
|
||||
|
||||
@ -3476,9 +3392,10 @@ class DiffieHellman : public ObjectWrap {
|
||||
delete[] data;
|
||||
|
||||
return scope.Close(outString);
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> GetPublicKey(const Arguments& args) {
|
||||
|
||||
Handle<Value> DiffieHellman::GetPublicKey(const Arguments& args) {
|
||||
DiffieHellman* diffieHellman =
|
||||
ObjectWrap::Unwrap<DiffieHellman>(args.This());
|
||||
|
||||
@ -3505,9 +3422,10 @@ class DiffieHellman : public ObjectWrap {
|
||||
delete[] data;
|
||||
|
||||
return scope.Close(outString);
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> GetPrivateKey(const Arguments& args) {
|
||||
|
||||
Handle<Value> DiffieHellman::GetPrivateKey(const Arguments& args) {
|
||||
DiffieHellman* diffieHellman =
|
||||
ObjectWrap::Unwrap<DiffieHellman>(args.This());
|
||||
|
||||
@ -3534,9 +3452,10 @@ class DiffieHellman : public ObjectWrap {
|
||||
delete[] data;
|
||||
|
||||
return scope.Close(outString);
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> ComputeSecret(const Arguments& args) {
|
||||
|
||||
Handle<Value> DiffieHellman::ComputeSecret(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
DiffieHellman* diffieHellman =
|
||||
@ -3607,9 +3526,10 @@ class DiffieHellman : public ObjectWrap {
|
||||
|
||||
delete[] data;
|
||||
return scope.Close(outString);
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> SetPublicKey(const Arguments& args) {
|
||||
|
||||
Handle<Value> DiffieHellman::SetPublicKey(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
DiffieHellman* diffieHellman =
|
||||
@ -3631,9 +3551,10 @@ class DiffieHellman : public ObjectWrap {
|
||||
}
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Value> SetPrivateKey(const Arguments& args) {
|
||||
|
||||
Handle<Value> DiffieHellman::SetPrivateKey(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
DiffieHellman* diffieHellman =
|
||||
@ -3656,21 +3577,10 @@ class DiffieHellman : public ObjectWrap {
|
||||
}
|
||||
|
||||
return args.This();
|
||||
}
|
||||
}
|
||||
|
||||
DiffieHellman() : ObjectWrap() {
|
||||
initialised_ = false;
|
||||
dh = NULL;
|
||||
}
|
||||
|
||||
~DiffieHellman() {
|
||||
if (dh != NULL) {
|
||||
DH_free(dh);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool VerifyContext() {
|
||||
bool DiffieHellman::VerifyContext() {
|
||||
int codes;
|
||||
if (!DH_check(dh, &codes)) return false;
|
||||
if (codes & DH_CHECK_P_NOT_SAFE_PRIME) return false;
|
||||
@ -3678,11 +3588,7 @@ class DiffieHellman : public ObjectWrap {
|
||||
if (codes & DH_UNABLE_TO_CHECK_GENERATOR) return false;
|
||||
if (codes & DH_NOT_SUITABLE_GENERATOR) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initialised_;
|
||||
DH* dh;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
struct pbkdf2_req {
|
||||
|
@ -276,6 +276,238 @@ class Connection : ObjectWrap {
|
||||
friend class SecureContext;
|
||||
};
|
||||
|
||||
class Cipher : public ObjectWrap {
|
||||
public:
|
||||
static void Initialize (v8::Handle<v8::Object> target);
|
||||
|
||||
bool CipherInit(char* cipherType, char* key_buf, int key_buf_len);
|
||||
bool CipherInitIv(char* cipherType,
|
||||
char* key,
|
||||
int key_len,
|
||||
char* iv,
|
||||
int iv_len);
|
||||
int CipherUpdate(char* data, int len, unsigned char** out, int* out_len);
|
||||
int SetAutoPadding(bool auto_padding);
|
||||
int CipherFinal(unsigned char** out, int *out_len);
|
||||
|
||||
protected:
|
||||
static v8::Handle<v8::Value> New(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> CipherInit(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> CipherInitIv(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> CipherUpdate(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> SetAutoPadding(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> CipherFinal(const v8::Arguments& args);
|
||||
|
||||
Cipher() : ObjectWrap(), initialised_(false) {
|
||||
}
|
||||
|
||||
~Cipher() {
|
||||
if (initialised_) {
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
EVP_CIPHER_CTX ctx; /* coverity[member_decl] */
|
||||
const EVP_CIPHER *cipher; /* coverity[member_decl] */
|
||||
bool initialised_;
|
||||
};
|
||||
|
||||
class Decipher : public ObjectWrap {
|
||||
public:
|
||||
static void Initialize(v8::Handle<v8::Object> target);
|
||||
|
||||
bool DecipherInit(char* cipherType, char* key_buf, int key_buf_len);
|
||||
bool DecipherInitIv(char* cipherType,
|
||||
char* key,
|
||||
int key_len,
|
||||
char* iv,
|
||||
int iv_len);
|
||||
int DecipherUpdate(char* data, int len, unsigned char** out, int* out_len);
|
||||
int SetAutoPadding(bool auto_padding);
|
||||
int DecipherFinal(unsigned char** out, int *out_len);
|
||||
|
||||
protected:
|
||||
static v8::Handle<v8::Value> New(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> DecipherInit(const v8::Arguments& args);
|
||||
|
||||
static v8::Handle<v8::Value> DecipherInitIv(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> DecipherUpdate(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> SetAutoPadding(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> DecipherFinal(const v8::Arguments& args);
|
||||
|
||||
Decipher() : ObjectWrap(), initialised_(false) {
|
||||
}
|
||||
|
||||
~Decipher() {
|
||||
if (initialised_) {
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
EVP_CIPHER_CTX ctx;
|
||||
const EVP_CIPHER *cipher_;
|
||||
bool initialised_;
|
||||
};
|
||||
|
||||
class Hmac : public ObjectWrap {
|
||||
public:
|
||||
static void Initialize (v8::Handle<v8::Object> target);
|
||||
|
||||
bool HmacInit(char* hashType, char* key, int key_len);
|
||||
int HmacUpdate(char* data, int len);
|
||||
int HmacDigest(unsigned char** md_value, unsigned int *md_len);
|
||||
|
||||
protected:
|
||||
static v8::Handle<v8::Value> New(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> HmacInit(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> HmacUpdate(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> HmacDigest(const v8::Arguments& args);
|
||||
|
||||
Hmac() : ObjectWrap(), initialised_(false) {
|
||||
}
|
||||
|
||||
~Hmac() {
|
||||
if (initialised_) {
|
||||
HMAC_CTX_cleanup(&ctx);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
HMAC_CTX ctx; /* coverity[member_decl] */
|
||||
const EVP_MD *md; /* coverity[member_decl] */
|
||||
bool initialised_;
|
||||
};
|
||||
|
||||
class Hash : public ObjectWrap {
|
||||
public:
|
||||
static void Initialize (v8::Handle<v8::Object> target);
|
||||
|
||||
bool HashInit (const char* hashType);
|
||||
int HashUpdate(char* data, int len);
|
||||
|
||||
protected:
|
||||
static v8::Handle<v8::Value> New(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> HashUpdate(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> HashDigest(const v8::Arguments& args);
|
||||
|
||||
Hash() : ObjectWrap(), initialised_(false) {
|
||||
}
|
||||
|
||||
~Hash() {
|
||||
if (initialised_) {
|
||||
EVP_MD_CTX_cleanup(&mdctx);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
EVP_MD_CTX mdctx; /* coverity[member_decl] */
|
||||
const EVP_MD *md; /* coverity[member_decl] */
|
||||
bool initialised_;
|
||||
};
|
||||
|
||||
class Sign : public ObjectWrap {
|
||||
public:
|
||||
static void Initialize(v8::Handle<v8::Object> target);
|
||||
|
||||
bool SignInit (const char* signType);
|
||||
int SignUpdate(char* data, int len);
|
||||
int SignFinal(unsigned char** md_value,
|
||||
unsigned int *md_len,
|
||||
char* key_pem,
|
||||
int key_pemLen);
|
||||
|
||||
protected:
|
||||
static v8::Handle<v8::Value> New(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> SignInit(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> SignUpdate(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> SignFinal(const v8::Arguments& args);
|
||||
|
||||
Sign() : ObjectWrap(), initialised_(false) {
|
||||
}
|
||||
|
||||
~Sign () {
|
||||
if (initialised_) {
|
||||
EVP_MD_CTX_cleanup(&mdctx);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
EVP_MD_CTX mdctx; /* coverity[member_decl] */
|
||||
const EVP_MD *md; /* coverity[member_decl] */
|
||||
bool initialised_;
|
||||
};
|
||||
|
||||
class Verify : public ObjectWrap {
|
||||
public:
|
||||
static void Initialize (v8::Handle<v8::Object> target);
|
||||
|
||||
bool VerifyInit (const char* verifyType);
|
||||
int VerifyUpdate(char* data, int len);
|
||||
int VerifyFinal(char* key_pem,
|
||||
int key_pemLen,
|
||||
unsigned char* sig,
|
||||
int siglen);
|
||||
|
||||
protected:
|
||||
static v8::Handle<v8::Value> New (const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> VerifyInit(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> VerifyUpdate(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> VerifyFinal(const v8::Arguments& args);
|
||||
|
||||
Verify() : ObjectWrap(), initialised_(false) {
|
||||
}
|
||||
|
||||
~Verify() {
|
||||
if (initialised_) {
|
||||
EVP_MD_CTX_cleanup(&mdctx);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
EVP_MD_CTX mdctx; /* coverity[member_decl] */
|
||||
const EVP_MD *md; /* coverity[member_decl] */
|
||||
bool initialised_;
|
||||
|
||||
};
|
||||
|
||||
class DiffieHellman : public ObjectWrap {
|
||||
public:
|
||||
static void Initialize(v8::Handle<v8::Object> target);
|
||||
|
||||
bool Init(int primeLength);
|
||||
bool Init(unsigned char* p, int p_len);
|
||||
bool Init(unsigned char* p, int p_len, unsigned char* g, int g_len);
|
||||
|
||||
protected:
|
||||
static v8::Handle<v8::Value> DiffieHellmanGroup(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> New(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> GenerateKeys(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> GetPrime(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> GetGenerator(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> GetPublicKey(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> GetPrivateKey(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> ComputeSecret(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> SetPublicKey(const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> SetPrivateKey(const v8::Arguments& args);
|
||||
|
||||
DiffieHellman() : ObjectWrap(), initialised_(false), dh(NULL) {
|
||||
}
|
||||
|
||||
~DiffieHellman() {
|
||||
if (dh != NULL) {
|
||||
DH_free(dh);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool VerifyContext();
|
||||
|
||||
bool initialised_;
|
||||
DH* dh;
|
||||
};
|
||||
|
||||
void InitCrypto(v8::Handle<v8::Object> target);
|
||||
|
||||
} // namespace crypto
|
||||
|
Loading…
x
Reference in New Issue
Block a user