diff options
Diffstat (limited to 'crypto/src/asn1/cms/RecipientEncryptedKey.cs')
-rw-r--r-- | crypto/src/asn1/cms/RecipientEncryptedKey.cs | 62 |
1 files changed, 17 insertions, 45 deletions
diff --git a/crypto/src/asn1/cms/RecipientEncryptedKey.cs b/crypto/src/asn1/cms/RecipientEncryptedKey.cs index 1afba4ab1..0e0214909 100644 --- a/crypto/src/asn1/cms/RecipientEncryptedKey.cs +++ b/crypto/src/asn1/cms/RecipientEncryptedKey.cs @@ -1,13 +1,23 @@ -using System; - -using Org.BouncyCastle.Utilities; - namespace Org.BouncyCastle.Asn1.Cms { - public class RecipientEncryptedKey + public class RecipientEncryptedKey : Asn1Encodable { - private readonly KeyAgreeRecipientIdentifier identifier; + public static RecipientEncryptedKey GetInstance(object obj) + { + if (obj == null) + return null; + if (obj is RecipientEncryptedKey recipientEncryptedKey) + return recipientEncryptedKey; + return new RecipientEncryptedKey(Asn1Sequence.GetInstance(obj)); + } + + public static RecipientEncryptedKey GetInstance(Asn1TaggedObject obj, bool isExplicit) + { + return new RecipientEncryptedKey(Asn1Sequence.GetInstance(obj, isExplicit)); + } + + private readonly KeyAgreeRecipientIdentifier identifier; private readonly Asn1OctetString encryptedKey; private RecipientEncryptedKey( @@ -17,45 +27,7 @@ namespace Org.BouncyCastle.Asn1.Cms encryptedKey = (Asn1OctetString) seq[1]; } - /** - * return an RecipientEncryptedKey object from a tagged object. - * - * @param obj the tagged object holding the object we want. - * @param isExplicit 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 RecipientEncryptedKey GetInstance( - Asn1TaggedObject obj, - bool isExplicit) - { - return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit)); - } - - /** - * return a RecipientEncryptedKey object from the given object. - * - * @param obj the object we want converted. - * @exception ArgumentException if the object cannot be converted. - */ - public static RecipientEncryptedKey GetInstance( - object obj) - { - if (obj == null || obj is RecipientEncryptedKey) - { - return (RecipientEncryptedKey) obj; - } - - if (obj is Asn1Sequence) - { - return new RecipientEncryptedKey((Asn1Sequence) obj); - } - - throw new ArgumentException("Invalid RecipientEncryptedKey: " + Platform.GetTypeName(obj), "obj"); - } - - public RecipientEncryptedKey( + public RecipientEncryptedKey( KeyAgreeRecipientIdentifier id, Asn1OctetString encryptedKey) { |