@@ -45,14 +45,11 @@ std::unique_ptr<mongocrypt_binary_t, MongoCryptBinaryDeleter> Uint8ArrayToBinary
45
45
}
46
46
47
47
Uint8Array BufferFromBinary (Env env, mongocrypt_binary_t * binary) {
48
- const uint8_t * data = mongocrypt_binary_data (binary);
49
- size_t len = mongocrypt_binary_len (binary);
50
- return Buffer<uint8_t >::Copy (env, data, len);
48
+ return Buffer<uint8_t >::Copy (env, (uint8_t *)binary->data , binary->len );
51
49
}
52
50
53
51
Uint8Array BufferWithLengthOf (Env env, mongocrypt_binary_t * binary) {
54
- size_t len = mongocrypt_binary_len (binary);
55
- return Buffer<uint8_t >::New (env, len);
52
+ return Buffer<uint8_t >::New (env, binary->len );
56
53
}
57
54
58
55
Uint8Array Uint8ArrayFromValue (Napi::Value v, std::string argument_name) {
@@ -64,13 +61,13 @@ Uint8Array Uint8ArrayFromValue(Napi::Value v, std::string argument_name) {
64
61
}
65
62
66
63
void CopyBufferData (mongocrypt_binary_t * out, Uint8Array buffer, size_t count) {
67
- assert (count <= mongocrypt_binary_len ( out) );
64
+ assert (count <= out-> len );
68
65
assert (count <= buffer.ByteLength ());
69
- memcpy (mongocrypt_binary_data ( out) , buffer.Data (), count);
66
+ memcpy (out-> data , buffer.Data (), count);
70
67
}
71
68
72
69
void CopyBufferData (mongocrypt_binary_t * out, Uint8Array buffer) {
73
- CopyBufferData (out, buffer, mongocrypt_binary_len ( out) );
70
+ CopyBufferData (out, buffer, out-> len );
74
71
}
75
72
76
73
std::string errorStringFromStatus (mongocrypt_t * crypt) {
@@ -184,12 +181,12 @@ static bool aes_256_generic_hook(MongoCrypt* mongoCrypt,
184
181
Uint8Array keyBuffer = BufferFromBinary (env, key);
185
182
Uint8Array ivBuffer = BufferFromBinary (env, iv);
186
183
Uint8Array inBuffer = BufferFromBinary (env, in);
187
- Uint8Array outBuffer = BufferWithLengthOf (env, out);
184
+ Uint8Array outputBuffer = BufferWithLengthOf (env, out);
188
185
189
186
Value result;
190
187
try {
191
188
result =
192
- hook.Call (std::initializer_list<napi_value>{keyBuffer, ivBuffer, inBuffer, outBuffer });
189
+ hook.Call (std::initializer_list<napi_value>{keyBuffer, ivBuffer, inBuffer, outputBuffer });
193
190
} catch (...) {
194
191
return false ;
195
192
}
@@ -200,7 +197,7 @@ static bool aes_256_generic_hook(MongoCrypt* mongoCrypt,
200
197
}
201
198
202
199
*bytes_written = result.ToNumber ().Uint32Value ();
203
- CopyBufferData (out, outBuffer , *bytes_written);
200
+ CopyBufferData (out, outputBuffer , *bytes_written);
204
201
return true ;
205
202
}
206
203
@@ -262,11 +259,11 @@ bool MongoCrypt::setupCryptoHooks() {
262
259
HandleScope scope (env);
263
260
Function hook = mongoCrypt->GetCallback (" randomHook" );
264
261
265
- Uint8Array outBuffer = BufferWithLengthOf (env, out);
262
+ Uint8Array outputBuffer = BufferWithLengthOf (env, out);
266
263
Napi::Value result;
267
264
try {
268
265
result =
269
- hook.Call (std::initializer_list<napi_value>{outBuffer , Number::New (env, count)});
266
+ hook.Call (std::initializer_list<napi_value>{outputBuffer , Number::New (env, count)});
270
267
} catch (...) {
271
268
return false ;
272
269
}
@@ -276,7 +273,7 @@ bool MongoCrypt::setupCryptoHooks() {
276
273
return false ;
277
274
}
278
275
279
- CopyBufferData (out, outBuffer );
276
+ CopyBufferData (out, outputBuffer );
280
277
return true ;
281
278
};
282
279
0 commit comments