Exemplo n.º 1
0
 public void ImportKeyPair()
 {
     CryptoProvider.RLWE_Provider p = new CryptoProvider.RLWE_Provider();
     if (!p.IsInitialized())
     {
         p.ImportKeyPairFromFile("C:\\temp\\keyPair.rle");
         Assert.IsTrue(p.IsInitialized());
     }
 }
Exemplo n.º 2
0
        public void SignMessage()
        {
            string Message = "This is a test message";

            CryptoProvider.RLWE_Provider p = new CryptoProvider.RLWE_Provider();
            p.ImportKeyPairFromFile("C:\\temp\\keyPair.rle");

            Assert.IsTrue(p.IsInitialized());

            string signature = p.SignMessage(Message);

            Assert.IsFalse(string.IsNullOrEmpty(signature));

            Console.WriteLine(signature);

            IPublicKey pubKey = p.GetPublicKey();

            Assert.IsTrue(pubKey != null);

            bool isValid = p.VerifySignature(Message, signature, pubKey);

            Assert.IsTrue(isValid);

            isValid = p.VerifySignature("This message has been tampered with", signature, pubKey);

            Assert.IsFalse(isValid);
        }
Exemplo n.º 3
0
        public void GenerateKey()
        {
            CryptoProvider.RLWE_Provider p = new CryptoProvider.RLWE_Provider();
            bool result = p.GenerateKeyPair();

            Assert.IsTrue(result);
            Assert.IsTrue(p.IsInitialized());
        }
Exemplo n.º 4
0
 public void ExportKeyPair()
 {
     CryptoProvider.RLWE_Provider p = new CryptoProvider.RLWE_Provider();
     p.GenerateKeyPair();
     if (p.IsInitialized())
     {
         p.ExportKeyPairToFile("C:\\temp\\keyPair.rle");
     }
 }