/** * Parse a {@link Certificate} from a {@link Stream}. * * @param input the {@link Stream} to parse from. * @return a {@link Certificate} object. * @throws IOException */ public static Certificate Parse(Stream input) { int totalLength = TlsUtilities.ReadUint24(input); if (totalLength == 0) { return(EmptyChain); } byte[] certListData = TlsUtilities.ReadFully(totalLength, input); MemoryStream buf = new MemoryStream(certListData, false); IList certificate_list = Platform.CreateArrayList(); while (buf.Position < buf.Length) { byte[] derEncoding = TlsUtilities.ReadOpaque24(buf); Asn1Object asn1Cert = TlsUtilities.ReadDerObject(derEncoding); certificate_list.Add(X509CertificateStructure.GetInstance(asn1Cert)); } X509CertificateStructure[] certificateList = new X509CertificateStructure[certificate_list.Count]; for (int i = 0; i < certificate_list.Count; ++i) { certificateList[i] = (X509CertificateStructure)certificate_list[i]; } return(new Certificate(certificateList)); }
public static Certificate Parse(Stream input) { int num = TlsUtilities.ReadUint24(input); if (num == 0) { return(EmptyChain); } byte[] buffer = TlsUtilities.ReadFully(num, input); MemoryStream memoryStream = new MemoryStream(buffer, writable: false); IList list = Platform.CreateArrayList(); while (memoryStream.Position < memoryStream.Length) { byte[] encoding = TlsUtilities.ReadOpaque24(memoryStream); Asn1Object obj = TlsUtilities.ReadDerObject(encoding); list.Add(X509CertificateStructure.GetInstance(obj)); } X509CertificateStructure[] array = new X509CertificateStructure[list.Count]; for (int i = 0; i < list.Count; i++) { array[i] = (X509CertificateStructure)list[i]; } return(new Certificate(array)); }
public static CertificateStatus Parse(Stream input) { byte b = TlsUtilities.ReadUint8(input); byte b2 = b; if (b2 == 1) { byte[] encoding = TlsUtilities.ReadOpaque24(input); object instance = OcspResponse.GetInstance(TlsUtilities.ReadDerObject(encoding)); return(new CertificateStatus(b, instance)); } throw new TlsFatalAlert(50); }
protected internal static IList ReadSupplementalDataMessage(MemoryStream input) { byte[] buffer = TlsUtilities.ReadOpaque24(input); AssertEmpty(input); MemoryStream memoryStream = new MemoryStream(buffer, writable: false); IList list = Platform.CreateArrayList(); while (memoryStream.Position < memoryStream.Length) { int dataType = TlsUtilities.ReadUint16(memoryStream); byte[] data = TlsUtilities.ReadOpaque16(memoryStream); list.Add(new SupplementalDataEntry(dataType, data)); } return(list); }
/** * Parse a {@link CertificateStatus} from a {@link Stream}. * * @param input * the {@link Stream} to parse from. * @return a {@link CertificateStatus} object. * @throws IOException */ public static CertificateStatus Parse(Stream input) { byte status_type = TlsUtilities.ReadUint8(input); object response; switch (status_type) { case CertificateStatusType.ocsp: { byte[] derEncoding = TlsUtilities.ReadOpaque24(input); response = OcspResponse.GetInstance(TlsUtilities.ReadDerObject(derEncoding)); break; } default: throw new TlsFatalAlert(AlertDescription.decode_error); } return(new CertificateStatus(status_type, response)); }