init commit
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.X509.Qualified;
|
||||
|
||||
public class BiometricData : Asn1Encodable
|
||||
{
|
||||
private readonly TypeOfBiometricData typeOfBiometricData;
|
||||
|
||||
private readonly AlgorithmIdentifier hashAlgorithm;
|
||||
|
||||
private readonly Asn1OctetString biometricDataHash;
|
||||
|
||||
private readonly DerIA5String sourceDataUri;
|
||||
|
||||
public TypeOfBiometricData TypeOfBiometricData => typeOfBiometricData;
|
||||
|
||||
public AlgorithmIdentifier HashAlgorithm => hashAlgorithm;
|
||||
|
||||
public Asn1OctetString BiometricDataHash => biometricDataHash;
|
||||
|
||||
public DerIA5String SourceDataUri => sourceDataUri;
|
||||
|
||||
public static BiometricData GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is BiometricData)
|
||||
{
|
||||
return (BiometricData)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new BiometricData(Asn1Sequence.GetInstance(obj));
|
||||
}
|
||||
throw new ArgumentException("unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private BiometricData(Asn1Sequence seq)
|
||||
{
|
||||
typeOfBiometricData = TypeOfBiometricData.GetInstance(seq[0]);
|
||||
hashAlgorithm = AlgorithmIdentifier.GetInstance(seq[1]);
|
||||
biometricDataHash = Asn1OctetString.GetInstance(seq[2]);
|
||||
if (seq.Count > 3)
|
||||
{
|
||||
sourceDataUri = DerIA5String.GetInstance(seq[3]);
|
||||
}
|
||||
}
|
||||
|
||||
public BiometricData(TypeOfBiometricData typeOfBiometricData, AlgorithmIdentifier hashAlgorithm, Asn1OctetString biometricDataHash, DerIA5String sourceDataUri)
|
||||
{
|
||||
this.typeOfBiometricData = typeOfBiometricData;
|
||||
this.hashAlgorithm = hashAlgorithm;
|
||||
this.biometricDataHash = biometricDataHash;
|
||||
this.sourceDataUri = sourceDataUri;
|
||||
}
|
||||
|
||||
public BiometricData(TypeOfBiometricData typeOfBiometricData, AlgorithmIdentifier hashAlgorithm, Asn1OctetString biometricDataHash)
|
||||
{
|
||||
this.typeOfBiometricData = typeOfBiometricData;
|
||||
this.hashAlgorithm = hashAlgorithm;
|
||||
this.biometricDataHash = biometricDataHash;
|
||||
sourceDataUri = null;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector(typeOfBiometricData, hashAlgorithm, biometricDataHash);
|
||||
if (sourceDataUri != null)
|
||||
{
|
||||
asn1EncodableVector.Add(sourceDataUri);
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Org.BouncyCastle.Asn1.X509.Qualified;
|
||||
|
||||
public abstract class EtsiQCObjectIdentifiers
|
||||
{
|
||||
public static readonly DerObjectIdentifier IdEtsiQcs = new DerObjectIdentifier("0.4.0.1862.1");
|
||||
|
||||
public static readonly DerObjectIdentifier IdEtsiQcsQcCompliance = new DerObjectIdentifier(string.Concat(IdEtsiQcs, ".1"));
|
||||
|
||||
public static readonly DerObjectIdentifier IdEtsiQcsLimitValue = new DerObjectIdentifier(string.Concat(IdEtsiQcs, ".2"));
|
||||
|
||||
public static readonly DerObjectIdentifier IdEtsiQcsRetentionPeriod = new DerObjectIdentifier(string.Concat(IdEtsiQcs, ".3"));
|
||||
|
||||
public static readonly DerObjectIdentifier IdEtsiQcsQcSscd = new DerObjectIdentifier(string.Concat(IdEtsiQcs, ".4"));
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.X509.Qualified;
|
||||
|
||||
public class Iso4217CurrencyCode : Asn1Encodable, IAsn1Choice
|
||||
{
|
||||
internal const int AlphabeticMaxSize = 3;
|
||||
|
||||
internal const int NumericMinSize = 1;
|
||||
|
||||
internal const int NumericMaxSize = 999;
|
||||
|
||||
internal Asn1Encodable obj;
|
||||
|
||||
public bool IsAlphabetic => obj is DerPrintableString;
|
||||
|
||||
public string Alphabetic => ((DerPrintableString)obj).GetString();
|
||||
|
||||
public int Numeric => ((DerInteger)obj).Value.IntValue;
|
||||
|
||||
public static Iso4217CurrencyCode GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is Iso4217CurrencyCode)
|
||||
{
|
||||
return (Iso4217CurrencyCode)obj;
|
||||
}
|
||||
if (obj is DerInteger)
|
||||
{
|
||||
DerInteger instance = DerInteger.GetInstance(obj);
|
||||
int intValue = instance.Value.IntValue;
|
||||
return new Iso4217CurrencyCode(intValue);
|
||||
}
|
||||
if (obj is DerPrintableString)
|
||||
{
|
||||
DerPrintableString instance2 = DerPrintableString.GetInstance(obj);
|
||||
return new Iso4217CurrencyCode(instance2.GetString());
|
||||
}
|
||||
throw new ArgumentException("unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
public Iso4217CurrencyCode(int numeric)
|
||||
{
|
||||
if (numeric > 999 || numeric < 1)
|
||||
{
|
||||
throw new ArgumentException("wrong size in numeric code : not in (" + 1 + ".." + 999 + ")");
|
||||
}
|
||||
obj = new DerInteger(numeric);
|
||||
}
|
||||
|
||||
public Iso4217CurrencyCode(string alphabetic)
|
||||
{
|
||||
if (alphabetic.Length > 3)
|
||||
{
|
||||
throw new ArgumentException("wrong size in alphabetic code : max size is " + 3);
|
||||
}
|
||||
obj = new DerPrintableString(alphabetic);
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return obj.ToAsn1Object();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Math;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.X509.Qualified;
|
||||
|
||||
public class MonetaryValue : Asn1Encodable
|
||||
{
|
||||
internal Iso4217CurrencyCode currency;
|
||||
|
||||
internal DerInteger amount;
|
||||
|
||||
internal DerInteger exponent;
|
||||
|
||||
public Iso4217CurrencyCode Currency => currency;
|
||||
|
||||
public BigInteger Amount => amount.Value;
|
||||
|
||||
public BigInteger Exponent => exponent.Value;
|
||||
|
||||
public static MonetaryValue GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is MonetaryValue)
|
||||
{
|
||||
return (MonetaryValue)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new MonetaryValue(Asn1Sequence.GetInstance(obj));
|
||||
}
|
||||
throw new ArgumentException("unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private MonetaryValue(Asn1Sequence seq)
|
||||
{
|
||||
if (seq.Count != 3)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
|
||||
}
|
||||
currency = Iso4217CurrencyCode.GetInstance(seq[0]);
|
||||
amount = DerInteger.GetInstance(seq[1]);
|
||||
exponent = DerInteger.GetInstance(seq[2]);
|
||||
}
|
||||
|
||||
public MonetaryValue(Iso4217CurrencyCode currency, int amount, int exponent)
|
||||
{
|
||||
this.currency = currency;
|
||||
this.amount = new DerInteger(amount);
|
||||
this.exponent = new DerInteger(exponent);
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return new DerSequence(currency, amount, exponent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.X509.Qualified;
|
||||
|
||||
public class QCStatement : Asn1Encodable
|
||||
{
|
||||
private readonly DerObjectIdentifier qcStatementId;
|
||||
|
||||
private readonly Asn1Encodable qcStatementInfo;
|
||||
|
||||
public DerObjectIdentifier StatementId => qcStatementId;
|
||||
|
||||
public Asn1Encodable StatementInfo => qcStatementInfo;
|
||||
|
||||
public static QCStatement GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is QCStatement)
|
||||
{
|
||||
return (QCStatement)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new QCStatement(Asn1Sequence.GetInstance(obj));
|
||||
}
|
||||
throw new ArgumentException("unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private QCStatement(Asn1Sequence seq)
|
||||
{
|
||||
qcStatementId = DerObjectIdentifier.GetInstance(seq[0]);
|
||||
if (seq.Count > 1)
|
||||
{
|
||||
qcStatementInfo = seq[1];
|
||||
}
|
||||
}
|
||||
|
||||
public QCStatement(DerObjectIdentifier qcStatementId)
|
||||
{
|
||||
this.qcStatementId = qcStatementId;
|
||||
}
|
||||
|
||||
public QCStatement(DerObjectIdentifier qcStatementId, Asn1Encodable qcStatementInfo)
|
||||
{
|
||||
this.qcStatementId = qcStatementId;
|
||||
this.qcStatementInfo = qcStatementInfo;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector(qcStatementId);
|
||||
if (qcStatementInfo != null)
|
||||
{
|
||||
asn1EncodableVector.Add(qcStatementInfo);
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Org.BouncyCastle.Asn1.X509.Qualified;
|
||||
|
||||
public sealed class Rfc3739QCObjectIdentifiers
|
||||
{
|
||||
public static readonly DerObjectIdentifier IdQcs = new DerObjectIdentifier("1.3.6.1.5.5.7.11");
|
||||
|
||||
public static readonly DerObjectIdentifier IdQcsPkixQCSyntaxV1 = new DerObjectIdentifier(string.Concat(IdQcs, ".1"));
|
||||
|
||||
public static readonly DerObjectIdentifier IdQcsPkixQCSyntaxV2 = new DerObjectIdentifier(string.Concat(IdQcs, ".2"));
|
||||
|
||||
private Rfc3739QCObjectIdentifiers()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.X509.Qualified;
|
||||
|
||||
public class SemanticsInformation : Asn1Encodable
|
||||
{
|
||||
private readonly DerObjectIdentifier semanticsIdentifier;
|
||||
|
||||
private readonly GeneralName[] nameRegistrationAuthorities;
|
||||
|
||||
public DerObjectIdentifier SemanticsIdentifier => semanticsIdentifier;
|
||||
|
||||
public static SemanticsInformation GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is SemanticsInformation)
|
||||
{
|
||||
return (SemanticsInformation)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new SemanticsInformation(Asn1Sequence.GetInstance(obj));
|
||||
}
|
||||
throw new ArgumentException("unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
public SemanticsInformation(Asn1Sequence seq)
|
||||
{
|
||||
if (seq.Count < 1)
|
||||
{
|
||||
throw new ArgumentException("no objects in SemanticsInformation");
|
||||
}
|
||||
IEnumerator enumerator = seq.GetEnumerator();
|
||||
enumerator.MoveNext();
|
||||
object obj = enumerator.Current;
|
||||
if (obj is DerObjectIdentifier)
|
||||
{
|
||||
semanticsIdentifier = DerObjectIdentifier.GetInstance(obj);
|
||||
obj = ((!enumerator.MoveNext()) ? null : enumerator.Current);
|
||||
}
|
||||
if (obj != null)
|
||||
{
|
||||
Asn1Sequence instance = Asn1Sequence.GetInstance(obj);
|
||||
nameRegistrationAuthorities = new GeneralName[instance.Count];
|
||||
for (int i = 0; i < instance.Count; i++)
|
||||
{
|
||||
nameRegistrationAuthorities[i] = GeneralName.GetInstance(instance[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SemanticsInformation(DerObjectIdentifier semanticsIdentifier, GeneralName[] generalNames)
|
||||
{
|
||||
this.semanticsIdentifier = semanticsIdentifier;
|
||||
nameRegistrationAuthorities = generalNames;
|
||||
}
|
||||
|
||||
public SemanticsInformation(DerObjectIdentifier semanticsIdentifier)
|
||||
{
|
||||
this.semanticsIdentifier = semanticsIdentifier;
|
||||
}
|
||||
|
||||
public SemanticsInformation(GeneralName[] generalNames)
|
||||
{
|
||||
nameRegistrationAuthorities = generalNames;
|
||||
}
|
||||
|
||||
public GeneralName[] GetNameRegistrationAuthorities()
|
||||
{
|
||||
return nameRegistrationAuthorities;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();
|
||||
if (semanticsIdentifier != null)
|
||||
{
|
||||
asn1EncodableVector.Add(semanticsIdentifier);
|
||||
}
|
||||
if (nameRegistrationAuthorities != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerSequence(nameRegistrationAuthorities));
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.X509.Qualified;
|
||||
|
||||
public class TypeOfBiometricData : Asn1Encodable, IAsn1Choice
|
||||
{
|
||||
public const int Picture = 0;
|
||||
|
||||
public const int HandwrittenSignature = 1;
|
||||
|
||||
internal Asn1Encodable obj;
|
||||
|
||||
public bool IsPredefined => obj is DerInteger;
|
||||
|
||||
public int PredefinedBiometricType => ((DerInteger)obj).Value.IntValue;
|
||||
|
||||
public DerObjectIdentifier BiometricDataOid => (DerObjectIdentifier)obj;
|
||||
|
||||
public static TypeOfBiometricData GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is TypeOfBiometricData)
|
||||
{
|
||||
return (TypeOfBiometricData)obj;
|
||||
}
|
||||
if (obj is DerInteger)
|
||||
{
|
||||
DerInteger instance = DerInteger.GetInstance(obj);
|
||||
int intValue = instance.Value.IntValue;
|
||||
return new TypeOfBiometricData(intValue);
|
||||
}
|
||||
if (obj is DerObjectIdentifier)
|
||||
{
|
||||
DerObjectIdentifier instance2 = DerObjectIdentifier.GetInstance(obj);
|
||||
return new TypeOfBiometricData(instance2);
|
||||
}
|
||||
throw new ArgumentException("unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
public TypeOfBiometricData(int predefinedBiometricType)
|
||||
{
|
||||
if (predefinedBiometricType == 0 || predefinedBiometricType == 1)
|
||||
{
|
||||
obj = new DerInteger(predefinedBiometricType);
|
||||
return;
|
||||
}
|
||||
throw new ArgumentException("unknow PredefinedBiometricType : " + predefinedBiometricType);
|
||||
}
|
||||
|
||||
public TypeOfBiometricData(DerObjectIdentifier biometricDataOid)
|
||||
{
|
||||
obj = biometricDataOid;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return obj.ToAsn1Object();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user