DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Mon, 30 Jul 2007 00:01:29 -0700,    posted on: microsoft.public.dotnet.security        back       

Thread Index
  1    floppyzedolfin


First call to RSAParam.export very slow   
Hello.
I'm working in Visual Studio, language is C#, and I am coding a
cryptography program.
At some point, I need random values, and rather than using a made-for-
it random generator, I use the first bytes of
RSACryptoServiceProvider.ExportParameters(false).Modulus.

The reason for that is just that I also have a call to that
RSACryptoServiceProvider.ExportParameters(false) further on, and my
problem is that the first call to
RSACryptoServiceProvider.ExportParameters(false) is excessivly slow
(it's in a range of 5 secs to 120 secs), whereas all furtherer calls
are fast (less than 20 ms)

Could there be a reason for that, and could it be avoided?


Here's a part of the code I use :


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

namespace My_Project
{
class My_Class
{
static void Main() {

  RSACryptoServiceProvider RSACrypto = new
RSACryptoServiceProvider(4096);

  byte[] My_Hash = new byte[20];
  My_Hash[0] = RSACrypto.ExportParameters(false).Modulus[0];  //this
line takes 20 secs, even if it's included inside the loop
  for(int i=1; i<20; i++)  // this  loop is fast enough to be
performed in less than 0.5 sec
  {
    My_Hash[i] = RSACrypto.ExportParameters(false).Modulus[i];
  }
  /* blah blah blah */
  // do things such as encrypt(data,
RSACrypto.ExportParameters(false));
}
}
}

A few words about that : it's not the entire code, so don't be afraid
of the uselessness of those lines; and, yes, I could've written the
RSACrypto.ExportParameters(false).Modulus into a buffer, but that's
not the point I want to emphatize on right now (since it will not skip
that first call)

Thanks.
Date:Mon, 30 Jul 2007 00:01:29 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us