E
Eric
Hello,
I am wanting to serialize (for storage of an RSA Keypair) a RSAParameters
class. It seems that even if i export the private portions of the Key, they
are never serialized and stored in the file. Only the public portions of the
key are (you can see this by opening up the serialtest.xml file written).
My question is: Am I just missing something very simple here or do I have to
write a custom class to turn a RSAParameters into a completely serializable
one?
I might have to do the second one anyways, so its not a big deal if I have
to (gotta encrypt the private portions of the key, would make sense to just
support this in its class) but if I really have to, id like to understand
why its doing this the way it is.
Ive been using C# for a while, but I have not used serialization yet. so I
might just be missing something.
Thank you for your time, and any ideas you can offer =]
eric.h
Example Code:
Console.WriteLine("testing serialization...");
Stream fs = new
FileStream("serialtest.xml",FileMode.Create,FileAccess.ReadWrite);
IFormatter formatter = new SoapFormatter();
RSAParameters rsap = BobRSA.ExportParameters(true); //we want the private
portions
formatter.Serialize(fs,rsap); //rsap.D is set, along with all private key
portions
fs.Close();
//deserialize
Stream nfs = new FileStream("serialtest.xml",FileMode.Open,FileAccess.Read);
IFormatter defmt = new SoapFormatter();
RSAParameters rp = (RSAParameters)defmt.Deserialize(nfs);
BobRSA.ImportParameters(rp); // rp.D is null, all private portions are.
public Exponet and modulus is set properly
nfs.Close();
I am wanting to serialize (for storage of an RSA Keypair) a RSAParameters
class. It seems that even if i export the private portions of the Key, they
are never serialized and stored in the file. Only the public portions of the
key are (you can see this by opening up the serialtest.xml file written).
My question is: Am I just missing something very simple here or do I have to
write a custom class to turn a RSAParameters into a completely serializable
one?
I might have to do the second one anyways, so its not a big deal if I have
to (gotta encrypt the private portions of the key, would make sense to just
support this in its class) but if I really have to, id like to understand
why its doing this the way it is.
Ive been using C# for a while, but I have not used serialization yet. so I
might just be missing something.
Thank you for your time, and any ideas you can offer =]
eric.h
Example Code:
Console.WriteLine("testing serialization...");
Stream fs = new
FileStream("serialtest.xml",FileMode.Create,FileAccess.ReadWrite);
IFormatter formatter = new SoapFormatter();
RSAParameters rsap = BobRSA.ExportParameters(true); //we want the private
portions
formatter.Serialize(fs,rsap); //rsap.D is set, along with all private key
portions
fs.Close();
//deserialize
Stream nfs = new FileStream("serialtest.xml",FileMode.Open,FileAccess.Read);
IFormatter defmt = new SoapFormatter();
RSAParameters rp = (RSAParameters)defmt.Deserialize(nfs);
BobRSA.ImportParameters(rp); // rp.D is null, all private portions are.
public Exponet and modulus is set properly
nfs.Close();