Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When setting keys in ECB mode, don't check IV length. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

smaxa20
Copy link

@smaxa20 smaxa20 commented Apr 24, 2020

I was trying to encrypt a string using a generated key and no IV because I'm using ECB. Here's my code:

var crypt = AesCrypt();
crypt.aesSetMode(AesMode.ecb);
Uint8List key = crypt.createKey();
crypt.aesSetKeys(key);
...

When I go to set the key it fails giving this error:
Unhandled Exception: NoSuchMethodError: The getter 'length' was called on null.

With this partial stack trace:


E/flutter ( 7509): #1      _Aes.aesSetKeys          package:aes_crypt/src/aes.dart:199
E/flutter ( 7509): #2      AesCrypt.aesSetKeys      package:aes_crypt/src
...

Following this trace to aes_crypt/src/aes.dart:199 I find this code:

} else if (iv.length != 16) {

It checks the length of the IV even in ECB mode when ECB mode doesn't require an IV (if my understanding is correct).
I've made this check only occur when the mode is not ECB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant