Exemplo n.º 1
0
        public static void SequenceStackOverflow()
        {
            var writer = new Asn1Writer(new byte[2], 3);

            writer.End();
            writer.End();
            writer.End();
            try { writer.End(); Assert.True(false); } catch (IndexOutOfRangeException) { } // cannot use Assert.Throws
        }
Exemplo n.º 2
0
 internal override void WriteAlgorithmIdentifier(
     ref Asn1Writer writer,
     ReadOnlySpan <byte> nonce)
 {
     writer.End();
     writer.End();
     writer.OctetString(nonce);
     writer.BeginSequence();
     writer.ObjectIdentifier(s_oid.Bytes);
     writer.BeginSequence();
 }
Exemplo n.º 3
0
        public static void IntegerSequence(int[] values, byte[] expected)
        {
            var writer = new Asn1Writer(new byte[expected.Length]);

            writer.End();
            for (var i = 0; i < values.Length; i++)
            {
                writer.Integer(values[values.Length - i - 1]);
            }
            writer.BeginSequence();
            Assert.Equal(expected, writer.Bytes.ToArray());
        }
Exemplo n.º 4
0
        public static void Sequence(int depth, byte[] expected)
        {
            var writer = new Asn1Writer(new byte[expected.Length]);

            for (var i = 0; i < depth; i++)
            {
                writer.End();
            }
            for (var i = 0; i < depth; i++)
            {
                writer.BeginSequence();
            }
            Assert.Equal(expected, writer.Bytes.ToArray());
        }
Exemplo n.º 5
0
        public static void SequenceStackOverflow()
        {
            Assert.Equal(6, Asn1Writer.MaxDepth);
            var writer = new Asn1Writer(new byte[2]);

            writer.End();
            writer.End();
            writer.End();
            writer.End();
            writer.End();
            writer.End();
            try { writer.End(); Assert.True(false); } catch (InvalidOperationException) { } // cannot use Assert.Throws
        }