Example #1
0
        public void Serialise(Stream stream, Version version)
        {
            int totalLength = CalculateSize(version);

            NetworkByteOrderConverter.WriteInt24(stream, totalLength - 3);
            switch (_CertificateType)
            {
            case TCertificateType.X509:
                if (_CertChain != null)
                {
                    foreach (byte[] item in _CertChain)
                    {
                        NetworkByteOrderConverter.WriteInt24(stream, item.Length);
                        stream.Write(item, 0, item.Length);
                    }
                }
                break;

            case TCertificateType.OpenPGP:
                break;

            case TCertificateType.RawPublicKey:
                break;

            case TCertificateType.Unknown:
                break;

            default:
                break;
            }
        }
Example #2
0
        public void Serialise(Stream stream, Version version)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            if (version == null)
            {
                throw new ArgumentNullException(nameof(version));
            }

            var totalLength = this.CalculateSize(version);

            NetworkByteOrderConverter.WriteInt24(stream, totalLength - 3);
            switch (this.CertificateType)
            {
            case TCertificateType.X509:
            {
                if (this.CertChain != null)
                {
                    foreach (var item in this.CertChain)
                    {
                        NetworkByteOrderConverter.WriteInt24(stream, item.Length);
                        stream.Write(item, 0, item.Length);
                    }
                }
                break;
            }

            case TCertificateType.OpenPGP:
            case TCertificateType.RawPublicKey:
            case TCertificateType.Unknown:
            {
                throw new NotImplementedException();
            }

            default:
            {
                break;
            }
            }
        }