at_client_sdk
at_client_sdk copied to clipboard
Synchronisation error - Invalid or corrupted pad block
Describe the bug
Sometimes after key creation the synchronisation fails with following error:
I/flutter (30031): SEVERE|2022-10-11 02:54:02.704061|EncryptionUtil|Error while decrypting value: Invalid argument(s): Invalid or corrupted pad block
I/flutter (30031): SEVERE|2022-10-11 02:54:02.708559|NotificationServiceImpl|Failed to decryptData caused by
I/flutter (30031): Failed to decrypt @baboon9blue:@baboon9blue:shared_key@81bored7@81bored7 caused by
I/flutter (30031): Invalid argument(s): Invalid or corrupted pad block
No further indication of the error
Steps to reproduce
- Create a key and put it to local storage
- Have keys synchronized
Expected behavior
Keys are synchronised as they are
Screenshots
No response
Smartphones
- Device: Emulator
- OS: Android
Were you using an atApplication when the bug was found?
None
Additional context
No response
Root cause of the issue:
On the sender side, a sharedKey (AES key) is generated and is encrypted with the receiver's public key and the resultant which is encryptedSharedKey is notified to the receiver's atsign. On the receiver side, when a notification related to sharedKey arrives, it is treated a SharedKey and SharedKeyDecryption is performed; which means the encryptedSharedKey is decrypted with the original sharedKey which leads to the corrupted pad block error.
Below is the screenshot which show the encryptedValue and the encryptedSharedKey has a same value.
The issue is fixed and changes are merged to trunk branch
The changes are published in v3.0.42. Hence marking the issue as fixed.
Thanks @kalluriramkumar ... did you look into why the error message says Failed to decrypt @baboon9blue:@baboon9blue:shared_key@81bored7@81bored7
instead of Failed to decrypt @baboon9blue:shared_key@81bored7
?
Thanks @kalluriramkumar ... did you look into why the error message says
Failed to decrypt @baboon9blue:@baboon9blue:shared_key@81bored7@81bored7
instead ofFailed to decrypt @baboon9blue:shared_key@81bored7
?
Yes, @gkc. In the update_verb_handler.dart, we prefix and append the sharedWith and sharedBy to the key before sending the notification. So, the key in the notification looks like "@bob:phone@alice"; when logging the key, we have an atKey.toString which will again add sharedWith and sharedBy to the key. Hence the atsign's are shown twice.
Great - have you created a ticket to track fixing that bug?
Great - have you created a ticket to track fixing that bug?
I remember seeing a similar bug. I will go through the bugs list. If there is no issue, will create one and update the git issue here.
Thanks @kalluriramkumar ... did you look into why the error message says
Failed to decrypt @baboon9blue:@baboon9blue:shared_key@81bored7@81bored7
instead ofFailed to decrypt @baboon9blue:shared_key@81bored7
?
Created a git issue to the bug: https://github.com/atsign-foundation/at_client_sdk/issues/772
Closing this ticket as fixed. There is another issue with decryption reported by @ralfeus which I will be looking into this week