AKushWarrior / steel_crypt

A collection of high-level API's exposing PointyCastle to perform hashing and encrypting in popular/secure algorithms.
https://pub.dev/packages/steel_crypt
Mozilla Public License 2.0
40 stars 10 forks source link

RegistryFactoryException: No algorithm registered of type BlockCipher with name: AES/OFB #41

Closed Skyost closed 4 years ago

Skyost commented 4 years ago

Using v2.0.0, I was using this code to encrypt / decrypt a string :

String encryptionKey = await CryptKey().genFortuna();
String initializationVector = await CryptKey().genDart();
AesCrypt crypter = AesCrypt(
  key: encryptionKey,
  mode: ModeAES.ofb64,
  padding: PaddingAES.pkcs7,
);

String crypted = crypter.encrypt('string', iv: initializationVector)
String decrypted = crypter.decrypt(crypted, iv: initializationVector)

I recently upgraded to the latest version (2.2.1) and so I migrated the above code to :

String encryptionKey = await CryptKey().genFortuna();
String initializationVector = await CryptKey().genDart();
AesCrypt crypter = AesCrypt(
  key: encryptionKey,
  padding: PaddingAES.pkcs7,
);

String crypted = crypter.ofb64.encrypt(inp: 'string', iv: initializationVector)
String decrypted = crypter.ofb64.decrypt(enc: crypted, iv: initializationVector)

And now I get the following errors :

RegistryFactoryException: No algorithm registered of type BlockCipher with name: AES/OFB
#0      _RegistryImpl._createConstructor (package:pc_steelcrypt/src/registry/registry.dart:135:5)
#1      _RegistryImpl.getConstructor (package:pc_steelcrypt/src/registry/registry.dart:106:21)
#2      _RegistryImpl.create (package:pc_steelcrypt/src/registry/registry.dart:96:23)
#3      new BlockCipher (package:pc_steelcrypt/src/api/block_cipher.dart:9:16)
#4      PaddedBlockCipherImpl.FACTORY_CONFIG.<anonymous closure>.<anonymous closure> (package:pc_steelcrypt/padded_block_cipher/padded_block_cipher_impl.dart
#5      _RegistryImpl.create (package:pc_steelcrypt/src/registry/registry.dart:97:29)
#6      new PaddedBlockCipher (package:pc_steelcrypt/src/api/padded_block_cipher.dart:23:16)
#7      OfbSatellite.encrypt (package:steel_crypt/src/satellites/ofb.dart:18:11)
RegistryFactoryException: No algorithm registered of type BlockCipher with name: AES/OFB
#0      _RegistryImpl._createConstructor (package:pc_steelcrypt/src/registry/registry.dart:135:5)
#1      _RegistryImpl.getConstructor (package:pc_steelcrypt/src/registry/registry.dart:106:21)
#2      _RegistryImpl.create (package:pc_steelcrypt/src/registry/registry.dart:96:23)
#3      new BlockCipher (package:pc_steelcrypt/src/api/block_cipher.dart:9:16)
#4      PaddedBlockCipherImpl.FACTORY_CONFIG.<anonymous closure>.<anonymous closure> (package:pc_steelcrypt/padded_block_cipher/padded_block_cipher_impl.dart:18:
#5      _RegistryImpl.create (package:pc_steelcrypt/src/registry/registry.dart:97:29)
#6      new PaddedBlockCipher (package:pc_steelcrypt/src/api/padded_block_cipher.dart:23:16)
#7      OfbSatellite.decrypt (package:steel_crypt/src/satellites/ofb.dart:34:11)

Have I done something wrong ?

AKushWarrior commented 4 years ago

You have not; this is a bug. I'll check out what's going wrong.

AKushWarrior commented 4 years ago

Okay, I know what went wrong. It's a stupid mistake; should be fixed by the end of this week.

Also, I would be cautious about using OFB. Note that this is a version of OFB that processes in 64-bit blocks, not the original stream cipher.

Skyost commented 4 years ago

Also, I would be cautious about using OFB.

What are the risks ?

AKushWarrior commented 4 years ago

Also, I would be cautious about using OFB.

What are the risks ?

@Skyost I wasn't talking about a security risk. Interoperability with another language's implementation of OFB may not work as expected.

Skyost commented 4 years ago

Oh that's okay, I'm only using it in Dart anyway 😄

AKushWarrior commented 4 years ago

Should be fixed in steel_crypt v2.2+

Skyost commented 4 years ago

Cool, thanks !