init commit
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
using Org.BouncyCastle.Utilities.Collections;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class CertificateValues : Asn1Encodable
|
||||
{
|
||||
private readonly Asn1Sequence certificates;
|
||||
|
||||
public static CertificateValues GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is CertificateValues)
|
||||
{
|
||||
return (CertificateValues)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new CertificateValues((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'CertificateValues' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private CertificateValues(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
foreach (Asn1Encodable item in seq)
|
||||
{
|
||||
X509CertificateStructure.GetInstance(item.ToAsn1Object());
|
||||
}
|
||||
certificates = seq;
|
||||
}
|
||||
|
||||
public CertificateValues(params X509CertificateStructure[] certificates)
|
||||
{
|
||||
if (certificates == null)
|
||||
{
|
||||
throw new ArgumentNullException("certificates");
|
||||
}
|
||||
this.certificates = new DerSequence(certificates);
|
||||
}
|
||||
|
||||
public CertificateValues(IEnumerable certificates)
|
||||
{
|
||||
if (certificates == null)
|
||||
{
|
||||
throw new ArgumentNullException("certificates");
|
||||
}
|
||||
if (!CollectionUtilities.CheckElementsAreOfType(certificates, typeof(X509CertificateStructure)))
|
||||
{
|
||||
throw new ArgumentException("Must contain only 'X509CertificateStructure' objects", "certificates");
|
||||
}
|
||||
this.certificates = new DerSequence(Asn1EncodableVector.FromEnumerable(certificates));
|
||||
}
|
||||
|
||||
public X509CertificateStructure[] GetCertificates()
|
||||
{
|
||||
X509CertificateStructure[] array = new X509CertificateStructure[certificates.Count];
|
||||
for (int i = 0; i < certificates.Count; i++)
|
||||
{
|
||||
array[i] = X509CertificateStructure.GetInstance(certificates[i]);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return certificates;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Org.BouncyCastle.Asn1.Pkcs;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public abstract class CommitmentTypeIdentifier
|
||||
{
|
||||
public static readonly DerObjectIdentifier ProofOfOrigin = PkcsObjectIdentifiers.IdCtiEtsProofOfOrigin;
|
||||
|
||||
public static readonly DerObjectIdentifier ProofOfReceipt = PkcsObjectIdentifiers.IdCtiEtsProofOfReceipt;
|
||||
|
||||
public static readonly DerObjectIdentifier ProofOfDelivery = PkcsObjectIdentifiers.IdCtiEtsProofOfDelivery;
|
||||
|
||||
public static readonly DerObjectIdentifier ProofOfSender = PkcsObjectIdentifiers.IdCtiEtsProofOfSender;
|
||||
|
||||
public static readonly DerObjectIdentifier ProofOfApproval = PkcsObjectIdentifiers.IdCtiEtsProofOfApproval;
|
||||
|
||||
public static readonly DerObjectIdentifier ProofOfCreation = PkcsObjectIdentifiers.IdCtiEtsProofOfCreation;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class CommitmentTypeIndication : Asn1Encodable
|
||||
{
|
||||
private readonly DerObjectIdentifier commitmentTypeId;
|
||||
|
||||
private readonly Asn1Sequence commitmentTypeQualifier;
|
||||
|
||||
public DerObjectIdentifier CommitmentTypeID => commitmentTypeId;
|
||||
|
||||
public Asn1Sequence CommitmentTypeQualifier => commitmentTypeQualifier;
|
||||
|
||||
public static CommitmentTypeIndication GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is CommitmentTypeIndication)
|
||||
{
|
||||
return (CommitmentTypeIndication)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new CommitmentTypeIndication((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'CommitmentTypeIndication' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
public CommitmentTypeIndication(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");
|
||||
}
|
||||
commitmentTypeId = (DerObjectIdentifier)seq[0].ToAsn1Object();
|
||||
if (seq.Count > 1)
|
||||
{
|
||||
commitmentTypeQualifier = (Asn1Sequence)seq[1].ToAsn1Object();
|
||||
}
|
||||
}
|
||||
|
||||
public CommitmentTypeIndication(DerObjectIdentifier commitmentTypeId)
|
||||
: this(commitmentTypeId, null)
|
||||
{
|
||||
}
|
||||
|
||||
public CommitmentTypeIndication(DerObjectIdentifier commitmentTypeId, Asn1Sequence commitmentTypeQualifier)
|
||||
{
|
||||
if (commitmentTypeId == null)
|
||||
{
|
||||
throw new ArgumentNullException("commitmentTypeId");
|
||||
}
|
||||
this.commitmentTypeId = commitmentTypeId;
|
||||
if (commitmentTypeQualifier != null)
|
||||
{
|
||||
this.commitmentTypeQualifier = commitmentTypeQualifier;
|
||||
}
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector(commitmentTypeId);
|
||||
if (commitmentTypeQualifier != null)
|
||||
{
|
||||
asn1EncodableVector.Add(commitmentTypeQualifier);
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class CommitmentTypeQualifier : Asn1Encodable
|
||||
{
|
||||
private readonly DerObjectIdentifier commitmentTypeIdentifier;
|
||||
|
||||
private readonly Asn1Object qualifier;
|
||||
|
||||
public DerObjectIdentifier CommitmentTypeIdentifier => commitmentTypeIdentifier;
|
||||
|
||||
public Asn1Object Qualifier => qualifier;
|
||||
|
||||
public CommitmentTypeQualifier(DerObjectIdentifier commitmentTypeIdentifier)
|
||||
: this(commitmentTypeIdentifier, null)
|
||||
{
|
||||
}
|
||||
|
||||
public CommitmentTypeQualifier(DerObjectIdentifier commitmentTypeIdentifier, Asn1Encodable qualifier)
|
||||
{
|
||||
if (commitmentTypeIdentifier == null)
|
||||
{
|
||||
throw new ArgumentNullException("commitmentTypeIdentifier");
|
||||
}
|
||||
this.commitmentTypeIdentifier = commitmentTypeIdentifier;
|
||||
if (qualifier != null)
|
||||
{
|
||||
this.qualifier = qualifier.ToAsn1Object();
|
||||
}
|
||||
}
|
||||
|
||||
public CommitmentTypeQualifier(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");
|
||||
}
|
||||
commitmentTypeIdentifier = (DerObjectIdentifier)seq[0].ToAsn1Object();
|
||||
if (seq.Count > 1)
|
||||
{
|
||||
qualifier = seq[1].ToAsn1Object();
|
||||
}
|
||||
}
|
||||
|
||||
public static CommitmentTypeQualifier GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is CommitmentTypeQualifier)
|
||||
{
|
||||
return (CommitmentTypeQualifier)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new CommitmentTypeQualifier((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'CommitmentTypeQualifier' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector(commitmentTypeIdentifier);
|
||||
if (qualifier != null)
|
||||
{
|
||||
asn1EncodableVector.Add(qualifier);
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
using Org.BouncyCastle.Utilities.Collections;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class CompleteCertificateRefs : Asn1Encodable
|
||||
{
|
||||
private readonly Asn1Sequence otherCertIDs;
|
||||
|
||||
public static CompleteCertificateRefs GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is CompleteCertificateRefs)
|
||||
{
|
||||
return (CompleteCertificateRefs)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new CompleteCertificateRefs((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'CompleteCertificateRefs' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private CompleteCertificateRefs(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
foreach (Asn1Encodable item in seq)
|
||||
{
|
||||
OtherCertID.GetInstance(item.ToAsn1Object());
|
||||
}
|
||||
otherCertIDs = seq;
|
||||
}
|
||||
|
||||
public CompleteCertificateRefs(params OtherCertID[] otherCertIDs)
|
||||
{
|
||||
if (otherCertIDs == null)
|
||||
{
|
||||
throw new ArgumentNullException("otherCertIDs");
|
||||
}
|
||||
this.otherCertIDs = new DerSequence(otherCertIDs);
|
||||
}
|
||||
|
||||
public CompleteCertificateRefs(IEnumerable otherCertIDs)
|
||||
{
|
||||
if (otherCertIDs == null)
|
||||
{
|
||||
throw new ArgumentNullException("otherCertIDs");
|
||||
}
|
||||
if (!CollectionUtilities.CheckElementsAreOfType(otherCertIDs, typeof(OtherCertID)))
|
||||
{
|
||||
throw new ArgumentException("Must contain only 'OtherCertID' objects", "otherCertIDs");
|
||||
}
|
||||
this.otherCertIDs = new DerSequence(Asn1EncodableVector.FromEnumerable(otherCertIDs));
|
||||
}
|
||||
|
||||
public OtherCertID[] GetOtherCertIDs()
|
||||
{
|
||||
OtherCertID[] array = new OtherCertID[otherCertIDs.Count];
|
||||
for (int i = 0; i < otherCertIDs.Count; i++)
|
||||
{
|
||||
array[i] = OtherCertID.GetInstance(otherCertIDs[i].ToAsn1Object());
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return otherCertIDs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
using Org.BouncyCastle.Utilities.Collections;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class CompleteRevocationRefs : Asn1Encodable
|
||||
{
|
||||
private readonly Asn1Sequence crlOcspRefs;
|
||||
|
||||
public static CompleteRevocationRefs GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is CompleteRevocationRefs)
|
||||
{
|
||||
return (CompleteRevocationRefs)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new CompleteRevocationRefs((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'CompleteRevocationRefs' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private CompleteRevocationRefs(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
foreach (Asn1Encodable item in seq)
|
||||
{
|
||||
CrlOcspRef.GetInstance(item.ToAsn1Object());
|
||||
}
|
||||
crlOcspRefs = seq;
|
||||
}
|
||||
|
||||
public CompleteRevocationRefs(params CrlOcspRef[] crlOcspRefs)
|
||||
{
|
||||
if (crlOcspRefs == null)
|
||||
{
|
||||
throw new ArgumentNullException("crlOcspRefs");
|
||||
}
|
||||
this.crlOcspRefs = new DerSequence(crlOcspRefs);
|
||||
}
|
||||
|
||||
public CompleteRevocationRefs(IEnumerable crlOcspRefs)
|
||||
{
|
||||
if (crlOcspRefs == null)
|
||||
{
|
||||
throw new ArgumentNullException("crlOcspRefs");
|
||||
}
|
||||
if (!CollectionUtilities.CheckElementsAreOfType(crlOcspRefs, typeof(CrlOcspRef)))
|
||||
{
|
||||
throw new ArgumentException("Must contain only 'CrlOcspRef' objects", "crlOcspRefs");
|
||||
}
|
||||
this.crlOcspRefs = new DerSequence(Asn1EncodableVector.FromEnumerable(crlOcspRefs));
|
||||
}
|
||||
|
||||
public CrlOcspRef[] GetCrlOcspRefs()
|
||||
{
|
||||
CrlOcspRef[] array = new CrlOcspRef[crlOcspRefs.Count];
|
||||
for (int i = 0; i < crlOcspRefs.Count; i++)
|
||||
{
|
||||
array[i] = CrlOcspRef.GetInstance(crlOcspRefs[i].ToAsn1Object());
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return crlOcspRefs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Math;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class CrlIdentifier : Asn1Encodable
|
||||
{
|
||||
private readonly X509Name crlIssuer;
|
||||
|
||||
private readonly DerUtcTime crlIssuedTime;
|
||||
|
||||
private readonly DerInteger crlNumber;
|
||||
|
||||
public X509Name CrlIssuer => crlIssuer;
|
||||
|
||||
public DateTime CrlIssuedTime => crlIssuedTime.ToAdjustedDateTime();
|
||||
|
||||
public BigInteger CrlNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
if (crlNumber != null)
|
||||
{
|
||||
return crlNumber.Value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static CrlIdentifier GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is CrlIdentifier)
|
||||
{
|
||||
return (CrlIdentifier)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new CrlIdentifier((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'CrlIdentifier' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private CrlIdentifier(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
if (seq.Count < 2 || seq.Count > 3)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
|
||||
}
|
||||
crlIssuer = X509Name.GetInstance(seq[0]);
|
||||
crlIssuedTime = DerUtcTime.GetInstance(seq[1]);
|
||||
if (seq.Count > 2)
|
||||
{
|
||||
crlNumber = DerInteger.GetInstance(seq[2]);
|
||||
}
|
||||
}
|
||||
|
||||
public CrlIdentifier(X509Name crlIssuer, DateTime crlIssuedTime)
|
||||
: this(crlIssuer, crlIssuedTime, null)
|
||||
{
|
||||
}
|
||||
|
||||
public CrlIdentifier(X509Name crlIssuer, DateTime crlIssuedTime, BigInteger crlNumber)
|
||||
{
|
||||
if (crlIssuer == null)
|
||||
{
|
||||
throw new ArgumentNullException("crlIssuer");
|
||||
}
|
||||
this.crlIssuer = crlIssuer;
|
||||
this.crlIssuedTime = new DerUtcTime(crlIssuedTime);
|
||||
if (crlNumber != null)
|
||||
{
|
||||
this.crlNumber = new DerInteger(crlNumber);
|
||||
}
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector(crlIssuer.ToAsn1Object(), crlIssuedTime);
|
||||
if (crlNumber != null)
|
||||
{
|
||||
asn1EncodableVector.Add(crlNumber);
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
using Org.BouncyCastle.Utilities.Collections;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class CrlListID : Asn1Encodable
|
||||
{
|
||||
private readonly Asn1Sequence crls;
|
||||
|
||||
public static CrlListID GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is CrlListID)
|
||||
{
|
||||
return (CrlListID)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new CrlListID((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'CrlListID' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private CrlListID(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
if (seq.Count != 1)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
|
||||
}
|
||||
crls = (Asn1Sequence)seq[0].ToAsn1Object();
|
||||
foreach (Asn1Encodable crl in crls)
|
||||
{
|
||||
CrlValidatedID.GetInstance(crl.ToAsn1Object());
|
||||
}
|
||||
}
|
||||
|
||||
public CrlListID(params CrlValidatedID[] crls)
|
||||
{
|
||||
if (crls == null)
|
||||
{
|
||||
throw new ArgumentNullException("crls");
|
||||
}
|
||||
this.crls = new DerSequence(crls);
|
||||
}
|
||||
|
||||
public CrlListID(IEnumerable crls)
|
||||
{
|
||||
if (crls == null)
|
||||
{
|
||||
throw new ArgumentNullException("crls");
|
||||
}
|
||||
if (!CollectionUtilities.CheckElementsAreOfType(crls, typeof(CrlValidatedID)))
|
||||
{
|
||||
throw new ArgumentException("Must contain only 'CrlValidatedID' objects", "crls");
|
||||
}
|
||||
this.crls = new DerSequence(Asn1EncodableVector.FromEnumerable(crls));
|
||||
}
|
||||
|
||||
public CrlValidatedID[] GetCrls()
|
||||
{
|
||||
CrlValidatedID[] array = new CrlValidatedID[crls.Count];
|
||||
for (int i = 0; i < crls.Count; i++)
|
||||
{
|
||||
array[i] = CrlValidatedID.GetInstance(crls[i].ToAsn1Object());
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return new DerSequence(crls);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class CrlOcspRef : Asn1Encodable
|
||||
{
|
||||
private readonly CrlListID crlids;
|
||||
|
||||
private readonly OcspListID ocspids;
|
||||
|
||||
private readonly OtherRevRefs otherRev;
|
||||
|
||||
public CrlListID CrlIDs => crlids;
|
||||
|
||||
public OcspListID OcspIDs => ocspids;
|
||||
|
||||
public OtherRevRefs OtherRev => otherRev;
|
||||
|
||||
public static CrlOcspRef GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is CrlOcspRef)
|
||||
{
|
||||
return (CrlOcspRef)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new CrlOcspRef((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'CrlOcspRef' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private CrlOcspRef(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
foreach (Asn1TaggedObject item in seq)
|
||||
{
|
||||
Asn1Object obj = item.GetObject();
|
||||
switch (item.TagNo)
|
||||
{
|
||||
case 0:
|
||||
crlids = CrlListID.GetInstance(obj);
|
||||
break;
|
||||
case 1:
|
||||
ocspids = OcspListID.GetInstance(obj);
|
||||
break;
|
||||
case 2:
|
||||
otherRev = OtherRevRefs.GetInstance(obj);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Illegal tag in CrlOcspRef", "seq");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CrlOcspRef(CrlListID crlids, OcspListID ocspids, OtherRevRefs otherRev)
|
||||
{
|
||||
this.crlids = crlids;
|
||||
this.ocspids = ocspids;
|
||||
this.otherRev = otherRev;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();
|
||||
if (crlids != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 0, crlids.ToAsn1Object()));
|
||||
}
|
||||
if (ocspids != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 1, ocspids.ToAsn1Object()));
|
||||
}
|
||||
if (otherRev != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 2, otherRev.ToAsn1Object()));
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class CrlValidatedID : Asn1Encodable
|
||||
{
|
||||
private readonly OtherHash crlHash;
|
||||
|
||||
private readonly CrlIdentifier crlIdentifier;
|
||||
|
||||
public OtherHash CrlHash => crlHash;
|
||||
|
||||
public CrlIdentifier CrlIdentifier => crlIdentifier;
|
||||
|
||||
public static CrlValidatedID GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is CrlValidatedID)
|
||||
{
|
||||
return (CrlValidatedID)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new CrlValidatedID((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'CrlValidatedID' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private CrlValidatedID(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");
|
||||
}
|
||||
crlHash = OtherHash.GetInstance(seq[0].ToAsn1Object());
|
||||
if (seq.Count > 1)
|
||||
{
|
||||
crlIdentifier = CrlIdentifier.GetInstance(seq[1].ToAsn1Object());
|
||||
}
|
||||
}
|
||||
|
||||
public CrlValidatedID(OtherHash crlHash)
|
||||
: this(crlHash, null)
|
||||
{
|
||||
}
|
||||
|
||||
public CrlValidatedID(OtherHash crlHash, CrlIdentifier crlIdentifier)
|
||||
{
|
||||
if (crlHash == null)
|
||||
{
|
||||
throw new ArgumentNullException("crlHash");
|
||||
}
|
||||
this.crlHash = crlHash;
|
||||
this.crlIdentifier = crlIdentifier;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector(crlHash.ToAsn1Object());
|
||||
if (crlIdentifier != null)
|
||||
{
|
||||
asn1EncodableVector.Add(crlIdentifier.ToAsn1Object());
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Org.BouncyCastle.Asn1.Pkcs;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public abstract class EsfAttributes
|
||||
{
|
||||
public static readonly DerObjectIdentifier SigPolicyId = PkcsObjectIdentifiers.IdAAEtsSigPolicyID;
|
||||
|
||||
public static readonly DerObjectIdentifier CommitmentType = PkcsObjectIdentifiers.IdAAEtsCommitmentType;
|
||||
|
||||
public static readonly DerObjectIdentifier SignerLocation = PkcsObjectIdentifiers.IdAAEtsSignerLocation;
|
||||
|
||||
public static readonly DerObjectIdentifier SignerAttr = PkcsObjectIdentifiers.IdAAEtsSignerAttr;
|
||||
|
||||
public static readonly DerObjectIdentifier OtherSigCert = PkcsObjectIdentifiers.IdAAEtsOtherSigCert;
|
||||
|
||||
public static readonly DerObjectIdentifier ContentTimestamp = PkcsObjectIdentifiers.IdAAEtsContentTimestamp;
|
||||
|
||||
public static readonly DerObjectIdentifier CertificateRefs = PkcsObjectIdentifiers.IdAAEtsCertificateRefs;
|
||||
|
||||
public static readonly DerObjectIdentifier RevocationRefs = PkcsObjectIdentifiers.IdAAEtsRevocationRefs;
|
||||
|
||||
public static readonly DerObjectIdentifier CertValues = PkcsObjectIdentifiers.IdAAEtsCertValues;
|
||||
|
||||
public static readonly DerObjectIdentifier RevocationValues = PkcsObjectIdentifiers.IdAAEtsRevocationValues;
|
||||
|
||||
public static readonly DerObjectIdentifier EscTimeStamp = PkcsObjectIdentifiers.IdAAEtsEscTimeStamp;
|
||||
|
||||
public static readonly DerObjectIdentifier CertCrlTimestamp = PkcsObjectIdentifiers.IdAAEtsCertCrlTimestamp;
|
||||
|
||||
public static readonly DerObjectIdentifier ArchiveTimestamp = PkcsObjectIdentifiers.IdAAEtsArchiveTimestamp;
|
||||
|
||||
public static readonly DerObjectIdentifier ArchiveTimestampV2 = new DerObjectIdentifier("1.2.840.113549.1.9.16.2.48");
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Asn1.Ocsp;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class OcspIdentifier : Asn1Encodable
|
||||
{
|
||||
private readonly ResponderID ocspResponderID;
|
||||
|
||||
private readonly DerGeneralizedTime producedAt;
|
||||
|
||||
public ResponderID OcspResponderID => ocspResponderID;
|
||||
|
||||
public DateTime ProducedAt => producedAt.ToDateTime();
|
||||
|
||||
public static OcspIdentifier GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is OcspIdentifier)
|
||||
{
|
||||
return (OcspIdentifier)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new OcspIdentifier((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'OcspIdentifier' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private OcspIdentifier(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
if (seq.Count != 2)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
|
||||
}
|
||||
ocspResponderID = ResponderID.GetInstance(seq[0].ToAsn1Object());
|
||||
producedAt = (DerGeneralizedTime)seq[1].ToAsn1Object();
|
||||
}
|
||||
|
||||
public OcspIdentifier(ResponderID ocspResponderID, DateTime producedAt)
|
||||
{
|
||||
if (ocspResponderID == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
this.ocspResponderID = ocspResponderID;
|
||||
this.producedAt = new DerGeneralizedTime(producedAt);
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return new DerSequence(ocspResponderID, producedAt);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
using Org.BouncyCastle.Utilities.Collections;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class OcspListID : Asn1Encodable
|
||||
{
|
||||
private readonly Asn1Sequence ocspResponses;
|
||||
|
||||
public static OcspListID GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is OcspListID)
|
||||
{
|
||||
return (OcspListID)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new OcspListID((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'OcspListID' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private OcspListID(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
if (seq.Count != 1)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
|
||||
}
|
||||
ocspResponses = (Asn1Sequence)seq[0].ToAsn1Object();
|
||||
foreach (Asn1Encodable ocspResponse in ocspResponses)
|
||||
{
|
||||
OcspResponsesID.GetInstance(ocspResponse.ToAsn1Object());
|
||||
}
|
||||
}
|
||||
|
||||
public OcspListID(params OcspResponsesID[] ocspResponses)
|
||||
{
|
||||
if (ocspResponses == null)
|
||||
{
|
||||
throw new ArgumentNullException("ocspResponses");
|
||||
}
|
||||
this.ocspResponses = new DerSequence(ocspResponses);
|
||||
}
|
||||
|
||||
public OcspListID(IEnumerable ocspResponses)
|
||||
{
|
||||
if (ocspResponses == null)
|
||||
{
|
||||
throw new ArgumentNullException("ocspResponses");
|
||||
}
|
||||
if (!CollectionUtilities.CheckElementsAreOfType(ocspResponses, typeof(OcspResponsesID)))
|
||||
{
|
||||
throw new ArgumentException("Must contain only 'OcspResponsesID' objects", "ocspResponses");
|
||||
}
|
||||
this.ocspResponses = new DerSequence(Asn1EncodableVector.FromEnumerable(ocspResponses));
|
||||
}
|
||||
|
||||
public OcspResponsesID[] GetOcspResponses()
|
||||
{
|
||||
OcspResponsesID[] array = new OcspResponsesID[ocspResponses.Count];
|
||||
for (int i = 0; i < ocspResponses.Count; i++)
|
||||
{
|
||||
array[i] = OcspResponsesID.GetInstance(ocspResponses[i].ToAsn1Object());
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return new DerSequence(ocspResponses);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class OcspResponsesID : Asn1Encodable
|
||||
{
|
||||
private readonly OcspIdentifier ocspIdentifier;
|
||||
|
||||
private readonly OtherHash ocspRepHash;
|
||||
|
||||
public OcspIdentifier OcspIdentifier => ocspIdentifier;
|
||||
|
||||
public OtherHash OcspRepHash => ocspRepHash;
|
||||
|
||||
public static OcspResponsesID GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is OcspResponsesID)
|
||||
{
|
||||
return (OcspResponsesID)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new OcspResponsesID((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'OcspResponsesID' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private OcspResponsesID(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");
|
||||
}
|
||||
ocspIdentifier = OcspIdentifier.GetInstance(seq[0].ToAsn1Object());
|
||||
if (seq.Count > 1)
|
||||
{
|
||||
ocspRepHash = OtherHash.GetInstance(seq[1].ToAsn1Object());
|
||||
}
|
||||
}
|
||||
|
||||
public OcspResponsesID(OcspIdentifier ocspIdentifier)
|
||||
: this(ocspIdentifier, null)
|
||||
{
|
||||
}
|
||||
|
||||
public OcspResponsesID(OcspIdentifier ocspIdentifier, OtherHash ocspRepHash)
|
||||
{
|
||||
if (ocspIdentifier == null)
|
||||
{
|
||||
throw new ArgumentNullException("ocspIdentifier");
|
||||
}
|
||||
this.ocspIdentifier = ocspIdentifier;
|
||||
this.ocspRepHash = ocspRepHash;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector(ocspIdentifier.ToAsn1Object());
|
||||
if (ocspRepHash != null)
|
||||
{
|
||||
asn1EncodableVector.Add(ocspRepHash.ToAsn1Object());
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class OtherCertID : Asn1Encodable
|
||||
{
|
||||
private readonly OtherHash otherCertHash;
|
||||
|
||||
private readonly IssuerSerial issuerSerial;
|
||||
|
||||
public OtherHash OtherCertHash => otherCertHash;
|
||||
|
||||
public IssuerSerial IssuerSerial => issuerSerial;
|
||||
|
||||
public static OtherCertID GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is OtherCertID)
|
||||
{
|
||||
return (OtherCertID)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new OtherCertID((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'OtherCertID' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
otherCertHash = OtherHash.GetInstance(seq[0].ToAsn1Object());
|
||||
if (seq.Count > 1)
|
||||
{
|
||||
issuerSerial = IssuerSerial.GetInstance(seq[1].ToAsn1Object());
|
||||
}
|
||||
}
|
||||
|
||||
public OtherCertID(OtherHash otherCertHash)
|
||||
: this(otherCertHash, null)
|
||||
{
|
||||
}
|
||||
|
||||
public OtherCertID(OtherHash otherCertHash, IssuerSerial issuerSerial)
|
||||
{
|
||||
if (otherCertHash == null)
|
||||
{
|
||||
throw new ArgumentNullException("otherCertHash");
|
||||
}
|
||||
this.otherCertHash = otherCertHash;
|
||||
this.issuerSerial = issuerSerial;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector(otherCertHash.ToAsn1Object());
|
||||
if (issuerSerial != null)
|
||||
{
|
||||
asn1EncodableVector.Add(issuerSerial.ToAsn1Object());
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Asn1.Oiw;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class OtherHash : Asn1Encodable, IAsn1Choice
|
||||
{
|
||||
private readonly Asn1OctetString sha1Hash;
|
||||
|
||||
private readonly OtherHashAlgAndValue otherHash;
|
||||
|
||||
public AlgorithmIdentifier HashAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
if (otherHash != null)
|
||||
{
|
||||
return otherHash.HashAlgorithm;
|
||||
}
|
||||
return new AlgorithmIdentifier(OiwObjectIdentifiers.IdSha1);
|
||||
}
|
||||
}
|
||||
|
||||
public static OtherHash GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is OtherHash)
|
||||
{
|
||||
return (OtherHash)obj;
|
||||
}
|
||||
if (obj is Asn1OctetString)
|
||||
{
|
||||
return new OtherHash((Asn1OctetString)obj);
|
||||
}
|
||||
return new OtherHash(OtherHashAlgAndValue.GetInstance(obj));
|
||||
}
|
||||
|
||||
public OtherHash(byte[] sha1Hash)
|
||||
{
|
||||
if (sha1Hash == null)
|
||||
{
|
||||
throw new ArgumentNullException("sha1Hash");
|
||||
}
|
||||
this.sha1Hash = new DerOctetString(sha1Hash);
|
||||
}
|
||||
|
||||
public OtherHash(Asn1OctetString sha1Hash)
|
||||
{
|
||||
if (sha1Hash == null)
|
||||
{
|
||||
throw new ArgumentNullException("sha1Hash");
|
||||
}
|
||||
this.sha1Hash = sha1Hash;
|
||||
}
|
||||
|
||||
public OtherHash(OtherHashAlgAndValue otherHash)
|
||||
{
|
||||
if (otherHash == null)
|
||||
{
|
||||
throw new ArgumentNullException("otherHash");
|
||||
}
|
||||
this.otherHash = otherHash;
|
||||
}
|
||||
|
||||
public byte[] GetHashValue()
|
||||
{
|
||||
if (otherHash != null)
|
||||
{
|
||||
return otherHash.GetHashValue();
|
||||
}
|
||||
return sha1Hash.GetOctets();
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
if (otherHash != null)
|
||||
{
|
||||
return otherHash.ToAsn1Object();
|
||||
}
|
||||
return sha1Hash;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class OtherHashAlgAndValue : Asn1Encodable
|
||||
{
|
||||
private readonly AlgorithmIdentifier hashAlgorithm;
|
||||
|
||||
private readonly Asn1OctetString hashValue;
|
||||
|
||||
public AlgorithmIdentifier HashAlgorithm => hashAlgorithm;
|
||||
|
||||
public static OtherHashAlgAndValue GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is OtherHashAlgAndValue)
|
||||
{
|
||||
return (OtherHashAlgAndValue)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new OtherHashAlgAndValue((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'OtherHashAlgAndValue' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private OtherHashAlgAndValue(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
if (seq.Count != 2)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
|
||||
}
|
||||
hashAlgorithm = AlgorithmIdentifier.GetInstance(seq[0].ToAsn1Object());
|
||||
hashValue = (Asn1OctetString)seq[1].ToAsn1Object();
|
||||
}
|
||||
|
||||
public OtherHashAlgAndValue(AlgorithmIdentifier hashAlgorithm, byte[] hashValue)
|
||||
{
|
||||
if (hashAlgorithm == null)
|
||||
{
|
||||
throw new ArgumentNullException("hashAlgorithm");
|
||||
}
|
||||
if (hashValue == null)
|
||||
{
|
||||
throw new ArgumentNullException("hashValue");
|
||||
}
|
||||
this.hashAlgorithm = hashAlgorithm;
|
||||
this.hashValue = new DerOctetString(hashValue);
|
||||
}
|
||||
|
||||
public OtherHashAlgAndValue(AlgorithmIdentifier hashAlgorithm, Asn1OctetString hashValue)
|
||||
{
|
||||
if (hashAlgorithm == null)
|
||||
{
|
||||
throw new ArgumentNullException("hashAlgorithm");
|
||||
}
|
||||
if (hashValue == null)
|
||||
{
|
||||
throw new ArgumentNullException("hashValue");
|
||||
}
|
||||
this.hashAlgorithm = hashAlgorithm;
|
||||
this.hashValue = hashValue;
|
||||
}
|
||||
|
||||
public byte[] GetHashValue()
|
||||
{
|
||||
return hashValue.GetOctets();
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return new DerSequence(hashAlgorithm, hashValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class OtherRevRefs : Asn1Encodable
|
||||
{
|
||||
private readonly DerObjectIdentifier otherRevRefType;
|
||||
|
||||
private readonly Asn1Object otherRevRefs;
|
||||
|
||||
public DerObjectIdentifier OtherRevRefType => otherRevRefType;
|
||||
|
||||
public Asn1Object OtherRevRefsObject => otherRevRefs;
|
||||
|
||||
public static OtherRevRefs GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is OtherRevRefs)
|
||||
{
|
||||
return (OtherRevRefs)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new OtherRevRefs((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'OtherRevRefs' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private OtherRevRefs(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
if (seq.Count != 2)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
|
||||
}
|
||||
otherRevRefType = (DerObjectIdentifier)seq[0].ToAsn1Object();
|
||||
otherRevRefs = seq[1].ToAsn1Object();
|
||||
}
|
||||
|
||||
public OtherRevRefs(DerObjectIdentifier otherRevRefType, Asn1Encodable otherRevRefs)
|
||||
{
|
||||
if (otherRevRefType == null)
|
||||
{
|
||||
throw new ArgumentNullException("otherRevRefType");
|
||||
}
|
||||
if (otherRevRefs == null)
|
||||
{
|
||||
throw new ArgumentNullException("otherRevRefs");
|
||||
}
|
||||
this.otherRevRefType = otherRevRefType;
|
||||
this.otherRevRefs = otherRevRefs.ToAsn1Object();
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return new DerSequence(otherRevRefType, otherRevRefs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class OtherRevVals : Asn1Encodable
|
||||
{
|
||||
private readonly DerObjectIdentifier otherRevValType;
|
||||
|
||||
private readonly Asn1Object otherRevVals;
|
||||
|
||||
public DerObjectIdentifier OtherRevValType => otherRevValType;
|
||||
|
||||
public Asn1Object OtherRevValsObject => otherRevVals;
|
||||
|
||||
public static OtherRevVals GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is OtherRevVals)
|
||||
{
|
||||
return (OtherRevVals)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new OtherRevVals((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'OtherRevVals' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private OtherRevVals(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
if (seq.Count != 2)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
|
||||
}
|
||||
otherRevValType = (DerObjectIdentifier)seq[0].ToAsn1Object();
|
||||
otherRevVals = seq[1].ToAsn1Object();
|
||||
}
|
||||
|
||||
public OtherRevVals(DerObjectIdentifier otherRevValType, Asn1Encodable otherRevVals)
|
||||
{
|
||||
if (otherRevValType == null)
|
||||
{
|
||||
throw new ArgumentNullException("otherRevValType");
|
||||
}
|
||||
if (otherRevVals == null)
|
||||
{
|
||||
throw new ArgumentNullException("otherRevVals");
|
||||
}
|
||||
this.otherRevValType = otherRevValType;
|
||||
this.otherRevVals = otherRevVals.ToAsn1Object();
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return new DerSequence(otherRevValType, otherRevVals);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
using Org.BouncyCastle.Utilities.Collections;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class OtherSigningCertificate : Asn1Encodable
|
||||
{
|
||||
private readonly Asn1Sequence certs;
|
||||
|
||||
private readonly Asn1Sequence policies;
|
||||
|
||||
public static OtherSigningCertificate GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is OtherSigningCertificate)
|
||||
{
|
||||
return (OtherSigningCertificate)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new OtherSigningCertificate((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'OtherSigningCertificate' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private OtherSigningCertificate(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");
|
||||
}
|
||||
certs = Asn1Sequence.GetInstance(seq[0].ToAsn1Object());
|
||||
if (seq.Count > 1)
|
||||
{
|
||||
policies = Asn1Sequence.GetInstance(seq[1].ToAsn1Object());
|
||||
}
|
||||
}
|
||||
|
||||
public OtherSigningCertificate(params OtherCertID[] certs)
|
||||
: this(certs, (PolicyInformation[])null)
|
||||
{
|
||||
}
|
||||
|
||||
public OtherSigningCertificate(OtherCertID[] certs, params PolicyInformation[] policies)
|
||||
{
|
||||
if (certs == null)
|
||||
{
|
||||
throw new ArgumentNullException("certs");
|
||||
}
|
||||
this.certs = new DerSequence(certs);
|
||||
if (policies != null)
|
||||
{
|
||||
this.policies = new DerSequence(policies);
|
||||
}
|
||||
}
|
||||
|
||||
public OtherSigningCertificate(IEnumerable certs)
|
||||
: this(certs, null)
|
||||
{
|
||||
}
|
||||
|
||||
public OtherSigningCertificate(IEnumerable certs, IEnumerable policies)
|
||||
{
|
||||
if (certs == null)
|
||||
{
|
||||
throw new ArgumentNullException("certs");
|
||||
}
|
||||
if (!CollectionUtilities.CheckElementsAreOfType(certs, typeof(OtherCertID)))
|
||||
{
|
||||
throw new ArgumentException("Must contain only 'OtherCertID' objects", "certs");
|
||||
}
|
||||
this.certs = new DerSequence(Asn1EncodableVector.FromEnumerable(certs));
|
||||
if (policies != null)
|
||||
{
|
||||
if (!CollectionUtilities.CheckElementsAreOfType(policies, typeof(PolicyInformation)))
|
||||
{
|
||||
throw new ArgumentException("Must contain only 'PolicyInformation' objects", "policies");
|
||||
}
|
||||
this.policies = new DerSequence(Asn1EncodableVector.FromEnumerable(policies));
|
||||
}
|
||||
}
|
||||
|
||||
public OtherCertID[] GetCerts()
|
||||
{
|
||||
OtherCertID[] array = new OtherCertID[certs.Count];
|
||||
for (int i = 0; i < certs.Count; i++)
|
||||
{
|
||||
array[i] = OtherCertID.GetInstance(certs[i].ToAsn1Object());
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public PolicyInformation[] GetPolicies()
|
||||
{
|
||||
if (policies == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
PolicyInformation[] array = new PolicyInformation[policies.Count];
|
||||
for (int i = 0; i < policies.Count; i++)
|
||||
{
|
||||
array[i] = PolicyInformation.GetInstance(policies[i].ToAsn1Object());
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector(certs);
|
||||
if (policies != null)
|
||||
{
|
||||
asn1EncodableVector.Add(policies);
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Org.BouncyCastle.Asn1.Ocsp;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Utilities.Collections;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class RevocationValues : Asn1Encodable
|
||||
{
|
||||
private readonly Asn1Sequence crlVals;
|
||||
|
||||
private readonly Asn1Sequence ocspVals;
|
||||
|
||||
private readonly OtherRevVals otherRevVals;
|
||||
|
||||
public OtherRevVals OtherRevVals => otherRevVals;
|
||||
|
||||
public static RevocationValues GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is RevocationValues)
|
||||
{
|
||||
return (RevocationValues)obj;
|
||||
}
|
||||
return new RevocationValues(Asn1Sequence.GetInstance(obj));
|
||||
}
|
||||
|
||||
private RevocationValues(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
if (seq.Count > 3)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
|
||||
}
|
||||
foreach (Asn1TaggedObject item in seq)
|
||||
{
|
||||
Asn1Object asn1Object = item.GetObject();
|
||||
switch (item.TagNo)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Asn1Sequence asn1Sequence2 = (Asn1Sequence)asn1Object;
|
||||
foreach (Asn1Encodable item2 in asn1Sequence2)
|
||||
{
|
||||
CertificateList.GetInstance(item2.ToAsn1Object());
|
||||
}
|
||||
crlVals = asn1Sequence2;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
Asn1Sequence asn1Sequence = (Asn1Sequence)asn1Object;
|
||||
foreach (Asn1Encodable item3 in asn1Sequence)
|
||||
{
|
||||
BasicOcspResponse.GetInstance(item3.ToAsn1Object());
|
||||
}
|
||||
ocspVals = asn1Sequence;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
otherRevVals = OtherRevVals.GetInstance(asn1Object);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Illegal tag in RevocationValues", "seq");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public RevocationValues(CertificateList[] crlVals, BasicOcspResponse[] ocspVals, OtherRevVals otherRevVals)
|
||||
{
|
||||
if (crlVals != null)
|
||||
{
|
||||
this.crlVals = new DerSequence(crlVals);
|
||||
}
|
||||
if (ocspVals != null)
|
||||
{
|
||||
this.ocspVals = new DerSequence(ocspVals);
|
||||
}
|
||||
this.otherRevVals = otherRevVals;
|
||||
}
|
||||
|
||||
public RevocationValues(IEnumerable crlVals, IEnumerable ocspVals, OtherRevVals otherRevVals)
|
||||
{
|
||||
if (crlVals != null)
|
||||
{
|
||||
if (!CollectionUtilities.CheckElementsAreOfType(crlVals, typeof(CertificateList)))
|
||||
{
|
||||
throw new ArgumentException("Must contain only 'CertificateList' objects", "crlVals");
|
||||
}
|
||||
this.crlVals = new DerSequence(Asn1EncodableVector.FromEnumerable(crlVals));
|
||||
}
|
||||
if (ocspVals != null)
|
||||
{
|
||||
if (!CollectionUtilities.CheckElementsAreOfType(ocspVals, typeof(BasicOcspResponse)))
|
||||
{
|
||||
throw new ArgumentException("Must contain only 'BasicOcspResponse' objects", "ocspVals");
|
||||
}
|
||||
this.ocspVals = new DerSequence(Asn1EncodableVector.FromEnumerable(ocspVals));
|
||||
}
|
||||
this.otherRevVals = otherRevVals;
|
||||
}
|
||||
|
||||
public CertificateList[] GetCrlVals()
|
||||
{
|
||||
CertificateList[] array = new CertificateList[crlVals.Count];
|
||||
for (int i = 0; i < crlVals.Count; i++)
|
||||
{
|
||||
array[i] = CertificateList.GetInstance(crlVals[i].ToAsn1Object());
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public BasicOcspResponse[] GetOcspVals()
|
||||
{
|
||||
BasicOcspResponse[] array = new BasicOcspResponse[ocspVals.Count];
|
||||
for (int i = 0; i < ocspVals.Count; i++)
|
||||
{
|
||||
array[i] = BasicOcspResponse.GetInstance(ocspVals[i].ToAsn1Object());
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();
|
||||
if (crlVals != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 0, crlVals));
|
||||
}
|
||||
if (ocspVals != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 1, ocspVals));
|
||||
}
|
||||
if (otherRevVals != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 2, otherRevVals.ToAsn1Object()));
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class SigPolicyQualifierInfo : Asn1Encodable
|
||||
{
|
||||
private readonly DerObjectIdentifier sigPolicyQualifierId;
|
||||
|
||||
private readonly Asn1Object sigQualifier;
|
||||
|
||||
public DerObjectIdentifier SigPolicyQualifierId => sigPolicyQualifierId;
|
||||
|
||||
public Asn1Object SigQualifier => sigQualifier;
|
||||
|
||||
public static SigPolicyQualifierInfo GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is SigPolicyQualifierInfo)
|
||||
{
|
||||
return (SigPolicyQualifierInfo)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new SigPolicyQualifierInfo((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'SigPolicyQualifierInfo' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private SigPolicyQualifierInfo(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
if (seq.Count != 2)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
|
||||
}
|
||||
sigPolicyQualifierId = (DerObjectIdentifier)seq[0].ToAsn1Object();
|
||||
sigQualifier = seq[1].ToAsn1Object();
|
||||
}
|
||||
|
||||
public SigPolicyQualifierInfo(DerObjectIdentifier sigPolicyQualifierId, Asn1Encodable sigQualifier)
|
||||
{
|
||||
this.sigPolicyQualifierId = sigPolicyQualifierId;
|
||||
this.sigQualifier = sigQualifier.ToAsn1Object();
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return new DerSequence(sigPolicyQualifierId, sigQualifier);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
using Org.BouncyCastle.Utilities.Collections;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class SignaturePolicyId : Asn1Encodable
|
||||
{
|
||||
private readonly DerObjectIdentifier sigPolicyIdentifier;
|
||||
|
||||
private readonly OtherHashAlgAndValue sigPolicyHash;
|
||||
|
||||
private readonly Asn1Sequence sigPolicyQualifiers;
|
||||
|
||||
public DerObjectIdentifier SigPolicyIdentifier => sigPolicyIdentifier;
|
||||
|
||||
public OtherHashAlgAndValue SigPolicyHash => sigPolicyHash;
|
||||
|
||||
public static SignaturePolicyId GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is SignaturePolicyId)
|
||||
{
|
||||
return (SignaturePolicyId)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new SignaturePolicyId((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'SignaturePolicyId' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private SignaturePolicyId(Asn1Sequence seq)
|
||||
{
|
||||
if (seq == null)
|
||||
{
|
||||
throw new ArgumentNullException("seq");
|
||||
}
|
||||
if (seq.Count < 2 || seq.Count > 3)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
|
||||
}
|
||||
sigPolicyIdentifier = (DerObjectIdentifier)seq[0].ToAsn1Object();
|
||||
sigPolicyHash = OtherHashAlgAndValue.GetInstance(seq[1].ToAsn1Object());
|
||||
if (seq.Count > 2)
|
||||
{
|
||||
sigPolicyQualifiers = (Asn1Sequence)seq[2].ToAsn1Object();
|
||||
}
|
||||
}
|
||||
|
||||
public SignaturePolicyId(DerObjectIdentifier sigPolicyIdentifier, OtherHashAlgAndValue sigPolicyHash)
|
||||
: this(sigPolicyIdentifier, sigPolicyHash, (SigPolicyQualifierInfo[])null)
|
||||
{
|
||||
}
|
||||
|
||||
public SignaturePolicyId(DerObjectIdentifier sigPolicyIdentifier, OtherHashAlgAndValue sigPolicyHash, params SigPolicyQualifierInfo[] sigPolicyQualifiers)
|
||||
{
|
||||
if (sigPolicyIdentifier == null)
|
||||
{
|
||||
throw new ArgumentNullException("sigPolicyIdentifier");
|
||||
}
|
||||
if (sigPolicyHash == null)
|
||||
{
|
||||
throw new ArgumentNullException("sigPolicyHash");
|
||||
}
|
||||
this.sigPolicyIdentifier = sigPolicyIdentifier;
|
||||
this.sigPolicyHash = sigPolicyHash;
|
||||
if (sigPolicyQualifiers != null)
|
||||
{
|
||||
this.sigPolicyQualifiers = new DerSequence(sigPolicyQualifiers);
|
||||
}
|
||||
}
|
||||
|
||||
public SignaturePolicyId(DerObjectIdentifier sigPolicyIdentifier, OtherHashAlgAndValue sigPolicyHash, IEnumerable sigPolicyQualifiers)
|
||||
{
|
||||
if (sigPolicyIdentifier == null)
|
||||
{
|
||||
throw new ArgumentNullException("sigPolicyIdentifier");
|
||||
}
|
||||
if (sigPolicyHash == null)
|
||||
{
|
||||
throw new ArgumentNullException("sigPolicyHash");
|
||||
}
|
||||
this.sigPolicyIdentifier = sigPolicyIdentifier;
|
||||
this.sigPolicyHash = sigPolicyHash;
|
||||
if (sigPolicyQualifiers != null)
|
||||
{
|
||||
if (!CollectionUtilities.CheckElementsAreOfType(sigPolicyQualifiers, typeof(SigPolicyQualifierInfo)))
|
||||
{
|
||||
throw new ArgumentException("Must contain only 'SigPolicyQualifierInfo' objects", "sigPolicyQualifiers");
|
||||
}
|
||||
this.sigPolicyQualifiers = new DerSequence(Asn1EncodableVector.FromEnumerable(sigPolicyQualifiers));
|
||||
}
|
||||
}
|
||||
|
||||
public SigPolicyQualifierInfo[] GetSigPolicyQualifiers()
|
||||
{
|
||||
if (sigPolicyQualifiers == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
SigPolicyQualifierInfo[] array = new SigPolicyQualifierInfo[sigPolicyQualifiers.Count];
|
||||
for (int i = 0; i < sigPolicyQualifiers.Count; i++)
|
||||
{
|
||||
array[i] = SigPolicyQualifierInfo.GetInstance(sigPolicyQualifiers[i]);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector(sigPolicyIdentifier, sigPolicyHash.ToAsn1Object());
|
||||
if (sigPolicyQualifiers != null)
|
||||
{
|
||||
asn1EncodableVector.Add(sigPolicyQualifiers.ToAsn1Object());
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class SignaturePolicyIdentifier : Asn1Encodable, IAsn1Choice
|
||||
{
|
||||
private readonly SignaturePolicyId sigPolicy;
|
||||
|
||||
public SignaturePolicyId SignaturePolicyId => sigPolicy;
|
||||
|
||||
public static SignaturePolicyIdentifier GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is SignaturePolicyIdentifier)
|
||||
{
|
||||
return (SignaturePolicyIdentifier)obj;
|
||||
}
|
||||
if (obj is SignaturePolicyId)
|
||||
{
|
||||
return new SignaturePolicyIdentifier((SignaturePolicyId)obj);
|
||||
}
|
||||
if (obj is Asn1Null)
|
||||
{
|
||||
return new SignaturePolicyIdentifier();
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'SignaturePolicyIdentifier' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
public SignaturePolicyIdentifier()
|
||||
{
|
||||
sigPolicy = null;
|
||||
}
|
||||
|
||||
public SignaturePolicyIdentifier(SignaturePolicyId signaturePolicyId)
|
||||
{
|
||||
if (signaturePolicyId == null)
|
||||
{
|
||||
throw new ArgumentNullException("signaturePolicyId");
|
||||
}
|
||||
sigPolicy = signaturePolicyId;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
if (sigPolicy != null)
|
||||
{
|
||||
return sigPolicy.ToAsn1Object();
|
||||
}
|
||||
return DerNull.Instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class SignerAttribute : Asn1Encodable
|
||||
{
|
||||
private Asn1Sequence claimedAttributes;
|
||||
|
||||
private AttributeCertificate certifiedAttributes;
|
||||
|
||||
public virtual Asn1Sequence ClaimedAttributes => claimedAttributes;
|
||||
|
||||
public virtual AttributeCertificate CertifiedAttributes => certifiedAttributes;
|
||||
|
||||
public static SignerAttribute GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is SignerAttribute)
|
||||
{
|
||||
return (SignerAttribute)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new SignerAttribute(obj);
|
||||
}
|
||||
throw new ArgumentException("Unknown object in 'SignerAttribute' factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private SignerAttribute(object obj)
|
||||
{
|
||||
Asn1Sequence asn1Sequence = (Asn1Sequence)obj;
|
||||
DerTaggedObject derTaggedObject = (DerTaggedObject)asn1Sequence[0];
|
||||
if (derTaggedObject.TagNo == 0)
|
||||
{
|
||||
claimedAttributes = Asn1Sequence.GetInstance(derTaggedObject, explicitly: true);
|
||||
return;
|
||||
}
|
||||
if (derTaggedObject.TagNo == 1)
|
||||
{
|
||||
certifiedAttributes = AttributeCertificate.GetInstance(derTaggedObject);
|
||||
return;
|
||||
}
|
||||
throw new ArgumentException("illegal tag.", "obj");
|
||||
}
|
||||
|
||||
public SignerAttribute(Asn1Sequence claimedAttributes)
|
||||
{
|
||||
this.claimedAttributes = claimedAttributes;
|
||||
}
|
||||
|
||||
public SignerAttribute(AttributeCertificate certifiedAttributes)
|
||||
{
|
||||
this.certifiedAttributes = certifiedAttributes;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();
|
||||
if (claimedAttributes != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(0, claimedAttributes));
|
||||
}
|
||||
else
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(1, certifiedAttributes));
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Asn1.X500;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Esf;
|
||||
|
||||
public class SignerLocation : Asn1Encodable
|
||||
{
|
||||
private DirectoryString countryName;
|
||||
|
||||
private DirectoryString localityName;
|
||||
|
||||
private Asn1Sequence postalAddress;
|
||||
|
||||
public DirectoryString Country => countryName;
|
||||
|
||||
public DirectoryString Locality => localityName;
|
||||
|
||||
[Obsolete("Use 'Country' property instead")]
|
||||
public DerUtf8String CountryName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (countryName != null)
|
||||
{
|
||||
return new DerUtf8String(countryName.GetString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Use 'Locality' property instead")]
|
||||
public DerUtf8String LocalityName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (localityName != null)
|
||||
{
|
||||
return new DerUtf8String(localityName.GetString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Asn1Sequence PostalAddress => postalAddress;
|
||||
|
||||
public SignerLocation(Asn1Sequence seq)
|
||||
{
|
||||
foreach (Asn1TaggedObject item in seq)
|
||||
{
|
||||
switch (item.TagNo)
|
||||
{
|
||||
case 0:
|
||||
countryName = DirectoryString.GetInstance(item, isExplicit: true);
|
||||
break;
|
||||
case 1:
|
||||
localityName = DirectoryString.GetInstance(item, isExplicit: true);
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
bool explicitly = item.IsExplicit();
|
||||
postalAddress = Asn1Sequence.GetInstance(item, explicitly);
|
||||
if (postalAddress != null && postalAddress.Count > 6)
|
||||
{
|
||||
throw new ArgumentException("postal address must contain less than 6 strings");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new ArgumentException("illegal tag");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SignerLocation(DirectoryString countryName, DirectoryString localityName, Asn1Sequence postalAddress)
|
||||
{
|
||||
if (postalAddress != null && postalAddress.Count > 6)
|
||||
{
|
||||
throw new ArgumentException("postal address must contain less than 6 strings");
|
||||
}
|
||||
this.countryName = countryName;
|
||||
this.localityName = localityName;
|
||||
this.postalAddress = postalAddress;
|
||||
}
|
||||
|
||||
public SignerLocation(DirectoryString countryName, DirectoryString localityName, DirectoryString[] postalAddress)
|
||||
: this(countryName, localityName, new DerSequence(postalAddress))
|
||||
{
|
||||
}
|
||||
|
||||
public SignerLocation(DerUtf8String countryName, DerUtf8String localityName, Asn1Sequence postalAddress)
|
||||
: this(DirectoryString.GetInstance(countryName), DirectoryString.GetInstance(localityName), postalAddress)
|
||||
{
|
||||
}
|
||||
|
||||
public static SignerLocation GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is SignerLocation)
|
||||
{
|
||||
return (SignerLocation)obj;
|
||||
}
|
||||
return new SignerLocation(Asn1Sequence.GetInstance(obj));
|
||||
}
|
||||
|
||||
public DirectoryString[] GetPostal()
|
||||
{
|
||||
if (postalAddress == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
DirectoryString[] array = new DirectoryString[postalAddress.Count];
|
||||
for (int i = 0; i != array.Length; i++)
|
||||
{
|
||||
array[i] = DirectoryString.GetInstance(postalAddress[i]);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();
|
||||
if (countryName != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 0, countryName));
|
||||
}
|
||||
if (localityName != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 1, localityName));
|
||||
}
|
||||
if (postalAddress != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 2, postalAddress));
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user