static ApplicationWebService() { try { // it works. // can we now wrap rsa for all platforms // and use it as a generic nuget? var sw = Stopwatch.StartNew(); Console.WriteLine("before generateKeyPair " + new { sw.ElapsedMilliseconds }); var keyGen = KeyPairGenerator.getInstance("RSA"); keyGen.initialize(2048); keyPair = keyGen.generateKeyPair(); Console.WriteLine("after generateKeyPair " + new { sw.ElapsedMilliseconds }); // samsung yoga? I/System.Console( 6966): after generateKeyPair {{ ElapsedMilliseconds = 8633 }} // I/System.Console( 7337): after generateKeyPair {{ ElapsedMilliseconds = 11281 }} // should the server do it in a background thread? //before generateKeyPair { { ElapsedMilliseconds = 2 } } //after generateKeyPair { { ElapsedMilliseconds = 1130 } } } catch { throw; } }
static ApplicationWebService() { try { // it works. // can we now wrap rsa for all platforms // and use it as a generic nuget? var sw = Stopwatch.StartNew(); Console.WriteLine("before generateKeyPair " + new { sw.ElapsedMilliseconds }); var keyGen = KeyPairGenerator.getInstance("RSA"); keyGen.initialize(2048); keyPair = keyGen.generateKeyPair(); Console.WriteLine("after generateKeyPair " + new { sw.ElapsedMilliseconds }); //before generateKeyPair { { ElapsedMilliseconds = 2 } } //after generateKeyPair { { ElapsedMilliseconds = 1130 } } } catch { throw; } }
// ctor()? public __RSACryptoServiceProvider(int dwKeySize, CspParameters parameters) { // what if ctor is here for import instead of gen? // X:\jsc.svn\examples\java\hybrid\JVMCLRRSACryptoServiceProviderExport\JVMCLRRSACryptoServiceProviderExport\Program.cs // If this is not a random container we generate, create it eagerly // in the constructor so we can report any errors now. // Environment.GetCompatibilityFlag(CompatibilityFlag.EagerlyGenerateRandomAsymmKeys) // GetKeyPair(); // We only attempt to generate a random key on desktop runtimes because the CoreCLR // RSA surface area is limited to simply verifying signatures. Since generating a // random key to verify signatures will always lead to failure (unless we happend to // win the lottery and randomly generate the signing key ...), there is no need // to add this functionality to CoreCLR at this point. // ? what this.dwKeySize = dwKeySize; this.parameters = parameters; // when would we want to delay key gen? // lets gen it early. // X:\jsc.svn\examples\javascript\appengine\Test\TestCryptoKeyGenerate\TestCryptoKeyGenerate\ApplicationWebService.cs try { // it works. // can we now wrap rsa for all platforms // and use it as a generic nuget? var sw = Stopwatch.StartNew(); Console.WriteLine("RSACryptoServiceProvider before generateKeyPair " + new { dwKeySize }); var keyGen = KeyPairGenerator.getInstance("RSA"); keyGen.initialize(dwKeySize); this.InternalKeyPair = keyGen.generateKeyPair(); this.InternalRSAPublicKey = (RSAPublicKey)this.InternalKeyPair.getPublic(); this.InternalRSAPrivateKey = (RSAPrivateCrtKey)this.InternalKeyPair.getPrivate(); Console.WriteLine("RSACryptoServiceProvider after generateKeyPair " + new { sw.ElapsedMilliseconds }); //before generateKeyPair { { ElapsedMilliseconds = 2 } } //after generateKeyPair { { ElapsedMilliseconds = 1130 } } } catch { throw; } }