Example #1
0
        void decode(Byte[] rawData)
        {
            var asn = new Asn1Reader(rawData);

            asn.MoveNext();
            Version = (Int32)Asn1Utils.DecodeInteger(asn.GetTagRawData());
            asn.MoveNextCurrentLevel();
            Issuer = new PkcsSubjectIdentifier(asn.GetTagRawData());
            asn.MoveNextCurrentLevel();
            HashAlgorithm = new AlgorithmIdentifier(asn.GetTagRawData());
            asn.MoveNextCurrentLevel();
            if (asn.Tag == 0xa0)
            {
                _authAttributes.Decode(asn.GetTagRawData());
                asn.MoveNextCurrentLevel();
            }
            EncryptedHashAlgorithm = new AlgorithmIdentifier(asn.GetTagRawData());
            asn.MoveNextCurrentLevel();
            EncryptedHash = asn.GetPayload();
            if (asn.MoveNextCurrentLevel() && asn.Tag == 0xa1)
            {
                _unauthAttributes.Decode(asn.GetTagRawData());
            }
            _rawData.AddRange(rawData);
        }
        void decode(Byte[] rawData)
        {
            var asn = new Asn1Reader(rawData);

            asn.MoveNextAndExpectTags((Byte)Asn1Type.OCTET_STRING);
            Thumbprint = AsnFormatter.BinaryToString(asn.GetPayload(), format: EncodingFormat.NOCRLF, forceUpperCase: true);
            // check if there are attributes
            if (asn.MoveNext() && asn.Tag == 49)
            {
                Byte[] attrBytes = asn.GetTagRawData();
                // in CTL attributes are encoded as SET, but we need SEQUENCE, so change first byte to SEQUENCE (48)
                attrBytes[0] = 48;
                var attributes = new X509AttributeCollection();
                // decode attributes into collection
                attributes.Decode(attrBytes);
                // and then add decoded attributes to internal list.
                _attributes.AddRange(attributes);
            }
        }