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); }
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; }
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); }
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); } }
private void AssignFieldsByOldMasterPassword(string masterPassword) { this.oldKey = PasswordFunctions.CalculateMasterPasswordKey(masterPassword); this.storedMasterPassword = PasswordFunctions2.CalculateStoredMasterPasswordKey(masterPassword); this.newKey = PasswordFunctions2.CalculateMasterPasswordKey(masterPassword, this.storedMasterPassword); }
private static string CalculateNewMasterPasswordKey(string password) { string storedKey = PasswordFunctions2.CalculateStoredMasterPasswordKey(password); return(PasswordFunctions2.CalculateMasterPasswordKey(password, storedKey)); }