@@ -231,7 +231,6 @@ void CipherBase::Initialize(Environment* env, Local<Object> target) {
231231
232232 t->InstanceTemplate ()->SetInternalFieldCount (CipherBase::kInternalFieldCount );
233233
234- SetProtoMethod (isolate, t, " init" , Init);
235234 SetProtoMethod (isolate, t, " initiv" , InitIv);
236235 SetProtoMethod (isolate, t, " update" , Update);
237236 SetProtoMethod (isolate, t, " final" , Final);
@@ -275,7 +274,6 @@ void CipherBase::RegisterExternalReferences(
275274 ExternalReferenceRegistry* registry) {
276275 registry->Register (New);
277276
278- registry->Register (Init);
279277 registry->Register (InitIv);
280278 registry->Register (Update);
281279 registry->Register (Final);
@@ -347,69 +345,6 @@ void CipherBase::CommonInit(std::string_view cipher_type,
347345 }
348346}
349347
350- void CipherBase::Init (std::string_view cipher_type,
351- const ArrayBufferOrViewContents<unsigned char >& key_buf,
352- unsigned int auth_tag_len) {
353- HandleScope scope (env ()->isolate ());
354- MarkPopErrorOnReturn mark_pop_error_on_return;
355- const auto cipher = Cipher::FromName (cipher_type);
356- if (!cipher) {
357- return THROW_ERR_CRYPTO_UNKNOWN_CIPHER (env ());
358- }
359-
360- unsigned char key[Cipher::MAX_KEY_LENGTH];
361- unsigned char iv[Cipher::MAX_IV_LENGTH];
362-
363- ncrypto::Buffer<const unsigned char > keyBuf{
364- .data = key_buf.data (),
365- .len = key_buf.size (),
366- };
367- int key_len = cipher.bytesToKey (Digest::MD5, keyBuf, key, iv);
368- CHECK_NE (key_len, 0 );
369-
370- if (kind_ == kCipher &&
371- (cipher.isCtrMode () || cipher.isGcmMode () || cipher.isCcmMode ())) {
372- // Ignore the return value (i.e. possible exception) because we are
373- // not calling back into JS anyway.
374- ProcessEmitWarning (env (),
375- " Use Cipheriv for counter mode of %s" ,
376- cipher_type);
377- }
378-
379- CommonInit (cipher_type,
380- cipher,
381- key,
382- key_len,
383- iv,
384- cipher.getIvLength (),
385- auth_tag_len);
386- }
387-
388- void CipherBase::Init (const FunctionCallbackInfo<Value>& args) {
389- CipherBase* cipher;
390- ASSIGN_OR_RETURN_UNWRAP (&cipher, args.This ());
391- Environment* env = Environment::GetCurrent (args);
392-
393- CHECK_GE (args.Length (), 3 );
394-
395- const Utf8Value cipher_type (args.GetIsolate (), args[0 ]);
396- ArrayBufferOrViewContents<unsigned char > key_buf (args[1 ]);
397- if (!key_buf.CheckSizeInt32 ())
398- return THROW_ERR_OUT_OF_RANGE (env, " password is too large" );
399-
400- // Don't assign to cipher->auth_tag_len_ directly; the value might not
401- // represent a valid length at this point.
402- unsigned int auth_tag_len;
403- if (args[2 ]->IsUint32 ()) {
404- auth_tag_len = args[2 ].As <Uint32>()->Value ();
405- } else {
406- CHECK (args[2 ]->IsInt32 () && args[2 ].As <Int32>()->Value () == -1 );
407- auth_tag_len = kNoAuthTagLength ;
408- }
409-
410- cipher->Init (cipher_type.ToStringView (), key_buf, auth_tag_len);
411- }
412-
413348void CipherBase::InitIv (std::string_view cipher_type,
414349 const ByteSource& key_buf,
415350 const ArrayBufferOrViewContents<unsigned char >& iv_buf,
0 commit comments