diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-20 19:01:12 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-20 19:01:12 +0700 |
commit | e5d77a0741bcc55088054b2ad4a91ab0508ac092 (patch) | |
tree | 816fc0d1139945ee9bfd22ca40f1e570e816a02f /crypto/src/asn1/cms/KEKIdentifier.cs | |
parent | Refactoring in Asn1.Crmf (diff) | |
download | BouncyCastle.NET-ed25519-e5d77a0741bcc55088054b2ad4a91ab0508ac092.tar.xz |
Refactoring in Asn1.Cms
Diffstat (limited to 'crypto/src/asn1/cms/KEKIdentifier.cs')
-rw-r--r-- | crypto/src/asn1/cms/KEKIdentifier.cs | 52 |
1 files changed, 15 insertions, 37 deletions
diff --git a/crypto/src/asn1/cms/KEKIdentifier.cs b/crypto/src/asn1/cms/KEKIdentifier.cs index 70ae8c438..09676fd0e 100644 --- a/crypto/src/asn1/cms/KEKIdentifier.cs +++ b/crypto/src/asn1/cms/KEKIdentifier.cs @@ -1,12 +1,24 @@ using System; -using Org.BouncyCastle.Utilities; - namespace Org.BouncyCastle.Asn1.Cms { public class KekIdentifier : Asn1Encodable { + public static KekIdentifier GetInstance(object obj) + { + if (obj == null) + return null; + if (obj is KekIdentifier kekIdentifier) + return kekIdentifier; + return new KekIdentifier(Asn1Sequence.GetInstance(obj)); + } + + public static KekIdentifier GetInstance(Asn1TaggedObject obj, bool explicitly) + { + return new KekIdentifier(Asn1Sequence.GetInstance(obj, explicitly)); + } + private Asn1OctetString keyIdentifier; private Asn1GeneralizedTime date; private OtherKeyAttribute other; @@ -48,41 +60,7 @@ namespace Org.BouncyCastle.Asn1.Cms } } - /** - * return a KekIdentifier object from a tagged object. - * - * @param obj the tagged object holding the object we want. - * @param explicitly true if the object is meant to be explicitly - * tagged false otherwise. - * @exception ArgumentException if the object held by the - * tagged object cannot be converted. - */ - public static KekIdentifier GetInstance( - Asn1TaggedObject obj, - bool explicitly) - { - return GetInstance(Asn1Sequence.GetInstance(obj, explicitly)); - } - - /** - * return a KekIdentifier object from the given object. - * - * @param obj the object we want converted. - * @exception ArgumentException if the object cannot be converted. - */ - public static KekIdentifier GetInstance( - object obj) - { - if (obj == null || obj is KekIdentifier) - return (KekIdentifier)obj; - - if (obj is Asn1Sequence) - return new KekIdentifier((Asn1Sequence)obj); - - throw new ArgumentException("Invalid KekIdentifier: " + Platform.GetTypeName(obj)); - } - - public Asn1OctetString KeyIdentifier + public Asn1OctetString KeyIdentifier { get { return keyIdentifier; } } |