-
Notifications
You must be signed in to change notification settings - Fork 287
[Cryptography Management] Fix instability test #5169
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
base: main
Are you sure you want to change the base?
Conversation
| end; | ||
|
|
||
| [TryFunction] | ||
| local procedure TryDecrypt(RSA: Codeunit RSA; XmlString: SecretText; EncryptedInStream: InStream; OaepPadding: Boolean; DecryptedOutStream: OutStream) |
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.
it is better to have 2 named helpers than have a boolean parameter
| DecryptionFailed := not TryDecrypt(RSA, PrivateKeyXmlStringSecret, EncryptedInStream, true, DecryptedOutStream); | ||
|
|
||
| // [THEN] Either decryption fails with an exception, or the decrypted text is garbage (not equal to plaintext) | ||
| if not DecryptionFailed then begin |
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.
there's no verification if encryption fails, no check whether the error is the expected one...
| if not DecryptionFailed then begin | ||
| DecryptingTempBlob.CreateInStream(DecryptedInStream); | ||
| DecryptedText := Base64Convert.FromBase64(Base64Convert.ToBase64(DecryptedInStream)); | ||
| LibraryAssert.AreNotEqual(PlainText, DecryptedText, 'Decryption with wrong padding should fail or return garbage data.'); |
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.
your message here should only be about garbage data no? if encryption fails you will never get to this assert
Summary
When encrypting with OAEP, PKCS should not be able to decrypt it. However the padding can randomly be correct.
Updated the test to ensure we validate the output and ensure it is garbage data decrypted when it is decrypting with a different padding.
Work Item(s)
Fixes AB#609358