Ejemplo n.º 1
0
        public AsnToBeSignedCertificate()
        {
            version = new AsnInteger(2);

            issuer  = new AsnName();
            subject = new AsnName();

            //issuerUniqueID = new AsnBitstring();
            //issuerUniqueID.contextTag = 1;

            //subjectUniqueID = new AsnBitstring();
            //subjectUniqueID.contextTag = 2;

            //extensions = new AsnExtensions();
            //extensions.contextTag = 3;
        }
Ejemplo n.º 2
0
        public static AsnCertificationRequestInfo Decode(byte[] source, ref int pos)
        {
            AsnCertificationRequestInfo instance = new AsnCertificationRequestInfo();

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

            // get the sequence length
            long len = instance.GetLength(source, ref pos);

            instance.elements.Add(AsnInteger.Decode(source, ref pos));
            instance.elements.Add(AsnName.Decode(source, ref pos));
            instance.elements.Add(AsnPublicKeyInfo.Decode(source, ref pos));
            instance.elements.Add(AsnAttributes.Decode(source, ref pos));

            return(instance);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public static AsnName Decode(byte[] source, ref int pos)
        {
            AsnName instance = new AsnName();

            //CheckContextTag(source, ref pos);

            // skip the 0x30 (SEQUENCE)
            pos++;

            // sequence length
            long length = instance.GetLength(source, ref pos);

            // now we should see a set and length of the set
            long start = pos;

            // decode the set
            while (pos < start + length)
            {
                AsnRelativeDistinguishedName name = AsnRelativeDistinguishedName.Decode(source, ref pos);
                instance.elements.Add(name);
            }

            return(instance);
        }