Exemplo n.º 1
0
        public Asn1OctetString GetMac()
        {
            if (nextObject == null)
            {
                nextObject = seq.ReadObject();
            }

            IAsn1Convertible o = nextObject;

            nextObject = null;

            return(Asn1OctetString.GetInstance(o.ToAsn1Object()));
        }
Exemplo n.º 2
0
 public ContentInfoParser GetEnapsulatedContentInfo()
 {
     if (nextObject == null)
     {
         nextObject = seq.ReadObject();
     }
     if (nextObject != null)
     {
         Asn1SequenceParser asn1SequenceParser = (Asn1SequenceParser)nextObject;
         nextObject = null;
         return(new ContentInfoParser(asn1SequenceParser));
     }
     return(null);
 }
Exemplo n.º 3
0
 public AlgorithmIdentifier GetDigestAlgorithm()
 {
     if (nextObject == null)
     {
         nextObject = seq.ReadObject();
     }
     if (nextObject is Asn1TaggedObjectParser)
     {
         AlgorithmIdentifier instance = AlgorithmIdentifier.GetInstance((Asn1TaggedObject)nextObject.ToAsn1Object(), explicitly: false);
         nextObject = null;
         return(instance);
     }
     return(null);
 }
        public Asn1SetParser GetCertificates()
        {
            _nextObject = _seq.ReadObject();

            if (_nextObject is Asn1TaggedObject && ((Asn1TaggedObject)_nextObject).TagNo == 0)
            {
                Asn1SetParser certs = (Asn1SetParser)((Asn1TaggedObject)_nextObject).GetObjectParser(Asn1Tags.Set, false);
                _nextObject = null;

                return(certs);
            }

            return(null);
        }
Exemplo n.º 5
0
 public AlgorithmIdentifier GetDigestAlgorithm()
 {
     if (this.nextObject == null)
     {
         this.nextObject = this.seq.ReadObject();
     }
     if (this.nextObject is Asn1TaggedObjectParser)
     {
         AlgorithmIdentifier instance = AlgorithmIdentifier.GetInstance((Asn1TaggedObject)this.nextObject.ToAsn1Object(), false);
         this.nextObject = null;
         return(instance);
     }
     return(null);
 }
Exemplo n.º 6
0
 public EncryptedContentInfoParser GetEncryptedContentInfo()
 {
     if (this._nextObject == null)
     {
         this._nextObject = this._seq.ReadObject();
     }
     if (this._nextObject != null)
     {
         Asn1SequenceParser seq = (Asn1SequenceParser)this._nextObject;
         this._nextObject = null;
         return(new EncryptedContentInfoParser(seq));
     }
     return(null);
 }
Exemplo n.º 7
0
        public Asn1SetParser GetCertificates()
        {
            _nextObject = _seq.ReadObject();

            if (_nextObject is Asn1TaggedObject && ((Asn1TaggedObject)_nextObject).TagNo == 0)
            {
                Asn1SetParser certs = (Asn1SetParser)((Asn1TaggedObject)_nextObject).GetObjectParser(Asn1Tags.Set, false);
                _nextObject = null;

                return certs;
            }

            return null;
        }
Exemplo n.º 8
0
 public AlgorithmIdentifier GetMacAlgorithm()
 {
     if (nextObject == null)
     {
         nextObject = seq.ReadObject();
     }
     if (nextObject != null)
     {
         Asn1SequenceParser asn1SequenceParser = (Asn1SequenceParser)nextObject;
         nextObject = null;
         return(AlgorithmIdentifier.GetInstance(asn1SequenceParser.ToAsn1Object()));
     }
     return(null);
 }
Exemplo n.º 9
0
 public Asn1SetParser GetUnauthAttrs()
 {
     if (nextObject == null)
     {
         nextObject = seq.ReadObject();
     }
     if (nextObject != null)
     {
         IAsn1Convertible asn1Convertible = nextObject;
         nextObject = null;
         return((Asn1SetParser)((Asn1TaggedObjectParser)asn1Convertible).GetObjectParser(17, isExplicit: false));
     }
     return(null);
 }
Exemplo n.º 10
0
 public Asn1SetParser GetUnauthAttrs()
 {
     if (this.nextObject == null)
     {
         this.nextObject = this.seq.ReadObject();
     }
     if (this.nextObject != null)
     {
         IAsn1Convertible asn1Convertible = this.nextObject;
         this.nextObject = null;
         return((Asn1SetParser)((Asn1TaggedObjectParser)asn1Convertible).GetObjectParser(17, false));
     }
     return(null);
 }
Exemplo n.º 11
0
 public Asn1SetParser GetUnprotectedAttrs()
 {
     if (this._nextObject == null)
     {
         this._nextObject = this._seq.ReadObject();
     }
     if (this._nextObject != null)
     {
         IAsn1Convertible nextObject = this._nextObject;
         this._nextObject = null;
         return((Asn1SetParser)((Asn1TaggedObjectParser)nextObject).GetObjectParser(17, false));
     }
     return(null);
 }
Exemplo n.º 12
0
 public Asn1SetParser GetUnprotectedAttrs()
 {
     if (_nextObject == null)
     {
         _nextObject = _seq.ReadObject();
     }
     if (_nextObject != null)
     {
         IAsn1Convertible nextObject = _nextObject;
         _nextObject = null;
         return((Asn1SetParser)((Asn1TaggedObjectParser)nextObject).GetObjectParser(17, isExplicit: false));
     }
     return(null);
 }
Exemplo n.º 13
0
    private ContentHints(Asn1Sequence seq)
    {
        IAsn1Convertible asn1Convertible = seq[0];

        if (asn1Convertible.ToAsn1Object() is DerUtf8String)
        {
            contentDescription = DerUtf8String.GetInstance(asn1Convertible);
            contentType        = DerObjectIdentifier.GetInstance(seq[1]);
        }
        else
        {
            contentType = DerObjectIdentifier.GetInstance(seq[0]);
        }
    }
Exemplo n.º 14
0
 public EncryptedContentInfoParser GetAuthEncryptedContentInfo()
 {
     if (nextObject == null)
     {
         nextObject = seq.ReadObject();
     }
     if (nextObject != null)
     {
         Asn1SequenceParser asn1SequenceParser = (Asn1SequenceParser)nextObject;
         nextObject = null;
         return(new EncryptedContentInfoParser(asn1SequenceParser));
     }
     return(null);
 }
        public static T CheckObject <T>(IAsn1Convertible obj) where T : IAsn1Convertible
        {
            if (obj == null)
            {
                throw new ParsingException($"ASN1 decode error, expected {typeof(T).Name}, got null");
            }

            if (typeof(T).Name != obj.GetType().Name)
            {
                throw new ParsingException(
                          $"ASN1 decode error, expected {typeof(T).Name}, got {obj.GetType().Name}");
            }

            return((T)obj);
        }
Exemplo n.º 16
0
 public OriginatorInfo GetOriginatorInfo()
 {
     originatorInfoCalled = true;
     if (nextObject == null)
     {
         nextObject = seq.ReadObject();
     }
     if (nextObject is Asn1TaggedObjectParser && ((Asn1TaggedObjectParser)nextObject).TagNo == 0)
     {
         Asn1SequenceParser asn1SequenceParser = (Asn1SequenceParser)((Asn1TaggedObjectParser)nextObject).GetObjectParser(16, isExplicit: false);
         nextObject = null;
         return(OriginatorInfo.GetInstance(asn1SequenceParser.ToAsn1Object()));
     }
     return(null);
 }
Exemplo n.º 17
0
        public Asn1SetParser GetRecipientInfos()
        {
            if (!this.originatorInfoCalled)
            {
                this.GetOriginatorInfo();
            }
            if (this.nextObject == null)
            {
                this.nextObject = this.seq.ReadObject();
            }
            Asn1SetParser result = (Asn1SetParser)this.nextObject;

            this.nextObject = null;
            return(result);
        }
Exemplo n.º 18
0
    public Asn1SetParser GetRecipientInfos()
    {
        if (!originatorInfoCalled)
        {
            GetOriginatorInfo();
        }
        if (nextObject == null)
        {
            nextObject = seq.ReadObject();
        }
        Asn1SetParser result = (Asn1SetParser)nextObject;

        nextObject = null;
        return(result);
    }
Exemplo n.º 19
0
 public OriginatorInfo GetOriginatorInfo()
 {
     this.originatorInfoCalled = true;
     if (this.nextObject == null)
     {
         this.nextObject = this.seq.ReadObject();
     }
     if (this.nextObject is Asn1TaggedObjectParser && ((Asn1TaggedObjectParser)this.nextObject).TagNo == 0)
     {
         Asn1SequenceParser asn1SequenceParser = (Asn1SequenceParser)((Asn1TaggedObjectParser)this.nextObject).GetObjectParser(16, false);
         this.nextObject = null;
         return(OriginatorInfo.GetInstance(asn1SequenceParser.ToAsn1Object()));
     }
     return(null);
 }
		public EncryptedContentInfoParser GetAuthEncryptedContentInfo() 
		{
			if (nextObject == null)
			{
				nextObject = seq.ReadObject();
			}

			if (nextObject != null)
			{
				Asn1SequenceParser o = (Asn1SequenceParser) nextObject;
				nextObject = null;
				return new EncryptedContentInfoParser(o);
			}

			return null;
		}
Exemplo n.º 21
0
        private Asn1OctetStringParser GetNextParser()
        {
            IAsn1Convertible asn1Obj = _parser.ReadObject();

            if (asn1Obj == null)
            {
                return(null);
            }

            if (asn1Obj is Asn1OctetStringParser)
            {
                return((Asn1OctetStringParser)asn1Obj);
            }

            throw new IOException("unknown object encountered: " + Platform.GetTypeName(asn1Obj));
        }
Exemplo n.º 22
0
        private Asn1OctetStringParser GetNextParser()
        {
            IAsn1Convertible asn1Obj = _parser.ReadObject();

            if (asn1Obj == null)
            {
                return(null);
            }

            if (asn1Obj is Asn1OctetStringParser)
            {
                return((Asn1OctetStringParser)asn1Obj);
            }

            throw new IOException("unknown object encountered: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(asn1Obj));
        }
Exemplo n.º 23
0
        private void doTestEncodingGeneralizedTime(
            DerObjectIdentifier oid,
            string val)
        {
            IAsn1Convertible converted = createEntryValue(oid, val);

            if (!(converted is DerGeneralizedTime))
            {
                Fail("encoding for " + oid + " not GeneralizedTime");
            }
            converted = createEntryValueFromString(oid, val);
            if (!(converted is DerGeneralizedTime))
            {
                Fail("encoding for " + oid + " not GeneralizedTime");
            }
        }
	    public AlgorithmIdentifier GetMacAlgorithm()
	    {
	        if (nextObject == null)
	        {
	            nextObject = seq.ReadObject();
	        }

	        if (nextObject != null)
	        {
	            Asn1SequenceParser o = (Asn1SequenceParser)nextObject;
	            nextObject = null;
	            return AlgorithmIdentifier.GetInstance(o.ToAsn1Object());
	        }

	        return null;
	    }
Exemplo n.º 25
0
		public EncryptedContentInfoParser GetEncryptedContentInfo()
		{
			if (_nextObject == null)
			{
				_nextObject = _seq.ReadObject();
			}

			if (_nextObject != null)
			{
				Asn1SequenceParser o = (Asn1SequenceParser) _nextObject;
				_nextObject = null;
				return new EncryptedContentInfoParser(o);
			}

			return null;
		}
Exemplo n.º 26
0
	    public Asn1SetParser GetRecipientInfos()
	    {
	        if (!originatorInfoCalled)
	        {
	            GetOriginatorInfo();
	        }

	        if (nextObject == null)
	        {
	            nextObject = seq.ReadObject();
	        }

	        Asn1SetParser recipientInfos = (Asn1SetParser)nextObject;
	        nextObject = null;
	        return recipientInfos;
	    }
        public Asn1SetParser GetUnauthAttrs()
        {
            if (nextObject == null)
            {
                nextObject = seq.ReadObject();
            }

            if (nextObject != null)
            {
                IAsn1Convertible o = nextObject;
                nextObject = null;
                return((Asn1SetParser)((Asn1TaggedObjectParser)o).GetObjectParser(Asn1Tags.Set, false));
            }

            return(null);
        }
Exemplo n.º 28
0
        public EncryptedContentInfoParser GetEncryptedContentInfo()
        {
            if (_nextObject == null)
            {
                _nextObject = _seq.ReadObject();
            }

            if (_nextObject != null)
            {
                Asn1SequenceParser o = (Asn1SequenceParser)_nextObject;
                _nextObject = null;
                return(new EncryptedContentInfoParser(o));
            }

            return(null);
        }
        public ContentInfoParser GetEnapsulatedContentInfo()
        {
            if (nextObject == null)
            {
                nextObject = seq.ReadObject();
            }

            if (nextObject != null)
            {
                Asn1SequenceParser o = (Asn1SequenceParser)nextObject;
                nextObject = null;
                return new ContentInfoParser(o);
            }

            return null;
        }
        public Asn1SetParser GetAuthAttrs()
        {
            if (nextObject == null)
            {
                nextObject = seq.ReadObject();
            }

            if (nextObject is Asn1TaggedObjectParser)
            {
                IAsn1Convertible o = nextObject;
                nextObject = null;
                return (Asn1SetParser)((Asn1TaggedObjectParser)o).GetObjectParser(Asn1Tags.Set, false);
            }

            return null;
        }
Exemplo n.º 31
0
        public Asn1SetParser GetUnprotectedAttrs()
        {
            if (_nextObject == null)
            {
                _nextObject = _seq.ReadObject();
            }

            if (_nextObject != null)
            {
                IAsn1Convertible o = _nextObject;
                _nextObject = null;
                return((Asn1SetParser)((Asn1TaggedObjectParser)o).GetObjectParser(Asn1Tags.Set, false));
            }

            return(null);
        }
Exemplo n.º 32
0
        internal Asn1EncodableVector ReadVector()
        {
            IAsn1Convertible obj = ReadObject();

            if (null == obj)
            {
                return(new Asn1EncodableVector(0));
            }

            Asn1EncodableVector v = new Asn1EncodableVector();

            do
            {
                v.Add(obj.ToAsn1Object());
            }while ((obj = ReadObject()) != null);
            return(v);
        }
Exemplo n.º 33
0
        public sealed override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            IAsn1Convertible convertible = obj as IAsn1Convertible;

            if (convertible == null)
            {
                return(false);
            }
            Asn1Object obj2 = this.ToAsn1Object();
            Asn1Object obj3 = convertible.ToAsn1Object();

            return((obj2 == obj3) || obj2.CallAsn1Equals(obj3));
        }
        public Asn1SetParser GetCrls()
        {
            if (_nextObject == null)
            {
                _nextObject = _seq.ReadObject();
            }

            if (_nextObject is Asn1TaggedObject && ((Asn1TaggedObject)_nextObject).TagNo == 1)
            {
                Asn1SetParser crls = (Asn1SetParser)((Asn1TaggedObject)_nextObject).GetObjectParser(Asn1Tags.Set, false);
                _nextObject = null;

                return(crls);
            }

            return(null);
        }
Exemplo n.º 35
0
        public sealed override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            IAsn1Convertible asn1Convertible = obj as IAsn1Convertible;

            if (asn1Convertible == null)
            {
                return(false);
            }
            Asn1Object asn1Object  = ToAsn1Object();
            Asn1Object asn1Object2 = asn1Convertible.ToAsn1Object();

            return(asn1Object == asn1Object2 || asn1Object.CallAsn1Equals(asn1Object2));
        }
Exemplo n.º 36
0
        public Asn1SetParser GetRecipientInfos()
        {
            if (!_originatorInfoCalled)
            {
                GetOriginatorInfo();
            }

            if (_nextObject == null)
            {
                _nextObject = _seq.ReadObject();
            }

            Asn1SetParser recipientInfos = (Asn1SetParser)_nextObject;

            _nextObject = null;
            return(recipientInfos);
        }
Exemplo n.º 37
0
        public Asn1SetParser GetCrls()
        {
            if (_nextObject == null)
            {
                _nextObject = _seq.ReadObject();
            }

            if (_nextObject is Asn1TaggedObject && ((Asn1TaggedObject)_nextObject).TagNo == 1)
            {
                Asn1SetParser crls = (Asn1SetParser)((Asn1TaggedObject)_nextObject).GetObjectParser(Asn1Tags.Set, false);
                _nextObject = null;

                return crls;
            }

            return null;
        }
Exemplo n.º 38
0
	    public OriginatorInfo GetOriginatorInfo()
	    {
	        originatorInfoCalled = true;

	        if (nextObject == null)
	        {
	            nextObject = seq.ReadObject();
	        }

	        if (nextObject is Asn1TaggedObjectParser && ((Asn1TaggedObjectParser)nextObject).TagNo == 0)
	        {
	            Asn1SequenceParser originatorInfo = (Asn1SequenceParser) ((Asn1TaggedObjectParser)nextObject).GetObjectParser(Asn1Tags.Sequence, false);
	            nextObject = null;
	            return OriginatorInfo.GetInstance(originatorInfo.ToAsn1Object());
	        }

	        return null;
	    }
Exemplo n.º 39
0
        public OriginatorInfo GetOriginatorInfo()
        {
            _originatorInfoCalled = true;

            if (_nextObject == null)
            {
                _nextObject = _seq.ReadObject();
            }

            if (_nextObject is Asn1TaggedObjectParser && ((Asn1TaggedObjectParser)_nextObject).TagNo == 0)
            {
                Asn1SequenceParser originatorInfo = (Asn1SequenceParser)
                                                    ((Asn1TaggedObjectParser)_nextObject).GetObjectParser(Asn1Tags.Sequence, false);
                _nextObject = null;
                return(OriginatorInfo.GetInstance(originatorInfo.ToAsn1Object()));
            }

            return(null);
        }
        public Asn1SetParser GetAuthAttrs()
        {
            if (nextObject == null)
            {
                nextObject = seq.ReadObject();
            }

            if (nextObject is Asn1TaggedObjectParser)
            {
                IAsn1Convertible o = nextObject;
                nextObject = null;
                return (Asn1SetParser)((Asn1TaggedObjectParser)o).GetObjectParser(Asn1Tags.Set, false);
            }

            // TODO
            // "The authAttrs MUST be present if the content type carried in
            // EncryptedContentInfo is not id-data."

            return null;
        }
        static string ExtractPartitionedCrlDistributionPoint(IAsn1Convertible directoryName)
        {
            var ds = (DerSequence) directoryName.ToAsn1Object();

            var partitionedCrlDistributionPoint = "";
            foreach (Asn1Set dset in ds)
            {
                partitionedCrlDistributionPoint = BuildPartitionedCrlDistributionPoint(partitionedCrlDistributionPoint, dset);
            }
            return partitionedCrlDistributionPoint;
        }
Exemplo n.º 42
0
		public AlgorithmIdentifier GetDigestAlgorithm()
		{
			if (nextObject == null)
			{
				nextObject = seq.ReadObject();
			}

			if (nextObject is Asn1TaggedObjectParser)
			{
				AlgorithmIdentifier obj = AlgorithmIdentifier.GetInstance(
					(Asn1TaggedObject)nextObject.ToAsn1Object(), false);
				nextObject = null;
				return obj;
			}

			return null;
		}
Exemplo n.º 43
0
	    public Asn1OctetString GetMac()
	    {
	        if (nextObject == null)
	        {
	            nextObject = seq.ReadObject();
	        }

	        IAsn1Convertible o = nextObject;
	        nextObject = null;

	        return Asn1OctetString.GetInstance(o.ToAsn1Object());
	    }
Exemplo n.º 44
0
		public Asn1SetParser GetUnprotectedAttrs()
		{
			if (_nextObject == null)
			{
				_nextObject = _seq.ReadObject();
			}

			if (_nextObject != null)
			{
				IAsn1Convertible o = _nextObject;
				_nextObject = null;
				return (Asn1SetParser)((Asn1TaggedObjectParser)o).GetObjectParser(Asn1Tags.Set, false);
			}
        
			return null;
		}