Пример #1
0
        public void V2PasswordsUniqueEncryptionTest()
        {
            string key = CalculateNewMasterPasswordKey(MASTERPASSWORD);
            string encryptedPassword  = PasswordFunctions2.EncryptPassword(USERPASSWORD, key);
            string encryptedPassword2 = PasswordFunctions2.EncryptPassword(USERPASSWORD, key);

            Assert.AreNotEqual(encryptedPassword, encryptedPassword2, "password encryption always generates identical encrypted bytes");
        }
Пример #2
0
        private static string CheckEncryptDecryptPasswordV2(string password, string masterPassword)
        {
            string masterKey         = CalculateNewMasterPasswordKey(masterPassword);
            string encryptedPassword = PasswordFunctions2.EncryptPassword(password, masterKey);
            string decryptedPassword = PasswordFunctions2.DecryptPassword(encryptedPassword, masterKey);

            Assert.AreEqual(password, decryptedPassword, "Unable to decrypt password");
            return(encryptedPassword);
        }
Пример #3
0
        private void UpdateStoredPasswords(string newKeyMaterial)
        {
            TerminalsConfigurationSection configSection = GetSection();

            configSection.EncryptedDefaultPassword   = PasswordFunctions2.EncryptPassword(DefaultPassword, newKeyMaterial);
            configSection.EncryptedAmazonAccessKey   = PasswordFunctions2.EncryptPassword(AmazonAccessKey, newKeyMaterial);
            configSection.EncryptedAmazonSecretKey   = PasswordFunctions2.EncryptPassword(AmazonSecretKey, newKeyMaterial);
            configSection.EncryptedConnectionString  = PasswordFunctions2.EncryptPassword(ConnectionString, newKeyMaterial);
            configSection.DatabaseMasterPasswordHash = PasswordFunctions2.EncryptPassword(DatabaseMasterPassword, newKeyMaterial);
        }
Пример #4
0
        private void MigrateNotEncryptedAttribute(XElement element, string attributeName)
        {
            var plainTextAttribute = element.Attribute(attributeName);

            if (plainTextAttribute == null)
            {
                return;
            }

            plainTextAttribute.Value = PasswordFunctions2.EncryptPassword(plainTextAttribute.Value, this.newKey);
        }
Пример #5
0
        private void MigrateNotEncryptedElement(XElement element, string elementName)
        {
            var plainTextElement = element.Element(elementName);

            if (plainTextElement == null)
            {
                return;
            }

            plainTextElement.Value = PasswordFunctions2.EncryptPassword(plainTextElement.Value, this.newKey);
        }
Пример #6
0
        private string UpdateThePropertiesPassword(string rdpOptions)
        {
            var document = XDocument.Parse(rdpOptions);

            if (document.Root == null)
            {
                return(rdpOptions);
            }

            var tsgwPasswordHash = document.Root.Descendants("EncryptedPassword").First();
            var oldPassword      = this.persistenceSecurity.DecryptPersistencePassword(tsgwPasswordHash.Value);

            tsgwPasswordHash.Value = PasswordFunctions2.EncryptPassword(oldPassword, this.newKeyMaterial);
            return(document.ToString());
        }
Пример #7
0
        /// <summary>
        /// Replaces stored encrypted password by new one using newKeymaterial
        /// </summary>
        /// <param name="newKeymaterial">key created from master password hash</param>
        internal void UpdatePasswordByNewKeyMaterial(string newKeymaterial)
        {
            string userName = this.GetDecryptedUserName();

            if (!string.IsNullOrEmpty(userName))
            {
                this.credential.EncryptedUserName = PasswordFunctions2.EncryptPassword(userName, newKeymaterial);
            }

            string domain = this.GetDecryptedDomain();

            if (!string.IsNullOrEmpty(domain))
            {
                this.credential.EncryptedDomain = PasswordFunctions2.EncryptPassword(domain, newKeymaterial);
            }

            string secret = this.GetDecryptedPassword();

            if (!string.IsNullOrEmpty(secret))
            {
                this.credential.EncryptedPassword = PasswordFunctions2.EncryptPassword(secret, newKeymaterial);
            }
        }
Пример #8
0
        private string MigratePassword(string oldPassword)
        {
            var securityPassword = PasswordFunctions.DecryptPassword(oldPassword, this.oldKey);

            return(PasswordFunctions2.EncryptPassword(securityPassword, this.newKey));
        }
Пример #9
0
 /// <summary>
 /// Use only to store all other passwords except settings file passwords
 /// </summary>
 internal string EncryptPersistencePassword(string decryptedPassword)
 {
     return(PasswordFunctions2.EncryptPassword(decryptedPassword, this.PersistenceKeyMaterial));
 }