Beispiel #1
0
        public void EncodeDecodePublicKey()
        {
            var       keyMaster = new KeyMaster();
            PublicKey pk        = keyMaster.GenerateKeyPair().PublicKey;
            string    encoded   = keyMaster.EncodePublicKey(pk);

            Assert.IsNotNull(encoded);

            PublicKey pk2 = keyMaster.DecodePublicKey(encoded);

            Assert.IsNotNull(pk2);
            Assert.AreEqual(pk, pk2);
        }
Beispiel #2
0
        public void DecodePublicKey()
        {
            var          km        = new KeyMaster();
            const string keyString =
                "MIIBCgKCAQEAr3a1JDZOo6oo6HGEhmFmkwmV6UNPdB4ZTZnv5KHI2j9Cc90h9aZvRkzd28NSh0fPP"
                + "/RxRMzAb5r08QgqcHWK5reBQGcj3k+f1gTyUlDssIBlbbP2Z/7VJsHPXoU53MLUZ4K/BPEKYkZV"
                + "CsWmVB07sWV4ThTsX934pxT+ybNH8FDdjGfLFwU3fINXQHVf34iwYcSJPWbtPb6dSrXD8c0h/X/"
                + "3WCaMjLhyvuXi4jdBLGAAP/UXBobqwFDcrW1CO5RSyEIjKcR2A6fvN1Kx6zGLzaZjWdb5miBU73"
                + "b6C0vjVjlIarK/+EYBrVUDLl3yBPfJn29SOoyQeejY8pTQ9XzgAwIDAQAB";
            PublicKey publicKey = km.DecodePublicKey(keyString);

            Assert.IsNotNull(publicKey);

            string encoded = km.EncodePublicKey(publicKey);

            Assert.IsNotNull(encoded);
        }
Beispiel #3
0
        public void EncryptWithIosPublicKey()
        {
            var km = new KeyMaster();
            var c  = new Cryptographer(km);

            const string KeyString =
                "MIIBCgKCAQEAr3a1JDZOo6oo6HGEhmFmkwmV6UNPdB4ZTZnv5KHI2j9Cc90h9aZvRkzd28NSh0fPP"
                + "/RxRMzAb5r08QgqcHWK5reBQGcj3k+f1gTyUlDssIBlbbP2Z/7VJsHPXoU53MLUZ4K/BPEKYkZV"
                + "CsWmVB07sWV4ThTsX934pxT+ybNH8FDdjGfLFwU3fINXQHVf34iwYcSJPWbtPb6dSrXD8c0h/X/"
                + "3WCaMjLhyvuXi4jdBLGAAP/UXBobqwFDcrW1CO5RSyEIjKcR2A6fvN1Kx6zGLzaZjWdb5miBU73"
                + "b6C0vjVjlIarK/+EYBrVUDLl3yBPfJn29SOoyQeejY8pTQ9XzgAwIDAQAB";
            PublicKey publicKey = km.DecodePublicKey(KeyString);

            Message msg = c.HybridEncrypt("test", publicKey);

            Assert.IsNotNull(msg);
            Assert.IsNotNull(msg.Key);
            Assert.IsNotNull(msg.Data);
            Log.Info("Key  : " + msg.Key);
            Log.Info("Data : " + msg.Data);
        }