Esempio n. 1
0
        public void CanSignAndVerify()
        {
            RsaKey key = TestKeys.Default;

            for (int i = 0; i < 100; i++)
            {
                var data = RandomUtils.GetBytes(234);
                var sig  = key.Sign(data, out uint160 nonce);
                Assert.True(key.PubKey.Verify(sig, data, nonce));
            }
        }
Esempio n. 2
0
 private static string GetRsaStringEncrypted(string message)
 {
     try
     {
         var m = Encoding.Default.GetBytes(message);
         var c = _rsa.Sign(m);
         return(Converter.BytesToHexString(c));
     }
     catch
     {
         return("0");
     }
 }
Esempio n. 3
0
        private static string DecryptRSAString(string message)
        {
            try
            {
                byte[] m = Encoding.Default.GetBytes(message);
                byte[] c = Rsa.Sign(m);

                return(Converter.BytesToHexString(c));
            }
            catch
            {
                return("0");
            }
        }
Esempio n. 4
0
        private static string GetRsaStringEncrypted(string message)
        {
            try
            {
                byte[] m = Encoding.Default.GetBytes(message);
                byte[] c = Rsa.Sign(m);

                return(Converter.BytesToHexString(c));
            }
            catch
            {
                Writer.LogCriticalException("Sorry, the Encryption Handler stopped Inesperatelly. Please Restart Emulator.");
                return(null);
            }
        }
Esempio n. 5
0
        private static string GetRsaStringEncrypted(string message)
        {
            try
            {
                byte[] m = Encoding.Default.GetBytes(message);
                byte[] c = Rsa.Sign(m);

                return(Converter.BytesToHexString(c));
            }
            catch (Exception e)
            {
                YupiLogManager.LogCriticalException(e, "Encryption System Crashed.", "Yupi.Users");

                return(null);
            }
        }
Esempio n. 6
0
        public static void CanVerifyBlind()
        {
            // generate rsa keypair
            var key = new RsaKey();

            // generate blinding factor with pubkey
            // blind message
            byte[] message        = Encoding.ASCII.GetBytes("sing me please");
            var    blindingResult = key.PubKey.Blind(message);

            // sign the blinded message
            var signature = key.Sign(blindingResult.BlindedData);

            // unblind the signature
            var unblindedSignature = key.PubKey.Unblind(signature, blindingResult.BlindingFactor);

            // unblind message
            var unblindedMessage = key.PubKey.Unblind(blindingResult.BlindedData, blindingResult.BlindingFactor);

            // verify the original data is signed
            Console.WriteLine(key.PubKey.Verify(unblindedSignature, message));
        }