Esempio n. 1
0
        public static AsnCertificationRequest Decode(byte[] source, ref int pos)
        {
            AsnCertificationRequest instance = new AsnCertificationRequest();

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

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

            instance.elements.Add(AsnCertificationRequestInfo.Decode(source, ref pos));
            instance.elements.Add(AsnAlgorithmIdentifier.Decode(source, ref pos));
            instance.elements.Add(AsnBitstring.Decode(source, ref pos));

            return(instance);
        }
Esempio n. 2
0
        public static AsnCertificate Decode(byte[] source, ref int pos)
        {
            AsnCertificate instance = new AsnCertificate();

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

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

            instance.elements.Add(AsnToBeSignedCertificate.Decode(source, ref pos));
            instance.elements.Add(AsnAlgorithmIdentifier.Decode(source, ref pos));
            instance.elements.Add(AsnBitstring.Decode(source, ref pos));

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

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

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

            instance.algorithm = AsnAlgorithmIdentifier.Decode(source, ref pos);
            instance.publicKey = AsnBitstring.Decode(source, ref pos);

            // TODO: further decode publicKey into AsnKeyPair
            int bi = 0;

            instance.keys = AsnPrivateKeyPair.Decode(instance.publicKey.value, ref bi);

            return(instance);
        }