Example #1
0
		private V2Form(
            Asn1Sequence seq)
        {
			if (seq.Count > 3)
			{
				throw new ArgumentException("Bad sequence size: " + seq.Count);
			}

			int index = 0;

			if (!(seq[0] is Asn1TaggedObject))
            {
                index++;
                this.issuerName = GeneralNames.GetInstance(seq[0]);
            }

			for (int i = index; i != seq.Count; i++)
            {
				Asn1TaggedObject o = Asn1TaggedObject.GetInstance(seq[i]);
				if (o.TagNo == 0)
                {
                    baseCertificateID = IssuerSerial.GetInstance(o, false);
                }
                else if (o.TagNo == 1)
                {
                    objectDigestInfo = ObjectDigestInfo.GetInstance(o, false);
                }
				else
				{
					throw new ArgumentException("Bad tag number: " + o.TagNo);
				}
			}
        }
Example #2
0
        /**
         * Constructor for a holder for an v2 attribute certificate. *
         *
         * @param seq The ASN.1 sequence.
         */
        private Holder(
            Asn1Sequence seq)
        {
            if (seq.Count > 3)
            {
                throw new ArgumentException("Bad sequence size: " + seq.Count);
            }

            for (int i = 0; i != seq.Count; i++)
            {
                Asn1TaggedObject tObj = Asn1TaggedObject.GetInstance(seq[i]);

                switch (tObj.TagNo)
                {
                case 0:
                    baseCertificateID = IssuerSerial.GetInstance(tObj, false);
                    break;

                case 1:
                    entityName = GeneralNames.GetInstance(tObj, false);
                    break;

                case 2:
                    objectDigestInfo = ObjectDigestInfo.GetInstance(tObj, false);
                    break;

                default:
                    throw new ArgumentException("unknown tag in Holder");
                }
            }

            this.version = 1;
        }
Example #3
0
 /**
  * Constructs a holder from a IssuerSerial.
  * @param baseCertificateID The IssuerSerial.
  * @param version The version of the attribute certificate.
  */
 public Holder(
     IssuerSerial baseCertificateID,
     int version)
 {
     this.baseCertificateID = baseCertificateID;
     this.version           = version;
 }
Example #4
0
		private EssCertIDv2(
			Asn1Sequence seq)
		{
			if (seq.Count > 3)
				throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");

			int count = 0;

			if (seq[0] is Asn1OctetString)
			{
				// Default value
				this.hashAlgorithm = DefaultAlgID;
			}
			else
			{
				this.hashAlgorithm = AlgorithmIdentifier.GetInstance(seq[count++].ToAsn1Object());
			}

			this.certHash = Asn1OctetString.GetInstance(seq[count++].ToAsn1Object()).GetOctets();

			if (seq.Count > count)
			{
				this.issuerSerial = IssuerSerial.GetInstance(
					Asn1Sequence.GetInstance(seq[count].ToAsn1Object()));
			}
		}
Example #5
0
        private V2Form(
            Asn1Sequence seq)
        {
            if (seq.Count > 3)
            {
                throw new ArgumentException("Bad sequence size: " + seq.Count);
            }

            int index = 0;

            if (!(seq[0] is Asn1TaggedObject))
            {
                index++;
                this.issuerName = GeneralNames.GetInstance(seq[0]);
            }

            for (int i = index; i != seq.Count; i++)
            {
                Asn1TaggedObject o = Asn1TaggedObject.GetInstance(seq[i]);
                if (o.TagNo == 0)
                {
                    baseCertificateID = IssuerSerial.GetInstance(o, false);
                }
                else if (o.TagNo == 1)
                {
                    objectDigestInfo = ObjectDigestInfo.GetInstance(o, false);
                }
                else
                {
                    throw new ArgumentException("Bad tag number: " + o.TagNo);
                }
            }
        }
Example #6
0
		public EssCertID(
			byte[]			hash,
			IssuerSerial	issuerSerial)
		{
			this.certHash = new DerOctetString(hash);
			this.issuerSerial = issuerSerial;
		}
Example #7
0
		public OtherCertID(
			AlgorithmIdentifier	algId,
			byte[]				digest,
			IssuerSerial		issuerSerial)
		{
			this.otherCertHash = new DigestInfo(algId, digest);
			this.issuerSerial = issuerSerial;
		}
Example #8
0
		public OtherCertID(
			OtherHash		otherCertHash,
			IssuerSerial	issuerSerial)
		{
			if (otherCertHash == null)
				throw new ArgumentNullException("otherCertHash");

			this.otherCertHash = otherCertHash;
			this.issuerSerial = issuerSerial;
		}
Example #9
0
		private OtherCertID(
			Asn1Sequence seq)
		{
			if (seq == null)
				throw new ArgumentNullException("seq");
			if (seq.Count < 1 || seq.Count > 2)
				throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");

			this.otherCertHash = OtherHash.GetInstance(seq[0].ToAsn1Object());

			if (seq.Count > 1)
			{
				this.issuerSerial = IssuerSerial.GetInstance(seq[1].ToAsn1Object());
			}
		}
Example #10
0
		/**
		 * constructor
		 */
		public EssCertID(
			Asn1Sequence seq)
		{
			if (seq.Count < 1 || seq.Count > 2)
			{
				throw new ArgumentException("Bad sequence size: " + seq.Count);
			}

			this.certHash = Asn1OctetString.GetInstance(seq[0]);

			if (seq.Count > 1)
			{
				issuerSerial = IssuerSerial.GetInstance(seq[1]);
			}
		}
Example #11
0
		public EssCertIDv2(
			AlgorithmIdentifier	algId,
			byte[]				certHash,
			IssuerSerial		issuerSerial)
		{
			if (algId == null)
			{
				// Default value
				this.hashAlgorithm = DefaultAlgID;
			}
			else
			{
				this.hashAlgorithm = algId;
			}

			this.certHash = certHash;
			this.issuerSerial = issuerSerial;
		}
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
		/**
		 * constructor
		 */
		public OtherCertID(
			Asn1Sequence seq)
		{
			if (seq.Count < 1 || seq.Count > 2)
			{
				throw new ArgumentException("Bad sequence size: " + seq.Count);
			}

			if (seq[0].ToAsn1Object() is Asn1OctetString)
			{
				otherCertHash = Asn1OctetString.GetInstance(seq[0]);
			}
			else
			{
				otherCertHash = DigestInfo.GetInstance(seq[0]);
			}

			if (seq.Count > 1)
			{
				issuerSerial = IssuerSerial.GetInstance(Asn1Sequence.GetInstance(seq[1]));
			}
		}
		/**
		* Constructor from a given details.
		* <p/>
		* <p/>
		* Either <code>generalName</code> or <code>certRef</code> MUST be
		* <code>null</code>.
		*
		* @param country            The country code whose laws apply.
		* @param typeOfSubstitution The type of procuration.
		* @param certRef            Reference to certificate of the person who is represented.
		*/
		public ProcurationSyntax(
			string			country,
			DirectoryString	typeOfSubstitution,
			IssuerSerial	certRef)
		{
			this.country = country;
			this.typeOfSubstitution = typeOfSubstitution;
			this.thirdPerson = null;
			this.certRef = certRef;
		}
		/**
		* Constructor from Asn1Sequence.
		* <p/>
		* The sequence is of type ProcurationSyntax:
		* <p/>
		* <pre>
		*               ProcurationSyntax ::= SEQUENCE {
		*                 country [1] EXPLICIT PrintableString(SIZE(2)) OPTIONAL,
		*                 typeOfSubstitution [2] EXPLICIT DirectoryString (SIZE(1..128)) OPTIONAL,
		*                 signingFor [3] EXPLICIT SigningFor
		*               }
		* <p/>
		*               SigningFor ::= CHOICE
		*               {
		*                 thirdPerson GeneralName,
		*                 certRef IssuerSerial
		*               }
		* </pre>
		*
		* @param seq The ASN.1 sequence.
		*/
		private ProcurationSyntax(
			Asn1Sequence seq)
		{
			if (seq.Count < 1 || seq.Count > 3)
				throw new ArgumentException("Bad sequence size: " + seq.Count);

			IEnumerator e = seq.GetEnumerator();

			while (e.MoveNext())
			{
				Asn1TaggedObject o = Asn1TaggedObject.GetInstance(e.Current);
				switch (o.TagNo)
				{
					case 1:
						country = DerPrintableString.GetInstance(o, true).GetString();
						break;
					case 2:
						typeOfSubstitution = DirectoryString.GetInstance(o, true);
						break;
					case 3:
						Asn1Object signingFor = o.GetObject();
						if (signingFor is Asn1TaggedObject)
						{
							thirdPerson = GeneralName.GetInstance(signingFor);
						}
						else
						{
							certRef = IssuerSerial.GetInstance(signingFor);
						}
						break;
					default:
						throw new ArgumentException("Bad tag number: " + o.TagNo);
				}
			}
		}
Example #16
0
 public Holder(
     IssuerSerial baseCertificateID)
     : this(baseCertificateID, 1)
 {
 }
		/**
		 * Constructor from a given details.
		 * <p/>
		 * <p/>
		 * Either <code>generalName</code> or <code>certRef</code> MUST be
		 * <code>null</code>.
		 *
		 * @param country            The country code whose laws apply.
		 * @param typeOfSubstitution The type of procuration.
		 * @param thirdPerson        The GeneralName of the person who is represented.
		 */
		public ProcurationSyntax(
			string			country,
			DirectoryString	typeOfSubstitution,
			GeneralName		thirdPerson)
		{
			this.country = country;
			this.typeOfSubstitution = typeOfSubstitution;
			this.thirdPerson = thirdPerson;
			this.certRef = null;
		}