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

Stripped of result with not padded AES #32

Closed
chinabrant opened this issue Apr 10, 2019 · 6 comments · Fixed by #41
Closed

Stripped of result with not padded AES #32

chinabrant opened this issue Apr 10, 2019 · 6 comments · Fixed by #41
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@chinabrant
Copy link

chinabrant commented Apr 10, 2019

static List<int> aes128Decode(List<int> data) {
    final key = Key.fromUtf8('15helloTCJTALK20'); 
    final iv = IV.fromLength(16);
    final encrypter = Encrypter(AES(key, iv, mode: AESMode.ecb, padding: null));
    final encrypted = Encrypted(Uint8List.fromList(data));
    print("original: $data");
    print("Uint8List: ${Uint8List.fromList(data)}");
    final result = encrypter.decrypt(encrypted);
    print('result: ${result}');

    return result.runes.toList();
}
flutter: original: [17, 224, 52, 85, 164, 137, 148, 236, 196, 53, 80, 125, 53, 13, 44, 30, 54, 190, 172, 57, 111, 245, 100, 145, 153, 69, 59, 32, 229, 59, 61, 18, 247, 169, 7, 188, 32, 186, 28, 224, 124, 71, 191, 191, 198, 79, 102, 226, 228, 94, 168, 232, 186, 75, 58, 179, 254, 22, 52, 59, 190, 242, 84, 213, 254, 110, 174, 191, 8, 229, 54, 99, 99, 156, 146, 249, 144, 238, 195, 250, 211, 209, 206, 248, 151, 35, 4, 199, 72, 163, 193, 187, 170, 133, 151, 172, 106, 226, 69, 145, 235, 20, 231, 51, 128, 35, 25, 36, 207, 178, 148, 49, 207, 44, 218, 100, 233, 120, 108, 131, 21, 166, 249, 151, 101, 233, 73, 162, 131, 107, 66, 125, 212, 22, 35, 247, 182, 222, 15, 169, 109, 67, 111, 242, 136, 189, 193, 199, 44, 200, 35, 180, 62, 71, 60, 73, 226, 59, 164, 119, 60, 231, 127, 236, 85, 98, 241, 58, 219, 30, 242, 104, 125, 4, 225, 218, 248, 215, 134, 142, 251, 242, 201, 192, 245, 21, 253, 180, 70, 243, 49, 179, 171, 73, 133, 4, 171, 187, 186, 167, 51, 194, 73, 91, 50, 141, 120, 174, 76, 74, 129, 83, 229, 246, <…>
flutter: Uint8List: [17, 224, 52, 85, 164, 137, 148, 236, 196, 53, 80, 125, 53, 13, 44, 30, 54, 190, 172, 57, 111, 245, 100, 145, 153, 69, 59, 32, 229, 59, 61, 18, 247, 169, 7, 188, 32, 186, 28, 224, 124, 71, 191, 191, 198, 79, 102, 226, 228, 94, 168, 232, 186, 75, 58, 179, 254, 22, 52, 59, 190, 242, 84, 213, 254, 110, 174, 191, 8, 229, 54, 99, 99, 156, 146, 249, 144, 238, 195, 250, 211, 209, 206, 248, 151, 35, 4, 199, 72, 163, 193, 187, 170, 133, 151, 172, 106, 226, 69, 145, 235, 20, 231, 51, 128, 35, 25, 36, 207, 178, 148, 49, 207, 44, 218, 100, 233, 120, 108, 131, 21, 166, 249, 151, 101, 233, 73, 162, 131, 107, 66, 125, 212, 22, 35, 247, 182, 222, 15, 169, 109, 67, 111, 242, 136, 189, 193, 199, 44, 200, 35, 180, 62, 71, 60, 73, 226, 59, 164, 119, 60, 231, 127, 236, 85, 98, 241, 58, 219, 30, 242, 104, 125, 4, 225, 218, 248, 215, 134, 142, 251, 242, 201, 192, 245, 21, 253, 180, 70, 243, 49, 179, 171, 73, 133, 4, 171, 187, 186, 167, 51, 194, 73, 91, 50, 141, 120, 174, 76, 74, 129, 83, 229, 246,<…>
flutter: result: {"moment":{"url"

The result just 16 characters. Should be a json string.

what's wrong?

@leocavalcante leocavalcante self-assigned this Apr 18, 2019
@leocavalcante leocavalcante added help wanted Extra attention is needed question Further information is requested labels Apr 18, 2019
@leocavalcante
Copy link
Owner

This is probably because of the lack of a padding. I'll dig into that asap.

@leocavalcante leocavalcante changed the title aes decrypt result error Stripped of result with not padded AES Apr 30, 2019
@christophewang
Copy link

@leocavalcante Any update on this issue ? I'm confronted with the same problem. The result I get after I decrypt return me the first 16 bytes but I'm expecting 32 bytes in total. In my case, I don't use padding as well since my data is already a multiple of the block size.

@leocavalcante leocavalcante added bug Something isn't working and removed question Further information is requested labels May 19, 2019
leocavalcante added a commit that referenced this issue May 19, 2019
@leocavalcante leocavalcante mentioned this issue May 19, 2019
@leocavalcante
Copy link
Owner

@chinabrant I'm really sorry about the delay, this got out of my radar.
@christophewang thanks for bringing this up!

Can you folks test https://github.com/leocavalcante/encrypt/tree/fix/32 please?

dependencies:
  encrypt:
    git:
      url: git://github.com/leocavalcante/encrypt.git
      ref: fix/32

If it works for you I make it officially 3.1.0 on pub

@christophewang
Copy link

@leocavalcante Yes, I just tried and it works for me ! Thanks 👍

@chinabrant
Copy link
Author

It works! Thanks.

@leocavalcante
Copy link
Owner

It on 3.1.0 now https://pub.dev/packages/encrypt/versions/3.1.0
Thanks!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants