示例#1
0
        public void RoundTripTest()
        {
            string serverKey = "MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAElakYLA/xXdxMgBY+A6v/hOca33Lnz1Dr56XQuTOUdWN6z8mbg5DjoBL+hc3t4gG+GdIGLcBew+56UJRfm313HZIhR6zpNnhqyA9GJsbCsBTq1D3A2zp+jpUZmrzuQBR/";

            ECDiffieHellmanPublicKey publicKey = CryptoUtils.CreateEcDiffieHellmanPublicKey(serverKey);

            string b64Key = Convert.ToBase64String(publicKey.GetDerEncoded());

            Assert.AreEqual(serverKey, b64Key);
        }
示例#2
0
        public void TestKeyMangling()
        {
            string keyString = "MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEDEKneqEvcqUqqFMM1HM1A4zWjJC+I8Y+aKzG5dl+6wNOHHQ4NmG2PEXRJYhujyodFH+wO0dEr4GM1WoaWog8xsYQ6mQJAC0eVpBM96spUB1eMN56+BwlJ4H3Qx4TAvAs";

            byte[] keyBytes = Base64Url.Decode(keyString);

            ECDiffieHellmanPublicKey clientKey = CryptoUtils.CreateEcDiffieHellmanPublicKey(keyString);

            byte[] outBytes = clientKey.GetDerEncoded();

            string outString = Convert.ToBase64String(outBytes);

            Console.WriteLine(Package.HexDump(keyBytes));
            Console.WriteLine(Package.HexDump(outBytes));

            Assert.AreEqual(keyBytes, outBytes);

            Assert.AreEqual(keyString, outString);
        }