From d64e59eacdcbcb676ea758ddc0f75d70bffd8042 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 7 Feb 2023 14:41:18 +0700 Subject: Refactor PopoPrivKey --- crypto/src/asn1/crmf/PopoPrivKey.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'crypto') diff --git a/crypto/src/asn1/crmf/PopoPrivKey.cs b/crypto/src/asn1/crmf/PopoPrivKey.cs index e7cef784c..6e2d695da 100644 --- a/crypto/src/asn1/crmf/PopoPrivKey.cs +++ b/crypto/src/asn1/crmf/PopoPrivKey.cs @@ -13,6 +13,20 @@ namespace Org.BouncyCastle.Asn1.Crmf public const int agreeMAC = 3; public const int encryptedKey = 4; + public static PopoPrivKey GetInstance(object obj) + { + if (obj == null) + return null; + if (obj is PopoPrivKey popoPrivKey) + return popoPrivKey; + return new PopoPrivKey(Asn1TaggedObject.GetInstance(obj, Asn1Tags.ContextSpecific)); + } + + public static PopoPrivKey GetInstance(Asn1TaggedObject tagged, bool isExplicit) + { + return Asn1Utilities.GetInstanceFromChoice(tagged, isExplicit, GetInstance); + } + private readonly int tagNo; private readonly Asn1Encodable obj; @@ -42,11 +56,6 @@ namespace Org.BouncyCastle.Asn1.Crmf } } - public static PopoPrivKey GetInstance(Asn1TaggedObject tagged, bool isExplicit) - { - return new PopoPrivKey(Asn1TaggedObject.GetInstance(tagged, true)); - } - public PopoPrivKey(PKMacValue pkMacValue) { this.tagNo = agreeMAC; -- cgit 1.4.1