Search Issue Tracker

Fixed in 5.0.1

Votes

4

Found in

5.0.0f4

Issue ID

677985

Regression

Yes

IL2CPP: RSACryptoServiceProvider doesn't work

Scripting

-

-e: The RSACryptoServiceProvider class seems broken on the IL2CPP backend.

-repro:
--open attached project
--build&run TestScene for iOS with IL2CPP
--NOTICE exceptions being loggedin xcode (see below) and test not working
--work fine with Mono

-test:

public static void SimpleTest()
{
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(1024);
RSAParameters publicKey = rsa.ExportParameters(false);

string name = "SimpleTest";
byte[] unencrypted = Encoding.UTF8.GetBytes(name);
RSACryptoServiceProvider remoteRSA = new RSACryptoServiceProvider();
remoteRSA.ImportParameters(publicKey);
byte[] encrypted = remoteRSA.Encrypt(unencrypted, false);

byte[] decryptedPacket = rsa.Decrypt(encrypted, false);
name = Encoding.UTF8.GetString(decryptedPacket);
Debug.Log("Decrypted message = " + name);
}

-errors:

2015-03-06 12:24:05.470 dark[2126:1187099] -> registered mono modules 0x100f32d60
-> applicationDidFinishLaunching()
-> applicationDidBecomeActive()
Requesting Resolution: 2048x1536
Init: screen size 2048x1536
Initializing Metal device caps
Initialize engine version: 5.0.0f4 (5b98b70ebeb9)
CryptographicException: PKCS1 decoding error.
at System.Security.Cryptography.HashAlgorithm.ComputeHash (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0
at System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter.SetKey (System.Security.Cryptography.AsymmetricAlgorithm key) [0x00000] in <filename unknown>:0
at System.Globalization.GregorianCalendar.GetYear (DateTime time) [0x00000] in <filename unknown>:0
at System.Security.Cryptography.RSACryptoServiceProvider.Decrypt (System.Byte[] rgb, Boolean fOAEP) [0x00000] in <filename unknown>:0
at RSATest.SimplerTest () [0x00000] in <filename unknown>:0
at RSATest.Start () [0x00000] in <filename unknown>:0
at Replacements.MSCompatUnicodeTable.get_IsReady () [0x00000] in <filename unknown>:0
Replacements.MSCompatUnicodeTable:get_IsReady()

(Filename: currently not available on il2cpp Line: -1)

Add comment

Log in to post comment