public static AsnToBeSignedCertificate FromRequest(AsnCertificationRequest request)
        {
            AsnToBeSignedCertificate tbsCert = new AsnToBeSignedCertificate
            {
                subject       = request.requestInfo.subject,
                subjectPKInfo = request.requestInfo.subjectPKInfo
            };

            // TODO: fill in the rest

            return(tbsCert);
        }
示例#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);
        }
示例#4
0
 public AsnCertificate(AsnToBeSignedCertificate tbs)
 {
     elements.Add(tbs);
     elements.Add(new AsnAlgorithmIdentifier());
     elements.Add(new AsnBitstring());
 }