From 3eb93b423abeefbdc03f0ecc38751d76428ba23e Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 4 Jun 2019 16:55:26 +0700 Subject: Refactoring --- crypto/src/asn1/x9/DHDomainParameters.cs | 22 ++++++---------------- crypto/src/asn1/x9/OtherInfo.cs | 12 +++--------- 2 files changed, 9 insertions(+), 25 deletions(-) (limited to 'crypto/src/asn1/x9') diff --git a/crypto/src/asn1/x9/DHDomainParameters.cs b/crypto/src/asn1/x9/DHDomainParameters.cs index b8c1ac030..a92322717 100644 --- a/crypto/src/asn1/x9/DHDomainParameters.cs +++ b/crypto/src/asn1/x9/DHDomainParameters.cs @@ -98,21 +98,11 @@ namespace Org.BouncyCastle.Asn1.X9 get { return this.validationParms; } } - public override Asn1Object ToAsn1Object() - { - Asn1EncodableVector v = new Asn1EncodableVector(p, g, q); - - if (this.j != null) - { - v.Add(this.j); - } - - if (this.validationParms != null) - { - v.Add(this.validationParms); - } - - return new DerSequence(v); - } + public override Asn1Object ToAsn1Object() + { + Asn1EncodableVector v = new Asn1EncodableVector(p, g, q); + v.AddOptional(j, validationParms); + return new DerSequence(v); + } } } diff --git a/crypto/src/asn1/x9/OtherInfo.cs b/crypto/src/asn1/x9/OtherInfo.cs index 21863bd17..4a52b7206 100644 --- a/crypto/src/asn1/x9/OtherInfo.cs +++ b/crypto/src/asn1/x9/OtherInfo.cs @@ -74,15 +74,9 @@ namespace Org.BouncyCastle.Asn1.X9 public override Asn1Object ToAsn1Object() { Asn1EncodableVector v = new Asn1EncodableVector(keyInfo); - - if (partyAInfo != null) - { - v.Add(new DerTaggedObject(0, partyAInfo)); - } - - v.Add(new DerTaggedObject(2, suppPubInfo)); - - return new DerSequence(v); + v.AddOptionalTagged(true, 0, partyAInfo); + v.Add(new DerTaggedObject(2, suppPubInfo)); + return new DerSequence(v); } } } -- cgit 1.4.1