summary refs log tree commit diff
path: root/crypto/src/asn1/cms/AuthEnvelopedData.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2019-06-04 16:55:26 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2019-06-04 16:55:26 +0700
commit3eb93b423abeefbdc03f0ecc38751d76428ba23e (patch)
treef364f857c54f65eb59462560b1f282b896eecf8b /crypto/src/asn1/cms/AuthEnvelopedData.cs
parentPort LinkedCertificate from bc-java (diff)
downloadBouncyCastle.NET-ed25519-3eb93b423abeefbdc03f0ecc38751d76428ba23e.tar.xz
Refactoring
Diffstat (limited to 'crypto/src/asn1/cms/AuthEnvelopedData.cs')
-rw-r--r--crypto/src/asn1/cms/AuthEnvelopedData.cs27
1 files changed, 8 insertions, 19 deletions
diff --git a/crypto/src/asn1/cms/AuthEnvelopedData.cs b/crypto/src/asn1/cms/AuthEnvelopedData.cs
index c30ec6bbd..6277e4b87 100644
--- a/crypto/src/asn1/cms/AuthEnvelopedData.cs
+++ b/crypto/src/asn1/cms/AuthEnvelopedData.cs
@@ -175,31 +175,20 @@ namespace Org.BouncyCastle.Asn1.Cms
 	    public override Asn1Object ToAsn1Object()
 		{
 			Asn1EncodableVector v = new Asn1EncodableVector(version);
-
-			if (originatorInfo != null)
-			{
-				v.Add(new DerTaggedObject(false, 0, originatorInfo));
-			}
-
+            v.AddOptionalTagged(false, 0, originatorInfo);
 			v.Add(recipientInfos, authEncryptedContentInfo);
 
 			// "authAttrs optionally contains the authenticated attributes."
-			if (authAttrs != null)
-			{
-				// "AuthAttributes MUST be DER encoded, even if the rest of the
-				// AuthEnvelopedData structure is BER encoded."
-				v.Add(new DerTaggedObject(false, 1, authAttrs));
-			}
+            // "AuthAttributes MUST be DER encoded, even if the rest of the
+            // AuthEnvelopedData structure is BER encoded."
+            v.AddOptionalTagged(false, 1, authAttrs);
 
-			v.Add(mac);
+            v.Add(mac);
 
-			// "unauthAttrs optionally contains the unauthenticated attributes."
-			if (unauthAttrs != null)
-			{
-				v.Add(new DerTaggedObject(false, 2, unauthAttrs));
-			}
+            // "unauthAttrs optionally contains the unauthenticated attributes."
+            v.AddOptionalTagged(false, 2, unauthAttrs);
 
-			return new BerSequence(v);
+            return new BerSequence(v);
 		}
 	}
 }