示例#1
0
        public void SignatureKeyCheck()
        {
            DigitalSignatureUtils.RetrieveKeyPair("addr1");

            var pubKey = DigitalSignatureUtils.RetrievePublicKey();

            Assert.IsTrue(pubKey != null);
        }
示例#2
0
        private void OnLogin(object obj)
        {
            if (string.IsNullOrWhiteSpace(Username))
            {
                Error           = "Enter a username.";
                ErrorVisibility = Visibility.Visible;
                return;
            }

            User user = userRepo.Get(Username);

            if (user != null)
            {
                PasswordBox passwordBox = obj as PasswordBox;
                string      password    = passwordBox.Password;

                var passwordHash = HashUtils.ComputeHashSha256(
                    Encoding.UTF8.GetBytes(
                        password +
                        user.Salt
                        )
                    );

                password = string.Empty;

                if (Convert.ToBase64String(passwordHash).Equals(user.Password))
                {
                    bool validOwner = DigitalSignatureUtils.RetrieveKeyPair(user.Address);

                    if (validOwner)
                    {
                        Application.Current.Resources["SID"] = user.Id;

                        ViewModelLocator.Main.CurrentViewModel = ViewModelLocator.Dashboard;

                        Messenger.Default.Send(user);

                        dialogCoordinator.ShowMessageAsync(
                            this,
                            "Login Successful",
                            "You are now signed into your profile."
                            );
                    }
                    else
                    {
                        dialogCoordinator.ShowMessageAsync(
                            this,
                            "Security Breach - 3",
                            "A valid key pair associated to this account wasn't found on your machine."
                            );
                    }
                }
                else
                {
                    dialogCoordinator.ShowMessageAsync(
                        this,
                        "Login Failed",
                        "The credentials you provided are invalid. Please double check and retry."
                        );
                }
            }
            else
            {
                dialogCoordinator.ShowMessageAsync(
                    this,
                    "Login Failed",
                    "The credentials you provided are invalid. Please double check and retry."
                    );
            }
        }