Skip to content

Commit 3202791

Browse files
authored
Handle RsaVerificationPrimitive failure (non-internal error) (#49741)
1 parent b3e96b3 commit 3202791

File tree

1 file changed

+6
-1
lines changed
  • src/libraries/Common/src/System/Security/Cryptography

1 file changed

+6
-1
lines changed

src/libraries/Common/src/System/Security/Cryptography/RSAAndroid.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ private static void CheckBoolReturn(int returnValue)
587587
{
588588
if (returnValue != 1)
589589
{
590-
throw new CryptographicException();
590+
throw new CryptographicException();
591591
}
592592
}
593593

@@ -810,6 +810,11 @@ public override bool VerifyHash(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> sign
810810
int ret = Interop.AndroidCrypto.RsaVerificationPrimitive(signature, unwrapped, rsa);
811811

812812
CheckReturn(ret);
813+
if (ret == 0)
814+
{
815+
// Return value of 0 from RsaVerificationPrimitive indicates the signature could not be decrypted.
816+
return false;
817+
}
813818

814819
Debug.Assert(
815820
ret == requiredBytes,

0 commit comments

Comments
 (0)