Пример #1
0
        public override void Decode
            (Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength)
        {
            int llen = (explicitTagging) ?
                       MatchTag(buffer, Asn1Tag.Sequence) : implicitLength;

            Init();

            // decode SEQUENCE

            Asn1BerDecodeContext context =
                new Asn1BerDecodeContext(buffer, llen);

            IntHolder elemLen = new IntHolder();

            // decode algorithm

            if (context.MatchElemTag(Asn1Tag.Universal, Asn1Tag.CONS, 16, elemLen, false))
            {
                algorithm = new AlgorithmIdentifier();
                algorithm.Decode(buffer, true, elemLen.Value);
            }
            else
            {
                throw new Exception("Asn1MissingRequiredException (buffer)");
            }

            // decode subjectPublicKey

            if (context.MatchElemTag(Asn1Tag.Universal, Asn1Tag.PRIM, 3, elemLen, false))
            {
                subjectPublicKey = new Asn1BitString();
                subjectPublicKey.Decode(buffer, true, elemLen.Value);
            }
            else
            {
                throw new Exception("Asn1MissingRequiredException (buffer)");
            }
        }