Skip to content

Commit d64e59e

Browse files
committed
Refactor PopoPrivKey
1 parent 0f733e8 commit d64e59e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

crypto/src/asn1/crmf/PopoPrivKey.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ public class PopoPrivKey
1313
public const int agreeMAC = 3;
1414
public const int encryptedKey = 4;
1515

16+
public static PopoPrivKey GetInstance(object obj)
17+
{
18+
if (obj == null)
19+
return null;
20+
if (obj is PopoPrivKey popoPrivKey)
21+
return popoPrivKey;
22+
return new PopoPrivKey(Asn1TaggedObject.GetInstance(obj, Asn1Tags.ContextSpecific));
23+
}
24+
25+
public static PopoPrivKey GetInstance(Asn1TaggedObject tagged, bool isExplicit)
26+
{
27+
return Asn1Utilities.GetInstanceFromChoice(tagged, isExplicit, GetInstance);
28+
}
29+
1630
private readonly int tagNo;
1731
private readonly Asn1Encodable obj;
1832

@@ -42,11 +56,6 @@ private PopoPrivKey(Asn1TaggedObject obj)
4256
}
4357
}
4458

45-
public static PopoPrivKey GetInstance(Asn1TaggedObject tagged, bool isExplicit)
46-
{
47-
return new PopoPrivKey(Asn1TaggedObject.GetInstance(tagged, true));
48-
}
49-
5059
public PopoPrivKey(PKMacValue pkMacValue)
5160
{
5261
this.tagNo = agreeMAC;

0 commit comments

Comments
 (0)