@@ -204,20 +204,17 @@ const EVP_MD* GetDigestImplementation(Environment* env,
204
204
}
205
205
206
206
// crypto.digest(algorithm, algorithmId, algorithmCache,
207
- // input, inputEncoding, inputEncodingId,
208
- // outputEncoding, outputEncodingId)
207
+ // input, outputEncoding, outputEncodingId)
209
208
void Hash::OneShotDigest (const FunctionCallbackInfo<Value>& args) {
210
209
Environment* env = Environment::GetCurrent (args);
211
210
Isolate* isolate = env->isolate ();
212
- CHECK_EQ (args.Length (), 8 );
211
+ CHECK_EQ (args.Length (), 6 );
213
212
CHECK (args[0 ]->IsString ()); // algorithm
214
213
CHECK (args[1 ]->IsInt32 ()); // algorithmId
215
214
CHECK (args[2 ]->IsObject ()); // algorithmCache
216
215
CHECK (args[3 ]->IsString () || args[3 ]->IsArrayBufferView ()); // input
217
- CHECK (args[4 ]->IsString ()); // inputEncoding
218
- CHECK (args[5 ]->IsUint32 () || args[5 ]->IsUndefined ()); // inputEncodingId
219
- CHECK (args[6 ]->IsString ()); // outputEncoding
220
- CHECK (args[7 ]->IsUint32 () || args[7 ]->IsUndefined ()); // outputEncodingId
216
+ CHECK (args[4 ]->IsString ()); // outputEncoding
217
+ CHECK (args[5 ]->IsUint32 () || args[5 ]->IsUndefined ()); // outputEncodingId
221
218
222
219
const EVP_MD* md = GetDigestImplementation (env, args[0 ], args[1 ], args[2 ]);
223
220
if (md == nullptr ) {
@@ -227,8 +224,7 @@ void Hash::OneShotDigest(const FunctionCallbackInfo<Value>& args) {
227
224
return ThrowCryptoError (env, ERR_get_error (), message.c_str ());
228
225
}
229
226
230
- enum encoding input_enc = ParseEncoding (isolate, args[4 ], args[5 ], UTF8);
231
- enum encoding output_enc = ParseEncoding (isolate, args[6 ], args[7 ], BUFFER);
227
+ enum encoding output_enc = ParseEncoding (isolate, args[4 ], args[5 ], HEX);
232
228
233
229
int md_len = EVP_MD_size (md);
234
230
unsigned int result_size;
@@ -241,15 +237,9 @@ void Hash::OneShotDigest(const FunctionCallbackInfo<Value>& args) {
241
237
// in the future.
242
238
// https://github.com/openssl/openssl/issues/19612
243
239
if (args[3 ]->IsString ()) {
244
- StringBytes::InlineDecoder decoder;
245
- // Input is a string so it must be decodable.
246
- decoder.Decode (env, args[3 ].As <String>(), input_enc).Check ();
247
- if (UNLIKELY (decoder.size () > INT_MAX)) {
248
- return THROW_ERR_OUT_OF_RANGE (env, " data is too long" );
249
- }
250
-
251
- success = EVP_Digest (decoder.out (),
252
- decoder.size (),
240
+ Utf8Value utf8 (isolate, args[3 ]);
241
+ success = EVP_Digest (utf8.out (),
242
+ utf8.length (),
253
243
output.data <unsigned char >(),
254
244
&result_size,
255
245
md,
0 commit comments