We have this business case where our c# web app will generate a public/private key pair for a corresponding iOS mobile device. The mobile device will use the public key to encrypt data and send it back up to the server.
I am using the following c# code.
const int PROVIDER_RSA_FULL = 1;
const string CONTAINER_NAME = "KeyContainer";
CspParameters cspParams;
cspParams = new CspParameters(PROVIDER_RSA_FULL);
cspParams.KeyContainerName = CONTAINER_NAME;
cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
cspParams.ProviderName = "Microsoft Strong Cryptographic Provider";
var rsa = new RSACryptoServiceProvider(2048,cspParams);
rsa.PersistKeyInCsp = false;
string publicPrivateKeyXML = rsa.ToXmlString(true);
After that, I don't know how to get the rsa.ToXmlString to the iOS app in a format it can support with the objective-c Crypto Libraries. How can I covert that public key (modulus +exponent) WITHOUT using OpenSSL to something iOS will understand and encrypt data with. This key generation will happen a lot (not once), and any new library has to approved before use. So answers that don't require additional libraries are favored.