RsaOaepDecrypt needs to throw, not return null
authorSebastien Pouliot <sebastien@xamarin.com>
Fri, 29 May 2015 20:01:09 +0000 (16:01 -0400)
committerMarek Safar <marek.safar@gmail.com>
Mon, 2 May 2016 22:10:22 +0000 (00:10 +0200)
Mono's implementation of RSAOAEPKeyExchangeDeformatter did the throwing
but we're now using MS implementation of it - so it make sense to move
the throw (it's needed) in the utils.cs file

mcs/class/referencesource/mscorlib/system/security/cryptography/utils.cs

index 0d80fa76c3e9e3a72aed9fd549be76054f123ae6..310219a89bde462a3955b1e8c9804473568072dc 100644 (file)
@@ -880,7 +880,10 @@ namespace System.Security.Cryptography
         [System.Security.SecurityCritical]  // auto-generated
         internal static byte[] RsaOaepDecrypt (RSA rsa, HashAlgorithm hash, PKCS1MaskGenerationMethod mgf, byte[] encryptedData) {
 #if MONO
-            return Mono.Security.Cryptography.PKCS1.Decrypt_OAEP (rsa, hash, encryptedData);
+            var result = Mono.Security.Cryptography.PKCS1.Decrypt_OAEP (rsa, hash, encryptedData);
+            if (result == null)
+                throw new CryptographicException(Environment.GetResourceString("Cryptography_OAEPDecoding"));
+            return result;
 #else
             int cb = rsa.KeySize / 8;