ok, after doing some shamanic dances with tambourine i've come to somewhat-satisfying solution. please hold in mind, that it is all done in context of working with PHP's openssl_private_decrypt() function.
so i got next:
encryption of BouncyCastle just doing it not right
i don't know how to get modulus out of private key to use it with RSACryptoServiceProvider
why not try to use BouncyCastle's key data and initialize RSACryptoServiceProvider
Object obj; using (TextReader sr = new StringReader(publicKey)) { PemReader pem = new PemReader(sr); obj = pem.ReadObject(); } var par = obj as Org.BouncyCastle.Crypto.Parameters.RsaKeyParameters; RSACryptoServiceProvider csp = new RSACryptoServiceProvider(1024); //var pp = csp.ExportParameters(false); //works on native .NET, doesn't work on monotouch var pp = new RSAParameters(); pp.Modulus = par.Modulus.ToByteArrayUnsigned(); //doesn't work with ToByteArray() pp.Exponent = par.Exponent.ToByteArrayUnsigned(); csp.ImportParameters(pp); var cspBytes = csp.Encrypt(bytes, false);
actually, it is strange that i've came up with solution at all, cuz of these niceties. i hope it would be helpful for someone someday.