-
Notifications
You must be signed in to change notification settings - Fork 49
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
Throw exception on AEAD decryption failure #90
Conversation
Thanks so much for the PR! The only problem I have with it is addition of a new package 😕 I see you also added a custom exception at one point, may I ask why you used |
I thought it's better to use an existing Exception in the Java Cryptography Extension API which denotes the same cause. I reckon javax.crypto.AEADBadTagException is available in JDK >= 1.7 and Android API >= 19 so there aren't any external dependencies being added. Does the project support JDK/Android targets below this? I'd be happy to change it however you see fit. |
OK you have convinced me. It's better to reuse than reinvent the wheel. Let's keep it using |
Co-authored-by: Gurpreet Paul <gurpreet@gurpreet.co>
@@ -122,8 +211,22 @@ public void encryptAES() { | |||
} | |||
} | |||
|
|||
@Test(expected = AEADBadTagException.class) | |||
public void encryptAESMalformedCipher() throws AEADBadTagException { | |||
if (lazySodium.cryptoAeadAES256GCMIsAvailable()) { |
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.
Hi, because of this if statement, wouldn't this fail if cryptoAeadAES256GCMIsAvailable
is false because it expects an exception (@Test(expected = AEADBadTagException.class)
) all the time?
|
||
@Before | ||
public void doBeforeEverything() { | ||
lazySodium = new LazySodiumJava(new SodiumJava(LibraryLoader.Mode.BUNDLED_ONLY)); | ||
encoder = new HexMessageEncoder(); |
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.
This can probably be moved to AEADTest
rather than be added to the BaseTest
class.
Hey I'll merge but then pickup the changes myself 👍 |
Added support for ARM 64-bit devices. Tested under: ``` uname -a Linux ubuntu-linux-20-04-desktop 5.4.0-80-generic terl#90-Ubuntu SMP Fri Jul 9 17:43:26 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux ```
Added support for ARM 64-bit devices. Tested under: ``` uname -a Linux ubuntu-linux-20-04-desktop 5.4.0-80-generic #90-Ubuntu SMP Fri Jul 9 17:43:26 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux ```
AddsAEADAuthenticationException
which is thrown if any AEAD decryption fails.Throws
javax.crypto.AEADBadTagException
in case of AEAD decryption failure.This is a backwards incompatible change to the API and might require a major version bump.
Fixes #89