Skip to content

Conversation

@vcsjones
Copy link
Member

@vcsjones vcsjones commented Sep 6, 2022

This introduces a new AuthenticationTagMismatchException for AEAD ciphers to throw during decryption when the authentication tag produces a mismatch.

Previously for Android, we were assuming any failure meant "auth tag mismatch". This changes the native shim to properly catch and handle the Android AEADBadTagException.

Closes #67082

@ghost
Copy link

ghost commented Sep 6, 2022

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost ghost assigned vcsjones Sep 6, 2022
@ghost
Copy link

ghost commented Sep 6, 2022

Tagging subscribers to this area: @dotnet/area-system-security, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

This introduces a new AuthenticationTagMismatchException for AEAD ciphers to throw during decryption when the authentication tag produces a mismatch.

Previously for Android, we were assuming anything mean "auth tag mismatch". This changes the native shim to properly catch and handle the Android AEADBadTagException.

Author: vcsjones
Assignees: -
Labels:

area-System.Security, new-api-needs-documentation

Milestone: -

@vcsjones
Copy link
Member Author

vcsjones commented Sep 6, 2022

Draft to get a run through CI. Android is very unhappy in my local dev.

@vcsjones vcsjones changed the title Auth tag mismatch Implement AuthenticationTagMismatchException exception Sep 6, 2022
@vcsjones
Copy link
Member Author

vcsjones commented Sep 6, 2022

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones
Copy link
Member Author

vcsjones commented Sep 7, 2022

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones
Copy link
Member Author

vcsjones commented Sep 7, 2022

The x86 and x64 Android legs passed. The ARM64 seemed to crash. I also cannot get the ARM64 tests to run locally, but that's true even on main, so I don't think I introduced any incorrect behavior.

Marking as ready for review, then.

@vcsjones vcsjones marked this pull request as ready for review September 7, 2022 14:53
@bartonjs
Copy link
Member

@jkoritzinsky can you weigh in on the JNI parts?

@vcsjones
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones
Copy link
Member Author

@bartonjs @jkoritzinsky I am having a hard time parsing the results of the Android test runs. I don't see anything in the test results that look like a failure as a result from this change. Can either of you help me confirm that and this is okay to merge?

@filipnavara
Copy link
Member

filipnavara commented Sep 29, 2022

It is related:

09-29 06:08:20.250  3012  3012 I DOTNET  : JNI_OnLoad: JNI_OnLoad in pal_jni.c
09-29 06:08:20.251  3012  3012 F DOTNET  : GetClassGRef: class javax/crypto/spec/AEADBadTagException was not found
--------- beginning of crash
09-29 06:08:20.251  3012  3012 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 3012 (rimitives.Tests), pid 3012 (rimitives.Tests)

Taken from one of the MonoRunner logs here

@vcsjones
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones vcsjones merged commit 60b40c3 into dotnet:main Sep 30, 2022
@vcsjones vcsjones deleted the auth-tag-mismatch branch September 30, 2022 12:57
@ghost ghost locked as resolved and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: Authenticated ciphers should distigush between mismatched tag and failure

4 participants