-
Notifications
You must be signed in to change notification settings - Fork 12
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
Modify SymmetricCipher overlaps buffer checks #295
Modify SymmetricCipher overlaps buffer checks #295
Conversation
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.
LGTM
The `doFinal` and `update` methods in the SymmetricCipher class have logic to detect if a input buffer and output buffer are overlapping in any sort of way. If they are then a copy of the input is made to a separate location to ensure a safe operation can then take place on the data. There is a logic problem where the calculation of overlap was incorrect and used a `=` instead of a `+` to calculate if the input and output overlapped. The comment above this code block was correct and remains unmodified. The test `BaseTestAESGCMCopySafe` was modified to test this condition which it was attempting to do in the past however it was not operating upon input and output buffers that had the same memory address. The test was modified to exercise various overlapping conditions for AES GCM and also AES CBC accordingly. The test was then renamed to `BaseTestAESCopySafe` since we are now testing both GCM and CBC modes. Fixes IBM#292 Signed-off-by: Jason Katonica <katonica@us.ibm.com>
46a71f1
to
dee50b3
Compare
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.
LGTM
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.
LGTM
x86_64_linux,ppc64le_linux,s390x_linux,x86_64_windows |
The
doFinal
andupdate
methods in the SymmetricCipher class have logic to detect if a input buffer and output buffer are overlapping in any sort of way. If they are then a copy of the input is made to a separate location to ensure a safe operation can then take place on the data.There is a logic problem where the calculation of overlap was incorrect and used a
=
instead of a+
to calculate if the input and output overlapped. The comment above this code block was correct and remains unmodified.The test
BaseTestAESGCMCopySafe
was modified to test this condition which it was attempting to do in the past however it was not operating upon input and output buffers that had the same memory address. The test was modified to exercise various overlapping conditions for AES GCM and also AES CBC accordingly. The test was then renamed toBaseTestAESCopySafe
since we are now testing both GCM and CBC modes.Fixes #292
Signed-off-by: Jason Katonica katonica@us.ibm.com