summary refs log tree commit diff
path: root/crypto/test/src
diff options
context:
space:
mode:
authorDavid Hook <dgh@bouncycastle.org>2021-05-24 07:36:41 +1000
committerDavid Hook <dgh@bouncycastle.org>2021-05-24 07:36:41 +1000
commit62680d48d8a1ef0237f310d860a5e99f596c2903 (patch)
tree800d152fb9d2b0849c006b516e49dfaf0000f97e /crypto/test/src
parentMerge remote-tracking branch 'refs/remotes/origin/master' (diff)
downloadBouncyCastle.NET-ed25519-62680d48d8a1ef0237f310d860a5e99f596c2903.tar.xz
added sha256 test vector
Diffstat (limited to 'crypto/test/src')
-rw-r--r--crypto/test/src/crypto/test/OAEPTest.cs23
1 files changed, 23 insertions, 0 deletions
diff --git a/crypto/test/src/crypto/test/OAEPTest.cs b/crypto/test/src/crypto/test/OAEPTest.cs
index 0d4374db1..08ecb6314 100644
--- a/crypto/test/src/crypto/test/OAEPTest.cs
+++ b/crypto/test/src/crypto/test/OAEPTest.cs
@@ -12,6 +12,7 @@ using Org.BouncyCastle.Crypto.Generators;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Math;
 using Org.BouncyCastle.Security;
+using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;
 using Org.BouncyCastle.X509;
@@ -823,6 +824,28 @@ namespace Org.BouncyCastle.Crypto.Tests
                     Fail("mixed digest failed decoding");
                 }
             }
+
+            // 2048 bit SHA-256 known answer test
+            byte[] encPub2048 = Base64.Decode("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvF6kzNRPSUM3klXHq6R7O6TfI9XOe6oK5Mm/wYLMY5tqnVXItOG2fQagKhULQSi7ihUTYBbiffG72LCQVUd4/m+FSJmFdbfQgIjtEanBCC4oE4G5/uKuGh1SGQSsppMQiaJ4g1q12RAruOYp6L94JMnSy5pq3czVtbMfiEskO/FfD+nVAnpQNlrRShn268FB4+6FUiR68nwEdQXTEs20/i9V2BwoHuMmIQyjP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bhxKnf16PyWbsvojjdNbAUKMr7G7VhdMFxJUcchARYhh19dtDR2/lJPBX8i9U1j5FXQzRmBz1TEQ4wF5TEYBnReOOnSWxF9kDaANY9jkMoUiAQJfWmKoLMYx5BoNoYhp/4Ri+pRVgTxM/Qp5UnzzzgXsZU4TwKBgQCgfuw/PWALg1SV+x5pbcLBYeSjSzaISf9UVFDZPT1XZB/TJAiiGPrA5jPVvj5AkETOo0jFKL8ojwb22H6j7uVG9HmofJ9LXbOfsvwQIBG2YYsNXT3BsMMYppVQaQrsYEaOWWAfFTC/sdlmUNtkuV3HPE15ztkE+v+O0aUF/U/R/wKBgHCkIFJAMhSgNh8ce6pn47EokzhlxXdHdlXr+2UbyHPQZTkFp4Q3AV159nS1gQDhDseNcqO3f7fsPRNCYP0r0rdeikbEQ3FvgthbY4BIQafjJxENhrQqjrgdMShRrAswmniBaRMFrIWP56RnqUsgbDgFSXL7OwvpExyIQhwSy4kTAoGBAN3x9T7UkwdHSAtpETC+9bGmdcbytHr6JElQKH8jM5sS3FKHR7NSGCGIBmYtbwU3GqU/4JUkDH+ASvsgT2KBLW9kj/zQRV6kW9g0O/2LY3RZ6bOvCs8p4LfPRBm6Zy1bm6h51Em62oXHoViYrI3TSmOfCK9nSeErsxt20sUfsLVW");
+
+            AsymmetricKeyParameter pub2048 = PublicKeyFactory.CreateKey(encPub2048);
+            AsymmetricKeyParameter pri2048 = PrivateKeyFactory.CreateKey(encPri2048);
+
+            input = Strings.ToByteArray("OAEP SHA-256 Test");
+            cipher = new OaepEncoding(new RsaEngine(), new Sha256Digest());
+
+            cipher.Init(true, new ParametersWithRandom(pub2048, new TestRandomData(encPub2048)));
+
+            output = cipher.ProcessBlock(input, 0, input.Length);
+
+            Assert.IsTrue(Arrays.AreEqual(Hex.Decode("8314e8dc39bfe75dcf1ecf770233593fd2f564c8bd2d4a4a66da238f8b3b476cbe4ccf40b2f3efdc74fd1fd015da1b7dd41802d9e61199b59d95714ac54b5479dd639d284038865d5a68790901093a6dac7afc086d26d4855b967eb262394eab9f15c3658ba62f90921d6354ce8d59095df761877b3e5e3278be84bae813f632a95042530eac0e28fa84f2a0202dd76529783ee3826c394476f381978dbabe7c08e76de5944b59aec0145ac6b2b75e1d153411ff8dceb18c14263eec5d9c6fc6cdbbd47006bcc0c905aaaf62d3f6b760dce5eb178635bb3fe02eb5772baa30eaa2cc00282830a9adc813611914e96ac1e3fc5c6319233ac65ff2a3c4468bac99"), output));
+
+            cipher.Init(false, pri2048);
+
+            output = cipher.ProcessBlock(output, 0, output.Length);
+
+            Assert.IsTrue(Arrays.AreEqual(input, output));
         }
 
         private void TestForHighByteError(string label, int keySizeBits)