Skip to content
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

[Android][crypto] Android 7 crashes in AsymmetricDSASignature #107867

Open
matouskozak opened this issue Sep 16, 2024 · 2 comments
Open

[Android][crypto] Android 7 crashes in AsymmetricDSASignature #107867

matouskozak opened this issue Sep 16, 2024 · 2 comments

Comments

@matouskozak
Copy link
Member

When running System.Security.Cryptography.Xml.Tests.SignedXmlTest.AsymmetricDSASignature tests on Android 7 emulators, we get the following crash:

08-27 18:39:54.155  2753  2771 I DOTNET  : 1) 	[FAIL] System.Security.Cryptography.Xml.Tests.SignedXmlTest.AsymmetricDSASignature   Test name: System.Security.Cryptography.Xml.Tests.SignedXmlTest.AsymmetricDSASignature
08-27 18:39:54.155  2753  2771 I DOTNET  :    Assembly:  [System.Security.Cryptography.Xml.Tests, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51]
08-27 18:39:54.155  2753  2771 I DOTNET  :    Exception messages: System.Security.Cryptography.CryptographicException : Error occurred during a cryptographic operation.   Exception stack traces:    at System.Security.Cryptography.DSAImplementation.DSAAndroid.SignHash(ReadOnlySpan`1 hash, Span`1 destination, Int32 signatureLength, SafeDsaHandle key)
08-27 18:39:54.155  2753  2771 I DOTNET  :    at System.Security.Cryptography.DSAImplementation.DSAAndroid.CreateSignature(Byte[] rgbHash)
08-27 18:39:54.155  2753  2771 I DOTNET  :    at System.Security.Cryptography.DSASignatureFormatter.CreateSignature(Byte[] rgbHash)
08-27 18:39:54.155  2753  2771 I DOTNET  :    at System.Security.Cryptography.AsymmetricSignatureFormatter.CreateSignature(HashAlgorithm hash)
08-27 18:39:54.155  2753  2771 I DOTNET  :    at System.Security.Cryptography.Xml.SignedXml.ComputeSignature() in /_/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXml.cs:line 435
08-27 18:39:54.155  2753  2771 I DOTNET  :    at System.Security.Cryptography.Xml.Tests.SignedXmlTest.AsymmetricDSASignature() in /_/src/libraries/System.Security.Cryptography.Xml/tests/SignedXmlTest.cs:line 316
08-27 18:39:54.155  2753  2771 I DOTNET  :    at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
08-27 18:39:54.155  2753  2771 I DOTNET  :    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
08-27 18:39:54.155  2753  2771 I DOTNET  :    Execution time: 2.2244818

The exception is thrown by

if (!Interop.AndroidCrypto.DsaSign(key, hash, destination, out int actualLength))
{
throw new CryptographicException();
}

and the probable cause:

2024-08-28 19:49:31.026  5166-5187  System.err              net...curity.Cryptography.Xml.Tests  W  java.security.InvalidKeyException: valueN must be 224 or 256 for valueL = 2048
2024-08-28 19:49:31.026  5166-5187  System.err              net...curity.Cryptography.Xml.Tests  W  	at com.android.org.bouncycastle.jcajce.provider.asymmetric.dsa.DSASigner.checkKey(DSASigner.java:203)
2024-08-28 19:49:31.026  5166-5187  System.err              net...curity.Cryptography.Xml.Tests  W  	at com.android.org.bouncycastle.jcajce.provider.asymmetric.dsa.DSASigner.engineInitSign(DSASigner.java:116)
2024-08-28 19:49:31.026  5166-5187  System.err              net...curity.Cryptography.Xml.Tests  W  	at java.security.Signature$Delegate.init(Signature.java:1208)
2024-08-28 19:49:31.026  5166-5187  System.err              net...curity.Cryptography.Xml.Tests  W  	at java.security.Signature$Delegate.chooseProvider(Signature.java:1167)
2024-08-28 19:49:31.026  5166-5187  System.err              net...curity.Cryptography.Xml.Tests  W  	at java.security.Signature$Delegate.engineInitSign(Signature.java:1232)
2024-08-28 19:49:31.026  5166-5187  System.err              net...curity.Cryptography.Xml.Tests  W  	at java.security.Signature.initSign(Signature.java:607)

Discovered in #106951
fyi: @bartonjs @vcsjones

Copy link
Contributor

Tagging subscribers to 'arch-android': @vitek-karas, @simonrozsival, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant