public static Extension Deserialise(Stream stream, bool client) { Extension result = null; if (stream.Position < stream.Length) { result = new Extension(); result._ExtensionType = (TExtensionType)NetworkByteOrderConverter.ToUInt16(stream); ushort length = NetworkByteOrderConverter.ToUInt16(stream); if (length > 0) { if (result._ExtensionType == TExtensionType.EllipticCurves) { result._SpecifcExtension = EllipticCurvesExtension.Deserialise(stream); } else if (result._ExtensionType == TExtensionType.ClientCertificateType) { result._SpecifcExtension = ClientCertificateTypeExtension.Deserialise(stream, client); } else if (result._ExtensionType == TExtensionType.ServerCertificateType) { result._SpecifcExtension = ServerCertificateTypeExtension.Deserialise(stream, client); } else if (result._ExtensionType == TExtensionType.SignatureAlgorithms) { result._SpecifcExtension = SignatureAlgorithmsExtension.Deserialise(stream); } else { result._Data = new byte[length]; stream.Read(result._Data, 0, length); } } } return result; }
public void AddExtension(IExtension extension) { if (_Extensions == null) { _Extensions = new Extensions(); } Extension item = new Extension(); item.ExtensionType = extension.ExtensionType; item.SpecifcExtension = extension; _Extensions.Add(item); }