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.WriteLi ne("testing serialization.. .");
Stream fs = new
FileStream("ser ialtest.xml",Fi leMode.Create,F ileAccess.ReadW rite);
IFormatter formatter = new SoapFormatter() ;
RSAParameters rsap = BobRSA.ExportPa rameters(true); //we want the private
portions
formatter.Seria lize(fs,rsap); //rsap.D is set, along with all private key
portions
fs.Close();
//deserialize
Stream nfs = new FileStream("ser ialtest.xml",Fi leMode.Open,Fil eAccess.Read);
IFormatter defmt = new SoapFormatter() ;
RSAParameters rp = (RSAParameters) defmt.Deseriali ze(nfs);
BobRSA.ImportPa rameters(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.WriteLi ne("testing serialization.. .");
Stream fs = new
FileStream("ser ialtest.xml",Fi leMode.Create,F ileAccess.ReadW rite);
IFormatter formatter = new SoapFormatter() ;
RSAParameters rsap = BobRSA.ExportPa rameters(true); //we want the private
portions
formatter.Seria lize(fs,rsap); //rsap.D is set, along with all private key
portions
fs.Close();
//deserialize
Stream nfs = new FileStream("ser ialtest.xml",Fi leMode.Open,Fil eAccess.Read);
IFormatter defmt = new SoapFormatter() ;
RSAParameters rp = (RSAParameters) defmt.Deseriali ze(nfs);
BobRSA.ImportPa rameters(rp); // rp.D is null, all private portions are.
public Exponet and modulus is set properly
nfs.Close();
Comment