Exemple #1
0
        private byte[] KeyStoreDecrypt(PasswordRegistryTypes passwordIdentifier, string json)
        {
            var tries = 0;

            while (tries < MaxTries)
            {
                var securePassword =
                    _passwordManager.RetrieveOrPromptPassword(passwordIdentifier, "Please provide your node password");
                var password = StringFromSecureString(securePassword);

                try
                {
                    var keyBytes = DecryptKeyStoreFromJson(password, json);

                    if (keyBytes != null && keyBytes.Length > 0)
                    {
                        _passwordManager.AddPasswordToRegistry(passwordIdentifier, securePassword);
                        return(keyBytes);
                    }
                }
                catch (DecryptionException)
                {
                    securePassword.Dispose();
                    _logger.Error("Error decrypting keystore");
                }

                tries += 1;
            }

            throw new AuthenticationException("Password incorrect for keystore.");
        }