-
Notifications
You must be signed in to change notification settings - Fork 33
[MOB-9235] Fix variable IV length issue #853
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
Conversation
evantk91
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some clarifications
| combined[0] = if (encryptedData.isModernEncryption) 1 else 0 | ||
| System.arraycopy(encryptedData.iv, 0, combined, 1, encryptedData.iv.size) | ||
| System.arraycopy(encryptedData.data, 0, combined, 1 + encryptedData.iv.size, encryptedData.data.size) | ||
| combined[1] = encryptedData.iv.size.toByte() // Store IV length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see IV length is pulled from data instead of being hardcoded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right so we have variable iv lenghts and we encode it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and then when we decode it we know what the iv length was
| val cipher = Cipher.getInstance(TRANSFORMATION_MODERN) | ||
| val iv = generateIV() | ||
| val spec = GCMParameterSpec(GCM_TAG_LENGTH, iv) | ||
| cipher.init(Cipher.ENCRYPT_MODE, getKey(), spec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is generateIV removed here? Seems like it should follow encrypt legacy but with modern set to true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in modern we dont generate instead we let android generate it
Fix Variable IV Length Issue