summary refs log tree commit diff
path: root/crypto/test/src/openpgp/test/PgpKeyRingTest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/test/src/openpgp/test/PgpKeyRingTest.cs')
-rw-r--r--crypto/test/src/openpgp/test/PgpKeyRingTest.cs79
1 files changed, 62 insertions, 17 deletions
diff --git a/crypto/test/src/openpgp/test/PgpKeyRingTest.cs b/crypto/test/src/openpgp/test/PgpKeyRingTest.cs
index a5dc4963b..821a7f295 100644
--- a/crypto/test/src/openpgp/test/PgpKeyRingTest.cs
+++ b/crypto/test/src/openpgp/test/PgpKeyRingTest.cs
@@ -1346,6 +1346,35 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
           + "WDoIM5gfjeZgwht1vl6+7J+h20yjFrBdf7gJj9OcIGmwlpQ56qzbT4U++mw3"
           + "pW2tN2VuYtreceEoI4B6yUGMEhI9t/asLgn7wEAU2lpuE7ACAAM=");
 
+        private static readonly byte[] curve25519Pub = Base64.Decode(
+            "mDMEXEzydhYJKwYBBAHaRw8BAQdAwHPDYhq7hIsCT0jHNxGh4Mbao9kDkcHZilME" +
+            "jfgnnG60N1Rlc3QgS2V5IChEbyBub3QgdXNlIGZvciByZWFsLikgPHRlc3RAd29v" +
+            "ZHMtZ2VibGVyLmNvbT6IlgQTFggAPhYhBIuq+f4gKmIa9ZKEqJdUhr00IJstBQJc" +
+            "TPJ2AhsDBQkB4TOABQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEJdUhr00IJst" +
+            "dHAA/RDOjus5OZL2m9Q9dxOVnWNguT7Cr5cWdJxUeKAWE2c6AQCcQZWA4SmV1dkJ" +
+            "U0XKmLeu3xWDpqrydT4+vQXb/Qm9B7g4BFxM8nYSCisGAQQBl1UBBQEBB0AY3XTS" +
+            "6S1pwFNc1QhNpEKTStG+LAJpiHPK9QyXBbW9dQMBCAeIfgQYFggAJhYhBIuq+f4g" +
+            "KmIa9ZKEqJdUhr00IJstBQJcTPJ2AhsMBQkB4TOAAAoJEJdUhr00IJstmAsBAMRJ" +
+            "pvh8iegwrJDMoQc53ZqDRsbieElV6ofB80a+jkzZAQCgpAaY4hZc8GUan2JIqkg0" +
+            "gs23h4au7H79KqXYG4a+Bg==");
+
+        private static readonly byte[] curve25519Priv = Base64.Decode(
+        "lIYEXEzydhYJKwYBBAHaRw8BAQdAwHPDYhq7hIsCT0jHNxGh4Mbao9kDkcHZilME" +
+            "jfgnnG7+BwMCgEr7OFDl3dTpT73rmw6vIwiTGqjx+Xbe8cq4l24q2AOtzO+UR97q" +
+            "7ypL41jtt7BY7uoxhF+NCKzYEtRoqyaM0lfjDlOVRJP6SYRixK2UHLQ3VGVzdCBL" +
+            "ZXkgKERvIG5vdCB1c2UgZm9yIHJlYWwuKSA8dGVzdEB3b29kcy1nZWJsZXIuY29t" +
+            "PoiWBBMWCAA+FiEEi6r5/iAqYhr1koSol1SGvTQgmy0FAlxM8nYCGwMFCQHhM4AF" +
+            "CwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQl1SGvTQgmy10cAD9EM6O6zk5kvab" +
+            "1D13E5WdY2C5PsKvlxZ0nFR4oBYTZzoBAJxBlYDhKZXV2QlTRcqYt67fFYOmqvJ1" +
+            "Pj69Bdv9Cb0HnIsEXEzydhIKKwYBBAGXVQEFAQEHQBjddNLpLWnAU1zVCE2kQpNK" +
+            "0b4sAmmIc8r1DJcFtb11AwEIB/4HAwItKjH+kGqkMelkEdIRxSLFeCsB/A64n+os" +
+            "X9nWVYsrixEWT5JcRWBniI1PKt9Cm15Yt8KQSAFDJIj5tnEm28x5RM0CzFHQ9Ej2" +
+            "8Q2Lt0RoiH4EGBYIACYWIQSLqvn+ICpiGvWShKiXVIa9NCCbLQUCXEzydgIbDAUJ" +
+            "AeEzgAAKCRCXVIa9NCCbLZgLAQDESab4fInoMKyQzKEHOd2ag0bG4nhJVeqHwfNG" +
+            "vo5M2QEAoKQGmOIWXPBlGp9iSKpINILNt4eGrux+/Sql2BuGvgY=");
+
+        //private static readonly char[] curve25519Pwd = "foobar".ToCharArray();
+
         [Test]
         public void PerformTest1()
         {
@@ -1744,15 +1773,12 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
         [Test]
         public void PerformTest4()
         {
-            PgpSecretKeyRingBundle secretRings1 = new PgpSecretKeyRingBundle(sec4);
-            int count = 0;
-
+            PgpSecretKeyRingBundle secretRings = new PgpSecretKeyRingBundle(sec4);
+            byte[] encRing = secretRings.GetEncoded();
+            secretRings = new PgpSecretKeyRingBundle(encRing);
 
-            byte[] encRing = secretRings1.GetEncoded();
-
-            PgpSecretKeyRingBundle secretRings2 = new PgpSecretKeyRingBundle(encRing);
-
-            foreach (PgpSecretKeyRing pgpSec1 in secretRings1.GetKeyRings())
+            int count = 0;
+            foreach (PgpSecretKeyRing pgpSec1 in secretRings.GetKeyRings())
             {
                 count++;
 
@@ -2486,22 +2512,22 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
         [Test]
         public void PublicKeyRingWithX509Test()
         {
-            checkPublicKeyRingWithX509(pubWithX509);
+            CheckPublicKeyRingWithX509(pubWithX509);
 
             PgpPublicKeyRing pubRing = new PgpPublicKeyRing(pubWithX509);
 
-            checkPublicKeyRingWithX509(pubRing.GetEncoded());
+            CheckPublicKeyRingWithX509(pubRing.GetEncoded());
         }
 
         [Test]
         public void SecretKeyRingWithPersonalCertificateTest()
         {
-            checkSecretKeyRingWithPersonalCertificate(secWithPersonalCertificate);
+            CheckSecretKeyRingWithPersonalCertificate(secWithPersonalCertificate);
             PgpSecretKeyRingBundle secRing = new PgpSecretKeyRingBundle(secWithPersonalCertificate);
-            checkSecretKeyRingWithPersonalCertificate(secRing.GetEncoded());
+            CheckSecretKeyRingWithPersonalCertificate(secRing.GetEncoded());
         }
 
-        private void checkSecretKeyRingWithPersonalCertificate(
+        private void CheckSecretKeyRingWithPersonalCertificate(
             byte[] keyRing)
         {
             PgpSecretKeyRingBundle secCol = new PgpSecretKeyRingBundle(keyRing);
@@ -2523,21 +2549,20 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
             }
         }
 
-        private void checkPublicKeyRingWithX509(
-            byte[] keyRing)
+        private void CheckPublicKeyRingWithX509(byte[] keyRing)
         {
             PgpPublicKeyRing pubRing = new PgpPublicKeyRing(keyRing);
             var en = pubRing.GetPublicKeys().GetEnumerator();
 
             if (en.MoveNext())
             {
-                PgpPublicKey key = (PgpPublicKey) en.Current;
+                PgpPublicKey key = en.Current;
 
                 var sEn = key.GetSignatures().GetEnumerator();
 
                 if (sEn.MoveNext())
                 {
-                    PgpSignature sig = (PgpSignature) sEn.Current;
+                    PgpSignature sig = sEn.Current;
                     if (sig.KeyAlgorithm != PublicKeyAlgorithmTag.Experimental_1)
                     {
                         Fail("experimental signature not found");
@@ -2581,6 +2606,26 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
             }
         }
 
+        [Test]
+        public void TestEdDsaRing()
+        {
+            ArmoredInputStream aIn = new ArmoredInputStream(GetTestDataAsStream("openpgp.eddsa-pub-keyring.asc"));
+
+            // make sure we can parse it without falling over.
+            PgpPublicKeyRing rng = new PgpPublicKeyRing(aIn);
+            Assert.IsNotNull(rng);
+        }
+
+        [Test]
+        public void TestCurve25519Ring()
+        {
+            // make sure we can parse it without falling over.
+            PgpPublicKeyRing rng = new PgpPublicKeyRing(new MemoryStream(curve25519Pub));
+
+            PgpSecretKeyRing priv = new PgpSecretKeyRing(new MemoryStream(curve25519Priv));
+            Assert.IsNotNull(priv);
+        }
+
         public override void PerformTest()
         {
             TestExpiryDate();