diff options
Diffstat (limited to 'crypto/src/asn1/cms/AuthenticatedData.cs')
-rw-r--r-- | crypto/src/asn1/cms/AuthenticatedData.cs | 67 |
1 files changed, 19 insertions, 48 deletions
diff --git a/crypto/src/asn1/cms/AuthenticatedData.cs b/crypto/src/asn1/cms/AuthenticatedData.cs index 6ec8061e2..47db0fa16 100644 --- a/crypto/src/asn1/cms/AuthenticatedData.cs +++ b/crypto/src/asn1/cms/AuthenticatedData.cs @@ -1,14 +1,27 @@ using System; using Org.BouncyCastle.Asn1.X509; -using Org.BouncyCastle.Utilities; namespace Org.BouncyCastle.Asn1.Cms { - public class AuthenticatedData + public class AuthenticatedData : Asn1Encodable { - private DerInteger version; + public static AuthenticatedData GetInstance(object obj) + { + if (obj == null) + return null; + if (obj is AuthenticatedData authenticatedData) + return authenticatedData; + return new AuthenticatedData(Asn1Sequence.GetInstance(obj)); + } + + public static AuthenticatedData GetInstance(Asn1TaggedObject obj, bool isExplicit) + { + return new AuthenticatedData(Asn1Sequence.GetInstance(obj, isExplicit)); + } + + private DerInteger version; private OriginatorInfo originatorInfo; private Asn1Set recipientInfos; private AlgorithmIdentifier macAlgorithm; @@ -88,45 +101,7 @@ namespace Org.BouncyCastle.Asn1.Cms } } - /** - * return an AuthenticatedData 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. - * @throws ArgumentException if the object held by the - * tagged object cannot be converted. - */ - public static AuthenticatedData GetInstance( - Asn1TaggedObject obj, - bool isExplicit) - { - return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit)); - } - - /** - * return an AuthenticatedData object from the given object. - * - * @param obj the object we want converted. - * @throws ArgumentException if the object cannot be converted. - */ - public static AuthenticatedData GetInstance( - object obj) - { - if (obj == null || obj is AuthenticatedData) - { - return (AuthenticatedData)obj; - } - - if (obj is Asn1Sequence) - { - return new AuthenticatedData((Asn1Sequence)obj); - } - - throw new ArgumentException("Invalid AuthenticatedData: " + Platform.GetTypeName(obj)); - } - - public DerInteger Version + public DerInteger Version { get { return version; } } @@ -214,10 +189,8 @@ namespace Org.BouncyCastle.Asn1.Cms foreach (object obj in origInfo.Certificates) { - if (obj is Asn1TaggedObject) + if (obj is Asn1TaggedObject tag) { - Asn1TaggedObject tag = (Asn1TaggedObject)obj; - if (tag.TagNo == 2) { ver = 1; @@ -232,10 +205,8 @@ namespace Org.BouncyCastle.Asn1.Cms foreach (object obj in origInfo.Crls) { - if (obj is Asn1TaggedObject) + if (obj is Asn1TaggedObject tag) { - Asn1TaggedObject tag = (Asn1TaggedObject)obj; - if (tag.TagNo == 1) { ver = 3; |