diff options
Diffstat (limited to 'crypto/src/asn1/cms/IssuerAndSerialNumber.cs')
-rw-r--r-- | crypto/src/asn1/cms/IssuerAndSerialNumber.cs | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/crypto/src/asn1/cms/IssuerAndSerialNumber.cs b/crypto/src/asn1/cms/IssuerAndSerialNumber.cs index 8e31eb0e4..dcd489336 100644 --- a/crypto/src/asn1/cms/IssuerAndSerialNumber.cs +++ b/crypto/src/asn1/cms/IssuerAndSerialNumber.cs @@ -1,5 +1,3 @@ -using System; - using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Math; @@ -8,54 +6,51 @@ namespace Org.BouncyCastle.Asn1.Cms public class IssuerAndSerialNumber : Asn1Encodable { - private X509Name name; - private DerInteger serialNumber; - public static IssuerAndSerialNumber GetInstance(object obj) { if (obj == null) return null; - IssuerAndSerialNumber existing = obj as IssuerAndSerialNumber; - if (existing != null) - return existing; + if (obj is IssuerAndSerialNumber issuerAndSerialNumber) + return issuerAndSerialNumber; return new IssuerAndSerialNumber(Asn1Sequence.GetInstance(obj)); } - private IssuerAndSerialNumber(Asn1Sequence seq) + public static IssuerAndSerialNumber GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) { - this.name = X509Name.GetInstance(seq[0]); - this.serialNumber = (DerInteger) seq[1]; + return new IssuerAndSerialNumber(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); } - public IssuerAndSerialNumber( - X509Name name, - BigInteger serialNumber) - { - this.name = name; - this.serialNumber = new DerInteger(serialNumber); - } + private X509Name m_name; + private DerInteger m_serialNumber; - public IssuerAndSerialNumber( - X509Name name, - DerInteger serialNumber) + private IssuerAndSerialNumber(Asn1Sequence seq) { - this.name = name; - this.serialNumber = serialNumber; + m_name = X509Name.GetInstance(seq[0]); + m_serialNumber = DerInteger.GetInstance(seq[1]); } - public X509Name Name + public IssuerAndSerialNumber(X509Name name, BigInteger serialNumber) { - get { return name; } + m_name = name; + m_serialNumber = new DerInteger(serialNumber); } - public DerInteger SerialNumber + public IssuerAndSerialNumber(X509Name name, DerInteger serialNumber) { - get { return serialNumber; } + m_name = name; + m_serialNumber = serialNumber; } - public override Asn1Object ToAsn1Object() + public IssuerAndSerialNumber(X509CertificateStructure x509CertificateStructure) { - return new DerSequence(name, serialNumber); + m_name = x509CertificateStructure.Issuer; + m_serialNumber = x509CertificateStructure.SerialNumber; } + + public X509Name Name => m_name; + + public DerInteger SerialNumber => m_serialNumber; + + public override Asn1Object ToAsn1Object() => new DerSequence(m_name, m_serialNumber); } } |