Example #1
0
		private Evidence(Asn1TaggedObject tagged)
		{
			if (tagged.TagNo == 0)
			{
				this.tstEvidence = TimeStampTokenEvidence.GetInstance(tagged, false);
			}
		}
Example #2
0
        private PopoPrivKey(Asn1TaggedObject obj)
        {
            this.tagNo = obj.TagNo;

            switch (tagNo)
            {
            case thisMessage:
                this.obj = DerBitString.GetInstance(obj, false);
                break;
            case subsequentMessage:
                this.obj = SubsequentMessage.ValueOf(DerInteger.GetInstance(obj, false).Value.IntValue);
                break;
            case dhMAC:
                this.obj = DerBitString.GetInstance(obj, false);
                break;
            case agreeMAC:
                this.obj = PKMacValue.GetInstance(obj, false);
                break;
            case encryptedKey:
                this.obj = EnvelopedData.GetInstance(obj, false);
                break;
            default:
                throw new ArgumentException("unknown tag in PopoPrivKey", "obj");
            }
        }
        private DeclarationOfMajority(
			Asn1TaggedObject o)
        {
            if (o.TagNo > 2)
                throw new ArgumentException("Bad tag number: " + o.TagNo);

            this.declaration = o;
        }
		public static RequestedCertificate GetInstance(
			Asn1TaggedObject	obj,
			bool				isExplicit)
		{
			if (!isExplicit)
				throw new ArgumentException("choice item must be explicitly tagged");

			return GetInstance(obj.GetObject());
		}
		public static DirectoryString GetInstance(
			Asn1TaggedObject	obj,
			bool				isExplicit)
		{
			if (!isExplicit)
				throw new ArgumentException("choice item must be explicitly tagged");

			return GetInstance(obj.GetObject());
		}
		/**
         * return an OriginatorIdentifierOrKey object from a tagged object.
         *
         * @param o the tagged object holding the object we want.
         * @param explicitly true if the object is meant to be explicitly
         *              tagged false otherwise.
         * @exception ArgumentException if the object held by the
         *          tagged object cannot be converted.
         */
        public static OriginatorIdentifierOrKey GetInstance(
            Asn1TaggedObject	o,
            bool				explicitly)
        {
            if (!explicitly)
            {
                throw new ArgumentException(
                        "Can't implicitly tag OriginatorIdentifierOrKey");
            }

			return GetInstance(o.GetObject());
        }
		public DistributionPointName(
            Asn1TaggedObject obj)
        {
            this.type = obj.TagNo;

			if (type == FullName)
            {
                this.name = GeneralNames.GetInstance(obj, false);
            }
            else
            {
                this.name = Asn1Set.GetInstance(obj, false);
            }
        }
		private CertOrEncCert(Asn1TaggedObject tagged)
		{
			if (tagged.TagNo == 0)
			{
				certificate = CmpCertificate.GetInstance(tagged.GetObject());
			}
			else if (tagged.TagNo == 1)
			{
				encryptedCert = EncryptedValue.GetInstance(tagged.GetObject());
			}
			else
			{
				throw new ArgumentException("unknown tag: " + tagged.TagNo, "tagged");
			}
		}
Example #9
0
		/**
		 * Constructor from Asn1TaggedObject.
		 * 
		 * @param tagObj The tagged object.
		 * @throws ArgumentException if the encoding is wrong.
		 */
		private Target(
			Asn1TaggedObject tagObj)
		{
			switch ((Choice) tagObj.TagNo)
			{
				case Choice.Name:	// GeneralName is already a choice so explicit
					targetName = GeneralName.GetInstance(tagObj, true);
					break;
				case Choice.Group:
					targetGroup = GeneralName.GetInstance(tagObj, true);
					break;
				default:
					throw new ArgumentException("unknown tag: " + tagObj.TagNo);
			}
		}
		private RequestedCertificate(
			Asn1TaggedObject tagged)
		{
			switch ((Choice) tagged.TagNo)
			{
				case Choice.AttributeCertificate:
					this.attributeCert = Asn1OctetString.GetInstance(tagged, true).GetOctets();
					break;
				case Choice.PublicKeyCertificate:
					this.publicKeyCert = Asn1OctetString.GetInstance(tagged, true).GetOctets();
					break;
				default:
					throw new ArgumentException("unknown tag number: " + tagged.TagNo);
			}
		}
Example #11
0
		public CertStatus(
            Asn1TaggedObject choice)
        {
            this.tagNo = choice.TagNo;

			switch (choice.TagNo)
            {
				case 1:
					value = RevokedInfo.GetInstance(choice, false);
					break;
				case 0:
				case 2:
					value = DerNull.Instance;
					break;
            }
        }
Example #12
0
		/**
		 * Constructor for a holder for an v1 attribute certificate.
		 * 
		 * @param tagObj The ASN.1 tagged holder object.
		 */
		public Holder(
			Asn1TaggedObject tagObj)
		{
			switch (tagObj.TagNo)
			{
				case 0:
					baseCertificateID = IssuerSerial.GetInstance(tagObj, false);
					break;
				case 1:
					entityName = GeneralNames.GetInstance(tagObj, false);
					break;
				default:
					throw new ArgumentException("unknown tag in Holder");
			}

			this.version = 0;
		}
Example #13
0
 private PkiArchiveOptions(Asn1TaggedObject tagged)
 {
     switch (tagged.TagNo)
     {
         case encryptedPrivKey:
             value = EncryptedKey.GetInstance(tagged.GetObject());
             break;
         case keyGenParameters:
             value = Asn1OctetString.GetInstance(tagged, false);
             break;
         case archiveRemGenPrivKey:
             value = DerBoolean.GetInstance(tagged, false);
             break;
         default:
             throw new ArgumentException("unknown tag number: " + tagged.TagNo, "tagged");
     }
 }
Example #14
0
		public CertStatus(
            Asn1TaggedObject choice)
        {
            this.tagNo = choice.TagNo;

			switch (choice.TagNo)
            {
				case 1:
					value = RevokedInfo.GetInstance(choice, false);
					break;
				case 0:
				case 2:
					value = DerNull.Instance;
					break;
				default:
					throw new ArgumentException("Unknown tag encountered: " + choice.TagNo);
            }
        }
 private ProofOfPossession(Asn1TaggedObject tagged)
 {
     tagNo = tagged.TagNo;
     switch (tagNo)
     {
     case 0:
         obj = DerNull.Instance;
         break;
     case 1:
         obj = PopoSigningKey.GetInstance(tagged, false);
         break;
     case 2:
     case 3:
         obj = PopoPrivKey.GetInstance(tagged, false);
         break;
     default:
         throw new ArgumentException("unknown tag: " + tagNo, "tagged");
     }
 }
		public DeclarationOfMajority(
			bool	fullAge,
			string	country)
		{
			if (country.Length > 2)
				throw new ArgumentException("country can only be 2 characters");

			DerPrintableString countryString = new DerPrintableString(country, true);

			DerSequence seq;
			if (fullAge)
			{
				seq = new DerSequence(countryString);
			}
			else
			{
				seq = new DerSequence(DerBoolean.False, countryString);
			}

			this.declaration = new DerTaggedObject(false, 1, seq);
		}
Example #17
0
 /// <summary>
 /// Gets the instance.
 /// </summary>
 /// <param name="obj">The object.</param>
 /// <param name="explicitly">if set to <c>true</c> [explicitly].</param>
 /// <returns></returns>
 public static FreshestCRL GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly)));
 }
 public DeclarationOfMajority(
     DerGeneralizedTime dateOfBirth)
 {
     this.declaration = new DerTaggedObject(false, 2, dateOfBirth);
 }
Example #19
0
 /**
  * return an RecipientEncryptedKey object from a tagged object.
  *
  * @param obj the tagged object holding the object we want.
  * @param isExplicit true if the object is meant to be explicitly
  *              tagged false otherwise.
  * @exception ArgumentException if the object held by the
  *          tagged object cannot be converted.
  */
 public static RecipientEncryptedKey GetInstance(
     Asn1TaggedObject obj,
     bool isExplicit)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit)));
 }
Example #20
0
 public static CertificatePolicies GetInstance(Asn1TaggedObject obj, bool isExplicit)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit)));
 }
Example #21
0
 public static DHDomainParameters GetInstance(Asn1TaggedObject obj, bool isExplicit)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit)));
 }
Example #22
0
 public static Time GetInstance(
     Asn1TaggedObject	obj,
     bool				explicitly)
 {
     return GetInstance(obj.GetObject());
 }
Example #23
0
 public static ContentInfo GetInstance(Asn1TaggedObject obj, bool isExplicit)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit)));
 }
 public static RsaPublicKeyStructure GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly)));
 }
Example #25
0
 public static BasicConstraints GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly)));
 }
Example #26
0
 /**
  * return a RecipientKeyIdentifier object from a tagged object.
  *
  * @param _ato the tagged object holding the object we want.
  * @param _explicit true if the object is meant to be explicitly
  *              tagged false otherwise.
  * @exception ArgumentException if the object held by the
  *          tagged object cannot be converted.
  */
 public static RecipientKeyIdentifier GetInstance(
     Asn1TaggedObject ato,
     bool explicitly)
 {
     return(GetInstance(Asn1Sequence.GetInstance(ato, explicitly)));
 }
        internal TbsCertificateStructure(
            Asn1Sequence seq)
        {
            int seqStart = 0;

            this.seq = seq;

            //
            // some certficates don't include a version number - we assume v1
            //
            if (seq[0] is Asn1TaggedObject)
            {
                version = DerInteger.GetInstance((Asn1TaggedObject)seq[0], true);
            }
            else
            {
                seqStart = -1;                          // field 0 is missing!
                version  = new DerInteger(0);
            }

            bool isV1 = false;
            bool isV2 = false;

            if (version.Value.Equals(BigInteger.Zero))
            {
                isV1 = true;
            }
            else if (version.Value.Equals(BigInteger.One))
            {
                isV2 = true;
            }
            else if (!version.Value.Equals(BigInteger.Two))
            {
                throw new ArgumentException("version number not recognised");
            }

            serialNumber = DerInteger.GetInstance(seq[seqStart + 1]);

            signature = AlgorithmIdentifier.GetInstance(seq[seqStart + 2]);
            issuer    = X509Name.GetInstance(seq[seqStart + 3]);

            //
            // before and after dates
            //
            Asn1Sequence dates = (Asn1Sequence)seq[seqStart + 4];

            startDate = Time.GetInstance(dates[0]);
            endDate   = Time.GetInstance(dates[1]);

            subject = X509Name.GetInstance(seq[seqStart + 5]);

            //
            // public key info.
            //
            subjectPublicKeyInfo = SubjectPublicKeyInfo.GetInstance(seq[seqStart + 6]);

            int extras = seq.Count - (seqStart + 6) - 1;

            if (extras != 0 && isV1)
            {
                throw new ArgumentException("version 1 certificate contains extra data");
            }

            while (extras > 0)
            {
                Asn1TaggedObject extra = Asn1TaggedObject.GetInstance(seq[seqStart + 6 + extras]);
                switch (extra.TagNo)
                {
                case 1:
                {
                    issuerUniqueID = DerBitString.GetInstance(extra, false);
                    break;
                }

                case 2:
                {
                    subjectUniqueID = DerBitString.GetInstance(extra, false);
                    break;
                }

                case 3:
                {
                    if (isV2)
                    {
                        throw new ArgumentException("version 2 certificate cannot contain extensions");
                    }

                    extensions = X509Extensions.GetInstance(Asn1Sequence.GetInstance(extra, true));
                    break;
                }

                default:
                {
                    throw new ArgumentException("Unknown tag encountered in structure: " + extra.TagNo);
                }
                }
                extras--;
            }
        }
Example #28
0
 public static PopoPrivKey GetInstance(Asn1TaggedObject tagged, bool isExplicit)
 {
     return(new PopoPrivKey(Asn1TaggedObject.GetInstance(tagged.GetObject())));
 }
Example #29
0
 /**
  * Return a X509Name based on the passed in tagged object.
  *
  * @param obj tag object holding name.
  * @param explicitly true if explicitly tagged false otherwise.
  * @return the X509Name
  */
 public static X509Name GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly)));
 }
Example #30
0
 public static PKMacValue GetInstance(Asn1TaggedObject obj, bool isExplicit)
 {
     return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
 }
Example #31
0
		public static ExtendedKeyUsage GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
        }
Example #32
0
 public static OcspRequest GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly)));
 }
Example #33
0
		public static ResponseBytes GetInstance(
			Asn1TaggedObject	obj,
			bool				explicitly)
		{
			return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
		}
Example #34
0
 public static ResponderID GetInstance(
     Asn1TaggedObject obj,
     bool isExplicit)
 {
     return(GetInstance(obj.GetObject()));            // must be explicitly tagged
 }
Example #35
0
 public static CrlDistPoint GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly)));
 }
Example #36
0
 public static AlgorithmIdentifier GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly)));
 }
 public static AttributeCertificateInfo GetInstance(
     Asn1TaggedObject obj,
     bool isExplicit)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit)));
 }
Example #38
0
 public static X509CertificateStructure GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly)));
 }
		/**
		 * return an AuthenticatedData object from a tagged object.
		 *
		 * @param obj      the tagged object holding the object we want.
		 * @param isExplicit true if the object is meant to be explicitly
		 *                 tagged false otherwise.
		 * @throws ArgumentException if the object held by the
		 *                                  tagged object cannot be converted.
		 */
		public static AuthenticatedData GetInstance(
			Asn1TaggedObject	obj,
			bool				isExplicit)
		{
			return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
		}
Example #40
0
 public static DHPublicKey GetInstance(Asn1TaggedObject obj, bool isExplicit)
 {
     return(GetInstance(DerInteger.GetInstance(obj, isExplicit)));
 }
 public static DHValidationParms GetInstance(Asn1TaggedObject obj, bool isExplicit)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit)));
 }
		/**
		 * return an AuthEnvelopedData object from a tagged object.
		 *
		 * @param obj      the tagged object holding the object we want.
		 * @param isExplicit true if the object is meant to be explicitly
		 *                 tagged false otherwise.
		 * @throws ArgumentException if the object held by the
		 *                                  tagged object cannot be converted.
		 */
		public static MQVuserKeyingMaterial GetInstance(
			Asn1TaggedObject	obj,
			bool				isExplicit)
		{
			return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
		}
Example #43
0
 public static Time GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(obj.GetObject()));
 }
Example #44
0
 private KekRecipientInfo GetKekInfo(
     Asn1TaggedObject o)
 {
     // For compatibility with erroneous version, we don't always pass 'false' here
     return(KekRecipientInfo.GetInstance(o, o.IsExplicit()));
 }
Example #45
0
 public static GeneralNames GetInstance(
     Asn1TaggedObject	obj,
     bool				explicitly)
 {
     return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
 }
Example #46
0
 public static Gost3410PublicKeyAlgParameters GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly)));
 }
 /**
  * return an RecipientEncryptedKey object from a tagged object.
  *
  * @param obj the tagged object holding the object we want.
  * @param isExplicit true if the object is meant to be explicitly
  *              tagged false otherwise.
  * @exception ArgumentException if the object held by the
  *          tagged object cannot be converted.
  */
 public static RecipientEncryptedKey GetInstance(
     Asn1TaggedObject	obj,
     bool				isExplicit)
 {
     return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
 }
Example #48
0
		public static GeneralName GetInstance(
            Asn1TaggedObject	tagObj,
            bool				explicitly)
        {
            return GetInstance(Asn1TaggedObject.GetInstance(tagObj, true));
        }
Example #49
0
 public static AlgorithmIdentifier GetInstance(
     Asn1TaggedObject	obj,
     bool				explicitly)
 {
     return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
 }
Example #50
0
        /**
         * Gets a String from an ASN1Primitive
         * @param names the ASN1Primitive
         * @return  a human-readable String
         * @throws IOException
         */
        private static String GetStringFromGeneralName(Asn1Object names)
        {
            Asn1TaggedObject taggedObject = (Asn1TaggedObject)names;

            return(Encoding.GetEncoding(1252).GetString(Asn1OctetString.GetInstance(taggedObject, false).GetOctets()));
        }
		public static DHValidationParms GetInstance(Asn1TaggedObject obj, bool isExplicit)
		{
			return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
		}
Example #52
0
 public static ResponseData GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly)));
 }
Example #53
0
		public static DigestInfo GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
        }
Example #54
0
 public static NamingAuthority GetInstance(
     Asn1TaggedObject obj,
     bool isExplicit)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit)));
 }
 /**
  * return a OtherRevocationInfoFormat object from a tagged object.
  *
  * @param obj the tagged object holding the object we want.
  * @param explicit true if the object is meant to be explicitly
  *              tagged false otherwise.
  * @exception IllegalArgumentException if the object held by the
  *          tagged object cannot be converted.
  */
 public static OtherRevocationInfoFormat GetInstance(Asn1TaggedObject obj, bool isExplicit)
 {
     return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
 }
Example #56
0
 public static CertId GetInstance(Asn1TaggedObject obj, bool isExplicit)
 {
     return(CertId.GetInstance(Asn1Sequence.GetInstance(obj, isExplicit)));
 }
 /**
  * return a KekRecipientInfo object from a tagged object.
  *
  * @param obj the tagged object holding the object we want.
  * @param explicitly true if the object is meant to be explicitly
  *              tagged false otherwise.
  * @exception ArgumentException if the object held by the
  *          tagged object cannot be converted.
  */
 public static KekRecipientInfo GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, explicitly)));
 }
Example #58
0
 public static GeneralName GetInstance(
     Asn1TaggedObject tagObj,
     bool explicitly)
 {
     return(GetInstance(Asn1TaggedObject.GetInstance(tagObj, true)));
 }
        public static TbsCertificateStructure GetInstance(
			Asn1TaggedObject	obj,
			bool				explicitly)
        {
            return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
        }
Example #60
0
 /**
  * return an AuthenticatedData object from a tagged object.
  *
  * @param obj      the tagged object holding the object we want.
  * @param isExplicit true if the object is meant to be explicitly
  *                 tagged false otherwise.
  * @throws ArgumentException if the object held by the
  *                                  tagged object cannot be converted.
  */
 public static AuthenticatedData GetInstance(
     Asn1TaggedObject obj,
     bool isExplicit)
 {
     return(GetInstance(Asn1Sequence.GetInstance(obj, isExplicit)));
 }