public ArrayList List; //of CertificateEntry public bool Open(Stream fs) { List = new ArrayList(); try { var intBytes = new byte[4]; while (fs.Position < fs.Length) { var tcert = new CertificateEntry(); fs.Read(intBytes, 0, 4); tcert.SignatureType = (SignatureType)BitConverter.ToInt32(intBytes, 0); // RSA Type switch (tcert.SignatureType) { case SignatureType.RSA_2048_SHA1: case SignatureType.RSA_2048_SHA256: tcert.Signature = new byte[256]; break; case SignatureType.RSA_4096_SHA1: case SignatureType.RSA_4096_SHA256: tcert.Signature = new byte[512]; break; } if (tcert.Signature == null) { break; //this is the end of the certificates } fs.Read(tcert.Signature, 0, tcert.Signature.Length); tcert.Certificate = MarshalUtil.ReadStructBE <Certificate>(fs); List.Add(tcert); } } catch { } return(true); }
public ArrayList List; //of CertificateEntry public bool Open(Stream fs) { List = new ArrayList(); try { var intBytes = new byte[4]; while (fs.Position < fs.Length) { var tcert = new CertificateEntry(); fs.Read(intBytes, 0, 4); tcert.SignatureType = (SignatureType)BitConverter.ToInt32(intBytes, 0); // RSA Type switch (tcert.SignatureType) { case SignatureType.RSA_2048_SHA1: case SignatureType.RSA_2048_SHA256: tcert.Signature = new byte[256]; break; case SignatureType.RSA_4096_SHA1: case SignatureType.RSA_4096_SHA256: tcert.Signature = new byte[512]; break; } if (tcert.Signature == null) break; //this is the end of the certificates fs.Read(tcert.Signature, 0, tcert.Signature.Length); tcert.Certificate = MarshalUtil.ReadStructBE<Certificate>(fs); List.Add(tcert); } } catch { } return true; }