public IssuerSerial( GeneralNames issuer, DerInteger serial) { this.issuer = issuer; this.serial = serial; }
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); } } }
public DistributionPoint( DistributionPointName distributionPointName, ReasonFlags reasons, GeneralNames crlIssuer) { this.distributionPoint = distributionPointName; this.reasons = reasons; this.cRLIssuer = crlIssuer; }
/** * */ public IetfAttrSyntax( Asn1Sequence seq) { int i = 0; if (seq[0] is Asn1TaggedObject) { policyAuthority = GeneralNames.GetInstance(((Asn1TaggedObject)seq[0]), false); i++; } else if (seq.Count == 2) { // VOMS fix policyAuthority = GeneralNames.GetInstance(seq[0]); i++; } if (!(seq[i] is Asn1Sequence)) { throw new ArgumentException("Non-IetfAttrSyntax encoding"); } seq = (Asn1Sequence) seq[i]; foreach (Asn1Object obj in seq) { int type; if (obj is DerObjectIdentifier) { type = ValueOid; } else if (obj is DerUtf8String) { type = ValueUtf8; } else if (obj is DerOctetString) { type = ValueOctets; } else { throw new ArgumentException("Bad value type encoding IetfAttrSyntax"); } if (valueChoice < 0) { valueChoice = type; } if (type != valueChoice) { throw new ArgumentException("Mix of value types in IetfAttrSyntax"); } values.Add(obj); } }
/** * Constructor. * @param roleAuthority the role authority of this RoleSyntax. * @param roleName the role name of this RoleSyntax. */ public RoleSyntax( GeneralNames roleAuthority, GeneralName roleName) { if (roleName == null || roleName.TagNo != GeneralName.UniformResourceIdentifier || ((IAsn1String) roleName.Name).GetString().Equals("")) { throw new ArgumentException("the role name MUST be non empty and MUST " + "use the URI option of GeneralName"); } this.roleAuthority = roleAuthority; this.roleName = roleName; }
private IssuerSerial( Asn1Sequence seq) { if (seq.Count != 2 && seq.Count != 3) { throw new ArgumentException("Bad sequence size: " + seq.Count); } issuer = GeneralNames.GetInstance(seq[0]); serial = DerInteger.GetInstance(seq[1]); if (seq.Count == 3) { issuerUid = DerBitString.GetInstance(seq[2]); } }
private DistributionPoint( Asn1Sequence seq) { for (int i = 0; i != seq.Count; i++) { Asn1TaggedObject t = Asn1TaggedObject.GetInstance(seq[i]); switch (t.TagNo) { case 0: distributionPoint = DistributionPointName.GetInstance(t, true); break; case 1: reasons = new ReasonFlags(DerBitString.GetInstance(t, false)); break; case 2: cRLIssuer = GeneralNames.GetInstance(t, false); break; } } }
protected internal AuthorityKeyIdentifier( Asn1Sequence seq) { foreach (Asn1TaggedObject o in seq) { switch (o.TagNo) { case 0: this.keyidentifier = Asn1OctetString.GetInstance(o, false); break; case 1: this.certissuer = GeneralNames.GetInstance(o, false); break; case 2: this.certserno = DerInteger.GetInstance(o, false); break; default: throw new ArgumentException("illegal tag"); } } }
/** * create an AuthorityKeyIdentifier with a precomupted key identifier * and the GeneralNames tag and the serial number provided as well. */ public AuthorityKeyIdentifier( byte[] keyIdentifier, GeneralNames name, BigInteger serialNumber) { this.keyidentifier = new DerOctetString(keyIdentifier); this.certissuer = GeneralNames.GetInstance(name.ToAsn1Object()); this.certserno = new DerInteger(serialNumber); }
/** * create an AuthorityKeyIdentifier with a precomputed key identifier */ public AuthorityKeyIdentifier( byte[] keyIdentifier) { this.keyidentifier = new DerOctetString(keyIdentifier); this.certissuer = null; this.certserno = null; }
/** * create an AuthorityKeyIdentifier with the GeneralNames tag and * the serial number provided as well. */ public AuthorityKeyIdentifier( SubjectPublicKeyInfo spki, GeneralNames name, BigInteger serialNumber) { IDigest digest = new Sha1Digest(); byte[] resBuf = new byte[digest.GetDigestSize()]; byte[] bytes = spki.PublicKeyData.GetBytes(); digest.BlockUpdate(bytes, 0, bytes.Length); digest.DoFinal(resBuf, 0); this.keyidentifier = new DerOctetString(resBuf); this.certissuer = name; this.certserno = new DerInteger(serialNumber); }
private X509Name[] GetPrincipals( GeneralNames names) { object[] p = this.GetNames(names.GetNames()); int count = 0; for (int i = 0; i != p.Length; i++) { if (p[i] is X509Name) { ++count; } } X509Name[] result = new X509Name[count]; int pos = 0; for (int i = 0; i != p.Length; i++) { if (p[i] is X509Name) { result[pos++] = (X509Name)p[i]; } } return result; }
/// <summary> /// Don't use this one if you are trying to be RFC 3281 compliant. /// Use it for v1 attribute certificates only. /// </summary> /// <param name="names">Our GeneralNames structure</param> public AttCertIssuer( GeneralNames names) { obj = names; choiceObj = obj.ToAsn1Object(); }
public V2Form( GeneralNames issuerName) { this.issuerName = issuerName; }
/** * Constructor that builds an instance of <code>RoleSyntax</code> by * extracting the encoded elements from the <code>Asn1Sequence</code> * object supplied. * @param seq an instance of <code>Asn1Sequence</code> that holds * the encoded elements used to build this <code>RoleSyntax</code>. */ private RoleSyntax( Asn1Sequence seq) { if (seq.Count < 1 || seq.Count > 2) { throw new ArgumentException("Bad sequence size: " + seq.Count); } for (int i = 0; i != seq.Count; i++) { Asn1TaggedObject taggedObject = Asn1TaggedObject.GetInstance(seq[i]); switch (taggedObject.TagNo) { case 0: roleAuthority = GeneralNames.GetInstance(taggedObject, false); break; case 1: roleName = GeneralName.GetInstance(taggedObject, true); break; default: throw new ArgumentException("Unknown tag in RoleSyntax"); } } }
private bool MatchesDN( X509Name subject, GeneralNames targets) { GeneralName[] names = targets.GetNames(); for (int i = 0; i != names.Length; i++) { GeneralName gn = names[i]; if (gn.TagNo == GeneralName.DirectoryName) { try { if (X509Name.GetInstance(gn.Name).Equivalent(subject)) { return true; } } catch (Exception) { } } } return false; }
public DistributionPointName( GeneralNames name) : this(FullName, name) { }