/// <inheritdoc />
        public override Byte[] Encode()
        {
            var builder = new Asn1Builder()
                          .AddInteger(Version)
                          .AddDerData(RequestMessage.Encode());

            if (PolicyID != null)
            {
                builder.AddObjectIdentifier(PolicyID);
            }
            if (UseNonce)
            {
                nonce = Guid.NewGuid().ToByteArray();
                builder.AddInteger(new BigInteger(nonce));
            }
            else
            {
                nonce = default;
            }
            if (RequestCertificates)
            {
                builder.AddBoolean(RequestCertificates);
            }
            if (_extensions.Any())
            {
                builder.AddExplicit(0, Extensions.Encode(), false);
            }

            return(builder.GetEncoded());
        }
Example #2
0
 public void Encode()
 {
     Message.Encode(Buffer.Span);
 }
Example #3
0
 public MessageEncoder()
 {
     Message = new RequestMessage(1, 2, 3);
     Buffer  = new Memory <byte> (new byte[20]);
     Message.Encode(Buffer.Span);
 }