public bool RSAImport(byte[] exportedkey) { RSAReader reader = new RSAReader(exportedkey); eRSAKeyFormat format = (eRSAKeyFormat)reader.ReadByte(); RSAParam key = new RSAParam(); /* input modulus and exponent*/ key.Modulus = reader.ReadBignum(); key.Exponent = reader.ReadBignum(); if (format == eRSAKeyFormat.PK_PRIVATE_OPTIMIZED || format == eRSAKeyFormat.PK_PRIVATE) { key.D = reader.ReadBignum(); } if (format == eRSAKeyFormat.PK_PRIVATE_OPTIMIZED) { key.DQ = reader.ReadBignum(); key.DP = reader.ReadBignum(); key.pQ = reader.ReadBignum(); key.qP = reader.ReadBignum(); key.P = reader.ReadBignum(); key.Q = reader.ReadBignum(); } //skip version at end of buffer this.ImportParam(key); return(true); }
public bool Import(byte[] exportedkey) { RSAReader reader = new RSAReader(exportedkey); reader.Skip(6); //skip the header ushort len = reader.ReadShort(); reader.Skip(2); //you have the len byte 2 time byte[] key = new byte[len]; reader.Read(key, 0, len); return(RSAImport(key)); }
public bool RSAImport(byte[] exportedkey) { RSAReader reader = new RSAReader(exportedkey); eRSAKeyFormat format =(eRSAKeyFormat)reader.ReadByte(); RSAParam key = new RSAParam(); /* input modulus and exponent*/ key.Modulus = reader.ReadBignum(); key.Exponent = reader.ReadBignum(); if (format == eRSAKeyFormat.PK_PRIVATE_OPTIMIZED || format == eRSAKeyFormat.PK_PRIVATE) { key.D = reader.ReadBignum(); } if (format == eRSAKeyFormat.PK_PRIVATE_OPTIMIZED) { key.DQ = reader.ReadBignum(); key.DP = reader.ReadBignum(); key.pQ = reader.ReadBignum(); key.qP = reader.ReadBignum(); key.P = reader.ReadBignum(); key.Q = reader.ReadBignum(); } //skip version at end of buffer this.ImportParam(key); return true; }
public bool Import(byte[] exportedkey) { RSAReader reader = new RSAReader(exportedkey); reader.Skip(6);//skip the header ushort len = reader.ReadShort(); reader.Skip(2);//you have the len byte 2 time byte[] key = new byte[len]; reader.Read(key,0,len); return (RSAImport(key)); }