public void RoundTripTest() { string serverKey = "MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAElakYLA/xXdxMgBY+A6v/hOca33Lnz1Dr56XQuTOUdWN6z8mbg5DjoBL+hc3t4gG+GdIGLcBew+56UJRfm313HZIhR6zpNnhqyA9GJsbCsBTq1D3A2zp+jpUZmrzuQBR/"; ECDiffieHellmanPublicKey publicKey = CryptoUtils.FromDerEncoded(serverKey.DecodeBase64Url()); string b64Key = publicKey.ToDerEncoded().EncodeBase64(); Assert.AreEqual(serverKey, b64Key); }
public void TestKeyMangling() { string keyString = "MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEDEKneqEvcqUqqFMM1HM1A4zWjJC+I8Y+aKzG5dl+6wNOHHQ4NmG2PEXRJYhujyodFH+wO0dEr4GM1WoaWog8xsYQ6mQJAC0eVpBM96spUB1eMN56+BwlJ4H3Qx4TAvAs"; byte[] keyBytes = Base64Url.Decode(keyString); ECDiffieHellmanPublicKey clientKey = CryptoUtils.FromDerEncoded(keyString.DecodeBase64Url()); byte[] outBytes = clientKey.ToDerEncoded(); string outString = outBytes.EncodeBase64(); Console.WriteLine(Package.HexDump(keyBytes)); Console.WriteLine(Package.HexDump(outBytes)); Assert.AreEqual(keyBytes, outBytes); Assert.AreEqual(keyString, outString); }