Bug 18482 - RSA - Import Public Key Bug
Summary: RSA - Import Public Key Bug
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Security ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
Depends on:
Reported: 2014-03-19 20:32 UTC by Craig
Modified: 2014-07-09 23:21 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 18482 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Craig 2014-03-19 20:32:14 UTC
This code is broken on Xamarin Android:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace Vectren.Mobile.Shared
    public class RsaCipherUtil
        public string Encrypt(string value)
            using (var rsa = new RSACryptoServiceProvider())
                rsa.PersistKeyInCsp = false;
                var param = rsa.ExportParameters(false);
                param.Modulus = Convert.FromBase64String("kGpIwe0ldtQHjp8BEveMlavqS9BC8OevECam3jpuR6xiKZX7IvI+uaPz8ptTrzUZ2nUpv1IihsKZGEGRuYHSVMypnGyjzY7+44rwHhgTlEFQATAXSAL/Zfn5MZ70Bd5JRd3WUA+eh5zS6hcXewWOcM1v2YFDyhbH4SVU5oV53r3mNleFwgTY/g05BSuVGIhHwntKGdCNoTP1tOmACFCyJnupKf+AgPh6/pDsF2yYoltVTEYjHU8oRxHU+spZQpbeM3K+bXFjZONroV1jJJXda9x/95go4vTvVp5suCDmxAxZejpFTLq0/EiT50vVTzFMl7oEw3EZ3rbTbtu11iUzzw==");
                param.Exponent = Convert.FromBase64String("AQAB");
                param.D = null;
                param.DP = null;
                param.DQ = null;
                param.InverseQ = null;
                param.P = null;
                param.Q = null;

                byte[] result = rsa.Encrypt(Encoding.UTF8.GetBytes(value), false);
                return Convert.ToBase64String(result);
Comment 2 marcos.henrich 2014-05-29 13:45:38 UTC
Hi Craig,

Thanks for the detailed bug report.
A pull request for this issue can be found in the link below.