summary refs log tree commit diff
path: root/crypto/test/src
diff options
context:
space:
mode:
authorDavid Hook <dgh@bouncycastle.org>2021-05-23 13:28:45 +1000
committerDavid Hook <dgh@bouncycastle.org>2021-05-23 13:28:45 +1000
commitf7d837b990cf19d3b324c7238eace45eb8c5d6bf (patch)
treec1b71240a688b4dcd3c237c4d2add9f091b33a97 /crypto/test/src
parentgithub #296 TSP fix (diff)
downloadBouncyCastle.NET-ed25519-f7d837b990cf19d3b324c7238eace45eb8c5d6bf.tar.xz
github #283 added extra features fields, corrected parsing for new draft
Diffstat (limited to 'crypto/test/src')
-rw-r--r--crypto/test/src/openpgp/test/PgpFeaturesTest.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/crypto/test/src/openpgp/test/PgpFeaturesTest.cs b/crypto/test/src/openpgp/test/PgpFeaturesTest.cs
new file mode 100644
index 000000000..2969d8982
--- /dev/null
+++ b/crypto/test/src/openpgp/test/PgpFeaturesTest.cs
@@ -0,0 +1,55 @@
+
+using NUnit.Core;
+using NUnit.Framework;
+using Org.BouncyCastle.Bcpg.Sig;
+
+namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
+{
+    [TestFixture]
+    public class PgpFeaturesTest
+    {
+        [Test]
+        public void PerformTest()
+        {
+            Features f = new Features(true, Features.FEATURE_MODIFICATION_DETECTION);
+            Assert.IsTrue(f.SupportsFeature(Features.FEATURE_MODIFICATION_DETECTION));
+            Assert.IsTrue(f.SupportsModificationDetection);
+            Assert.IsTrue(!f.SupportsFeature(Features.FEATURE_VERSION_5_PUBLIC_KEY));
+
+            f = new Features(true, Features.FEATURE_VERSION_5_PUBLIC_KEY);
+            Assert.IsTrue(!f.SupportsModificationDetection);
+            Assert.IsTrue(f.SupportsFeature(Features.FEATURE_VERSION_5_PUBLIC_KEY));
+
+            f = new Features(true, Features.FEATURE_AEAD_ENCRYPTED_DATA);
+            Assert.IsTrue(f.SupportsFeature(Features.FEATURE_AEAD_ENCRYPTED_DATA));
+            Assert.IsTrue(!f.SupportsModificationDetection);
+            Assert.IsTrue(!f.SupportsFeature(Features.FEATURE_VERSION_5_PUBLIC_KEY));
+
+            f = new Features(true, Features.FEATURE_AEAD_ENCRYPTED_DATA | Features.FEATURE_MODIFICATION_DETECTION);
+            Assert.IsTrue(f.SupportsFeature(Features.FEATURE_AEAD_ENCRYPTED_DATA));
+            Assert.IsTrue(f.SupportsModificationDetection);
+            Assert.IsTrue(!f.SupportsFeature(Features.FEATURE_VERSION_5_PUBLIC_KEY));
+
+            f = new Features(true, Features.FEATURE_VERSION_5_PUBLIC_KEY | Features.FEATURE_MODIFICATION_DETECTION);
+            Assert.IsTrue(!f.SupportsFeature(Features.FEATURE_AEAD_ENCRYPTED_DATA));
+            Assert.IsTrue(f.SupportsModificationDetection);
+            Assert.IsTrue(f.SupportsFeature(Features.FEATURE_VERSION_5_PUBLIC_KEY));
+        }
+
+        public static void Main(string[] args)
+        {
+            Suite.Run(new NullListener(), NUnit.Core.TestFilter.Empty);
+        }
+
+        [Suite]
+        public static TestSuite Suite
+        {
+            get
+            {
+                TestSuite suite = new TestSuite("PGP Features Tests");
+                suite.Add(new PgpFeaturesTest());
+                return suite;
+            }
+        }
+    }
+}