diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-03-27 15:52:07 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-03-27 15:52:07 +0700 |
commit | c57bfb1947029444533f14bfcd5174f3e07f6168 (patch) | |
tree | 6225e835ccc56cd5b9654fab26b81816a7107838 /crypto/test | |
parent | Add SignedPublicKeyAndChallenge into Asn1/Mozilla. (diff) | |
download | BouncyCastle.NET-ed25519-c57bfb1947029444533f14bfcd5174f3e07f6168.tar.xz |
Rework SIgnedPublicKeyAndChallenge
Diffstat (limited to 'crypto/test')
-rw-r--r-- | crypto/test/src/mozilla/test/SpkacTest.cs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/crypto/test/src/mozilla/test/SpkacTest.cs b/crypto/test/src/mozilla/test/SpkacTest.cs new file mode 100644 index 000000000..3d7533865 --- /dev/null +++ b/crypto/test/src/mozilla/test/SpkacTest.cs @@ -0,0 +1,34 @@ +using NUnit.Framework; + +using Org.BouncyCastle.Asn1; +using Org.BouncyCastle.Utilities; +using Org.BouncyCastle.Utilities.Encoders; + +namespace Org.BouncyCastle.Mozilla.Tests +{ + [TestFixture] + public class SpkacTest + { + private static readonly byte[] Spkac = Base64.Decode( + "MIIBOjCBpDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEApne7ti0ibPhV8Iht" + + "7Pws5iRckM7x4mtZYxEpeX5/IO8tDsBFdY86ewuY2f2KCca0oMWr43kdkZbPyzf4" + + "CSV+0fZm9MJyNMywygZjoOCC+rS8kr0Ef31iHChhYsyejJnjw116Jnn96syhdHY6" + + "lVD1rK0nn5ZkHjxU74gjoZu6BJMCAwEAARYAMA0GCSqGSIb3DQEBBAUAA4GBAKFL" + + "g/luv0C7gMTI8ZKfFoSyi7Q7kiSQcmSj1WJgT56ouIRJO5NdvB/1n4GNik8VOAU0" + + "NRztvGy3ZGqgbSav7lrxcNEvXH+dLbtS97s7yiaozpsOcEHqsBribpLOTRzYa8ci" + + "CwkPmIiYqcby11diKLpd+W9RFYNme2v0rrbM2CyV"); + + [Test] + public void TestSpkac() + { + var spkac = new SignedPublicKeyAndChallenge(Spkac); + + var reencoded = spkac.ToAsn1Structure().GetEncoded(Asn1Encodable.Der); + Assert.True(Arrays.AreEqual(Spkac, reencoded)); + + var publicKey = spkac.GetPublicKey(); + var shouldVerify = spkac.IsSignatureValid(publicKey); + Assert.True(shouldVerify); + } + } +} |