Beispiel #1
0
        void decodeCms(Asn1Reader asn)
        {
            asn.MoveNextAndExpectTags(48, (Byte)Asn1Type.OBJECT_IDENTIFIER);
            if (asn.Tag == 48)
            {
                Status = new TspStatusInfo(asn.GetTagRawData());
                if (Status.ResponseStatus != TspResponseStatus.Granted && Status.ResponseStatus != TspResponseStatus.GrantedWithModifications)
                {
                    return;
                }
                asn.MoveNextCurrentLevelAndExpectTags(48);
            }
            else
            {
                asn.MoveToPosition(0);
            }
            signedCms = new DefaultSignedPkcs7(asn.GetTagRawData());

            ResponseType = signedCms.ContentType;
            switch (ResponseType.Value)
            {
            // TimeStamp Token
            case "1.2.840.113549.1.9.16.1.4":
                decodeTstInfo(new Asn1Reader(signedCms.Content));
                break;

            // PKCS 7 DATA
            case "1.2.840.113549.1.7.1":
                break;
            }
            getSigningTime();
            _rawData.AddRange(asn.GetRawData());
            validate();
        }
Beispiel #2
0
        void decode(Byte[] rawData)
        {
            reset();
            _rawData.AddRange(rawData);
            cms = new DefaultSignedPkcs7(rawData);
            if (cms.ContentType.Value != ctlOid.Value)
            {
                throw new ArgumentException("Decoded data is not valid certificate trust list.");
            }
            var asn = new Asn1Reader(Asn1Utils.Encode(cms.Content, 48));

            asn.MoveNextAndExpectTags(48);
            decodeUsages(asn);
            Boolean reachedEnd = false;

            while (asn.MoveNextCurrentLevel())
            {
                if (reachedEnd)
                {
                    break;
                }
                switch (asn.Tag)
                {
                case (Byte)Asn1Type.OCTET_STRING:
                    decodeListIdentifier(asn);
                    break;

                case (Byte)Asn1Type.INTEGER:
                    decodeSequenceNumber(asn);
                    break;

                case (Byte)Asn1Type.UTCTime:
                case (Byte)Asn1Type.GeneralizedTime:
                    decodeValidity(asn);
                    reachedEnd = true;
                    break;

                default:
                    reachedEnd = true;
                    break;
                }
            }
            decodeAlgId(asn);
            asn.MoveNextCurrentLevel();
            decodeEntries(asn);
            if (asn.MoveNextCurrentLevel())
            {
                decodeExtensions(asn);
            }
        }