@@ -204,20 +204,17 @@ const EVP_MD* GetDigestImplementation(Environment* env,
204204}
205205
206206// crypto.digest(algorithm, algorithmId, algorithmCache,
207- // input, inputEncoding, inputEncodingId,
208- // outputEncoding, outputEncodingId)
207+ // input, outputEncoding, outputEncodingId)
209208void Hash::OneShotDigest (const FunctionCallbackInfo<Value>& args) {
210209 Environment* env = Environment::GetCurrent (args);
211210 Isolate* isolate = env->isolate ();
212- CHECK_EQ (args.Length (), 8 );
211+ CHECK_EQ (args.Length (), 6 );
213212 CHECK (args[0 ]->IsString ()); // algorithm
214213 CHECK (args[1 ]->IsInt32 ()); // algorithmId
215214 CHECK (args[2 ]->IsObject ()); // algorithmCache
216215 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
221218
222219 const EVP_MD* md = GetDigestImplementation (env, args[0 ], args[1 ], args[2 ]);
223220 if (md == nullptr ) {
@@ -227,8 +224,7 @@ void Hash::OneShotDigest(const FunctionCallbackInfo<Value>& args) {
227224 return ThrowCryptoError (env, ERR_get_error (), message.c_str ());
228225 }
229226
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);
232228
233229 int md_len = EVP_MD_size (md);
234230 unsigned int result_size;
@@ -241,15 +237,9 @@ void Hash::OneShotDigest(const FunctionCallbackInfo<Value>& args) {
241237 // in the future.
242238 // https://github.com/openssl/openssl/issues/19612
243239 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 (),
253243 output.data <unsigned char >(),
254244 &result_size,
255245 md,
0 commit comments