G
Guest
Hi,
I already asked the following question in microsoft.public.dotnet.security
but I found out that that group isn't an MSDN Managed Newsgroup.
I show the public and private key stored in a pfx file. The public key
is the same every time I run the program, but the private key isn't.
Can someone explain to me why the private key isn't the same every time
I run the program?
I show the keyexponent and keymodulus of the public key, and the D
parameter of the private key, with the following C# code:
---------------
PfxOpen pfx = new PfxOpen();
String pfxFilename = @"E:\Prototype\Test\Release2\key.pfx";
String password = "geheim";
if(!pfx.LoadPfx(pfxFilename, ref password))
{
throw new Exception("Failed to load pfx");
}
CspParameters cspParameters = new CspParameters();
cspParameters.Flags = CspProviderFlags.UseMachineKeyStore;
cspParameters.KeyContainerName = pfx.container;
RSACryptoServiceProvider rsaCryptoServiceProvider =
new RSACryptoServiceProvider(cspParameters);
RSAParameters rsaParameters =
rsaCryptoServiceProvider.ExportParameters(true);
MessageBox.Show("container: " + pfx.container
+ "\n\n" + "keyexponent: " + ByteArrayToString(pfx.keyexponent)
+ "\n\n" + "keymodulus: " + ByteArrayToString(pfx.keymodulus)
+ "\n\n" + "D: " + ByteArrayToString(rsaParameters.D)
);
---------------
I'm using PfxOpen.cs and win32.cs from
http://msdn.microsoft.com/library/en-us/dncapi/html/pkcs12.asp and I'm
using .NET framework version 1.1.
Cheers,
Bob
I already asked the following question in microsoft.public.dotnet.security
but I found out that that group isn't an MSDN Managed Newsgroup.
I show the public and private key stored in a pfx file. The public key
is the same every time I run the program, but the private key isn't.
Can someone explain to me why the private key isn't the same every time
I run the program?
I show the keyexponent and keymodulus of the public key, and the D
parameter of the private key, with the following C# code:
---------------
PfxOpen pfx = new PfxOpen();
String pfxFilename = @"E:\Prototype\Test\Release2\key.pfx";
String password = "geheim";
if(!pfx.LoadPfx(pfxFilename, ref password))
{
throw new Exception("Failed to load pfx");
}
CspParameters cspParameters = new CspParameters();
cspParameters.Flags = CspProviderFlags.UseMachineKeyStore;
cspParameters.KeyContainerName = pfx.container;
RSACryptoServiceProvider rsaCryptoServiceProvider =
new RSACryptoServiceProvider(cspParameters);
RSAParameters rsaParameters =
rsaCryptoServiceProvider.ExportParameters(true);
MessageBox.Show("container: " + pfx.container
+ "\n\n" + "keyexponent: " + ByteArrayToString(pfx.keyexponent)
+ "\n\n" + "keymodulus: " + ByteArrayToString(pfx.keymodulus)
+ "\n\n" + "D: " + ByteArrayToString(rsaParameters.D)
);
---------------
I'm using PfxOpen.cs and win32.cs from
http://msdn.microsoft.com/library/en-us/dncapi/html/pkcs12.asp and I'm
using .NET framework version 1.1.
Cheers,
Bob