diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-09-03 23:15:30 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-09-03 23:33:02 +0200 |
commit | 7d0543c128839523e088f3ef3aeec88ee884b4e4 (patch) | |
tree | 55b3ec7836787dbe9966a3d8270d3cdb710610a1 /src | |
parent | d1eff9ab68ae3fa32285544ad9f1d2c2ed52ab82 (diff) | |
download | node-new-7d0543c128839523e088f3ef3aeec88ee884b4e4.tar.gz |
crypto: make pbkdf2() compatible with domains
Diffstat (limited to 'src')
-rw-r--r-- | src/node_crypto.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc index dc5da802bb..50f0b42d1f 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -4201,7 +4201,7 @@ struct pbkdf2_req { size_t iter; char* key; size_t keylen; - Persistent<Function> callback; + Persistent<Object> obj; }; void @@ -4236,16 +4236,13 @@ EIO_PBKDF2After(uv_work_t* req) { argv[1] = Local<Value>::New(Undefined()); } - // XXX There should be an object connected to this that - // we can attach a domain onto. - MakeCallback(Context::GetCurrent()->Global(), - request->callback, - ARRAY_SIZE(argv), argv); + MakeCallback(request->obj, "ondone", ARRAY_SIZE(argv), argv); delete[] request->pass; delete[] request->salt; delete[] request->key; - request->callback.Dispose(); + request->obj.Dispose(); + request->obj.Clear(); delete request; } @@ -4267,6 +4264,7 @@ PBKDF2(const Arguments& args) { Local<Function> callback; pbkdf2_req* request = NULL; uv_work_t* req = NULL; + Persistent<Object> obj; if (args.Length() != 5) { type_error = "Bad parameter"; @@ -4324,7 +4322,8 @@ PBKDF2(const Arguments& args) { goto err; } - callback = Local<Function>::Cast(args[4]); + obj = Persistent<Object>::New(Object::New()); + obj->Set(String::New("ondone"), args[4]); request = new pbkdf2_req; request->err = 0; @@ -4335,7 +4334,7 @@ PBKDF2(const Arguments& args) { request->iter = iter; request->key = key; request->keylen = keylen; - request->callback = Persistent<Function>::New(callback); + request->obj = obj; req = new uv_work_t(); req->data = request; |