1
1
// extcrypto.cc - some openssl wrappers to extend RSA support
2
2
#include < node.h>
3
+ #include < nan.h>
3
4
#include < stdint.h>
4
5
#include < string.h>
5
6
#include < openssl/rsa.h>
@@ -24,15 +25,15 @@ namespace extcrypto {
24
25
const unsigned argc = 2 ;
25
26
Local<Value> argv[argc] = { Null (isolate), rval };
26
27
27
- cb-> Call (Null (isolate ), argc, argv);
28
+ Nan:: Call (Nan::Callback (cb ), argc, argv);
28
29
}
29
30
30
31
31
32
void async_eret (Isolate* isolate, Local<Function> cb, Local<String> rval) {
32
33
const uint64_t argc = 1 ;
33
34
Local<Value> argv[argc] = { Exception::Error (rval) };
34
35
35
- cb-> Call (Null (isolate ), argc, argv);
36
+ Nan:: Call (Nan::Callback (cb ), argc, argv);
36
37
}
37
38
38
39
@@ -53,7 +54,7 @@ namespace extcrypto {
53
54
int64_t kg = RSA_generate_key_ex (rsa, 2048 , exp, NULL );
54
55
55
56
if (!kg) {
56
- rval = String::NewFromUtf8 (isolate, " Unable to generate key" );
57
+ rval = Nan::New ( " Unable to generate key" ). ToLocalChecked ( );
57
58
58
59
if (!async) {
59
60
args.GetReturnValue ().Set (rval);
@@ -71,7 +72,7 @@ namespace extcrypto {
71
72
72
73
if (!key || (kl == UINT64_MAX)) {
73
74
free (key); // in case compiler dependent behavior for calloc after overflow returns a non-null pointer
74
- rval = String::NewFromUtf8 (isolate, " Unable to generate key" );
75
+ rval = Nan::New ( " Unable to generate key" ). ToLocalChecked ( );
75
76
76
77
if (!async) {
77
78
args.GetReturnValue ().Set (rval);
@@ -89,7 +90,7 @@ namespace extcrypto {
89
90
90
91
// return
91
92
92
- rval = String::NewFromUtf8 (isolate, key);
93
+ rval = Nan::New ( key). ToLocalChecked ( );
93
94
free (key);
94
95
95
96
if (!async) {
@@ -112,7 +113,7 @@ namespace extcrypto {
112
113
bool async = args.Length () > 1 ;
113
114
if (async) { cb = Local<Function>::Cast (args[1 ]); }
114
115
115
- String::Utf8Value ipem (pem);
116
+ Nan::Utf8String ipem (pem);
116
117
char * skey (*ipem);
117
118
118
119
BIO* bio = BIO_new (BIO_s_mem ());
@@ -127,7 +128,7 @@ namespace extcrypto {
127
128
128
129
if (!pkey || (kl == UINT64_MAX)) {
129
130
free (pkey); // in case compiler dependent behavior for calloc after overflow returns a non-null pointer
130
- rval = String::NewFromUtf8 (isolate, " Unable to extract key" );
131
+ rval = Nan::New ( " Unable to extract key" ). ToLocalChecked ( );
131
132
132
133
if (!async) {
133
134
args.GetReturnValue ().Set (rval);
@@ -144,7 +145,7 @@ namespace extcrypto {
144
145
145
146
// return
146
147
147
- rval = String::NewFromUtf8 (isolate, pkey);
148
+ rval = Nan::New ( pkey). ToLocalChecked ( );
148
149
free (pkey);
149
150
150
151
if (!async) {
0 commit comments