Esempio n. 1
0
        private void Configure(string connectionString, string oldPassword, string newPassword)
        {
            // persistence doesn't have to be fully configured, we need only the persistence passwords part
            this.persistenceSecurity = new SqlPersistenceSecurity();
            this.persistenceSecurity.UpdateDatabaseKey(connectionString, oldPassword);

            if (!string.IsNullOrEmpty(newPassword))
            {
                this.newStoredKey = PasswordFunctions2.CalculateStoredMasterPasswordKey(newPassword);
            }
            this.newKeyMaterial = PasswordFunctions2.CalculateMasterPasswordKey(newPassword, this.newStoredKey);
        }
Esempio n. 2
0
        internal void UpdateMasterPassword(string newPassword)
        {
            string storedMasterPassword = PasswordFunctions2.CalculateStoredMasterPasswordKey(newPassword);
            string newMasterKey         = PasswordFunctions2.CalculateMasterPasswordKey(newPassword, storedMasterPassword);

            // start of not secured transaction. Old key is still present,
            // but passwords are already encrypted by new Key
            this.persistence.UpdatePasswordsByNewMasterPassword(newMasterKey);
            settings.UpdateConfigurationPasswords(newMasterKey, storedMasterPassword);
            // finish transaction, the passwords now reflect the new key
            this.KeyMaterial = newMasterKey;
        }
Esempio n. 3
0
        private Boolean IsMasterPasswordValid(string passwordToCheck)
        {
            string storedMasterPassword = this.settings.MasterPasswordHash;
            bool   isValid = PasswordFunctions2.MasterPasswordIsValid(passwordToCheck, storedMasterPassword);

            if (isValid)
            {
                this.KeyMaterial = PasswordFunctions2.CalculateMasterPasswordKey(passwordToCheck, storedMasterPassword);
                return(true);
            }

            return(false);
        }
Esempio n. 4
0
 internal bool UpdateDatabaseKey(string connectionString, string databasePassword)
 {
     try
     {
         string databaseStoredKey = DatabaseConnections.TryGetMasterPasswordHash(connectionString);
         this.persistenceKeyMaterial = PasswordFunctions2.CalculateMasterPasswordKey(databasePassword, databaseStoredKey);
         return(true);
     }
     catch
     {
         Logging.Error("Unable to obtain database key from database");
         return(false);
     }
 }
Esempio n. 5
0
 private void AssignFieldsByOldMasterPassword(string masterPassword)
 {
     this.oldKey = PasswordFunctions.CalculateMasterPasswordKey(masterPassword);
     this.storedMasterPassword = PasswordFunctions2.CalculateStoredMasterPasswordKey(masterPassword);
     this.newKey = PasswordFunctions2.CalculateMasterPasswordKey(masterPassword, this.storedMasterPassword);
 }
Esempio n. 6
0
        private static string CalculateNewMasterPasswordKey(string password)
        {
            string storedKey = PasswordFunctions2.CalculateStoredMasterPasswordKey(password);

            return(PasswordFunctions2.CalculateMasterPasswordKey(password, storedKey));
        }