예제 #1
0
        public static AsnToBeSignedCertificate Decode(byte[] source, ref int pos)
        {
            AsnToBeSignedCertificate instance = new AsnToBeSignedCertificate();

            //instance.CheckContextTag(source, ref pos);
            pos++;

            int len = instance.GetLength(source, ref pos);

            // peek into the next byte to see if we have an explicit tag (should be there)
            if (source[pos] == 0xa0)
            {
                pos++;
                len = instance.GetLength(source, ref pos);
            }

            instance.version       = AsnInteger.Decode(source, ref pos);
            instance.serialNumber  = AsnInteger.Decode(source, ref pos);
            instance.signature     = AsnAlgorithmIdentifier.Decode(source, ref pos);
            instance.issuer        = AsnName.Decode(source, ref pos);
            instance.validity      = AsnValidity.Decode(source, ref pos);
            instance.subject       = AsnName.Decode(source, ref pos);
            instance.subjectPKInfo = AsnPublicKeyInfo.Decode(source, ref pos);

            if (source[pos] == 0xa1)
            {
                pos++;
                instance.GetLength(source, ref pos);
                instance.issuerUniqueID = AsnBitstring.Decode(source, ref pos);
            }
            if (source[pos] == 0xa2)
            {
                pos++;
                instance.GetLength(source, ref pos);
                instance.subjectUniqueID = AsnBitstring.Decode(source, ref pos);
            }
            if (source[pos] == 0xa3)
            {
                pos++;
                instance.GetLength(source, ref pos);
                instance.extensions = AsnExtensions.Decode(source, ref pos);
            }

            return(instance);
        }
예제 #2
0
        public static AsnValidity Decode(byte[] source, ref int pos)
        {
            AsnValidity instance = new AsnValidity();

            int start = pos;

            pos++;

            int len = instance.GetLength(source, ref pos);

            instance.notBefore = AsnGeneralizedTime.Decode(source, ref pos);
            instance.notAfter  = AsnGeneralizedTime.Decode(source, ref pos);

            instance.originalDer = new byte[pos - start];
            Array.Copy(source, start, instance.originalDer, 0, pos - start);

            return(instance);
        }