fix!: remove padding from decryptedBytes if left in by the cipher #647
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On (some?) Pixel devices (tested Pixel 6 and Pixel 7 on Android 14,
AP2A.240705.004
build) for certain string lengths (e.g.256
) the encryption/decryption usingCipherStorageKeystoreAesCbc
doesn't erase thePKCS7
padding from the returned string.To work around this issue I added a method that will detect & delete the padding if left in.
This technically a breaking change for any stored strings that end with a valid
PKCS7
padding of characters up to with an ascii int value ofIV.IV_LENGTH
. Not sure how likely this use-case would be.Opened this workaround as a discussion point, happy to discuss alternatives.
Also reported to Android https://issuetracker.google.com/issues/357896946, so they can look at the issue on their side