using System; using System.IO; namespace Org.BouncyCastle.Tls { public sealed class CertificateVerify { private readonly int m_algorithm; private readonly byte[] m_signature; public CertificateVerify(int algorithm, byte[] signature) { if (!TlsUtilities.IsValidUint16(algorithm)) throw new ArgumentException("algorithm"); if (signature == null) throw new ArgumentNullException("signature"); this.m_algorithm = algorithm; this.m_signature = signature; } /// a value. public int Algorithm { get { return m_algorithm; } } public byte[] Signature { get { return m_signature; } } /// Encode this to a . /// the to encode to. /// public void Encode(Stream output) { TlsUtilities.WriteUint16(m_algorithm, output); TlsUtilities.WriteOpaque16(m_signature, output); } /// Parse a from a . /// the of the current connection. /// the to parse from. /// a object. /// public static CertificateVerify Parse(TlsContext context, Stream input) { if (!TlsUtilities.IsTlsV13(context)) throw new InvalidOperationException(); int algorithm = TlsUtilities.ReadUint16(input); byte[] signature = TlsUtilities.ReadOpaque16(input); return new CertificateVerify(algorithm, signature); } } }