Esempio n. 1
0
        public void AreEquivalent()
        {
            var buf   = IDPasswordCredentials.PlainPasswordToSecureBuffer("@8luE+5ky=");
            var hash1 = Manager.ComputeHash(PasswordFamily.Text, buf);
            var hash2 = HashedPassword.FromString(hash1.ToString());



            Aver.IsTrue(m_Manager.AreEquivalent(hash1, hash2));

            Aver.IsFalse(m_Manager.AreEquivalent(null, null));

            var hash3 = new HashedPassword("OTH", hash2.Family);

            hash3["hash"] = hash2["hash"];
            hash3["salt"] = hash2["salt"];
            Aver.IsFalse(m_Manager.AreEquivalent(hash1, hash3));

            hash2 = Manager.ComputeHash(PasswordFamily.Text, buf);
            Aver.IsFalse(m_Manager.AreEquivalent(hash1, hash2));

            buf   = IDPasswordCredentials.PlainPasswordToSecureBuffer("qwerty");
            hash2 = Manager.ComputeHash(PasswordFamily.Text, buf);
            Aver.IsFalse(m_Manager.AreEquivalent(hash1, hash2));
        }
Esempio n. 2
0
        public void Compute_Verify_Pass()
        {
            var  buf = IDPasswordCredentials.PlainPasswordToSecureBuffer("qwerty");
            var  hash = Manager.ComputeHash(PasswordFamily.Text, buf);
            bool rehash, check;

            check = Manager.Verify(buf, hash, out rehash);
            Aver.IsTrue(check);

            buf   = IDPasswordCredentials.PlainPasswordToSecureBuffer("@8luE+5ky=");
            hash  = Manager.ComputeHash(PasswordFamily.Text, buf);
            check = Manager.Verify(buf, hash, out rehash);
            Aver.IsTrue(check);

            check = Manager.Verify(buf, HashedPassword.FromString(hash.ToJSON()), out rehash);
            Aver.IsTrue(check);
        }
Esempio n. 3
0
        public void AreEquivalent()
        {
            var pm = new DefaultPasswordManager(NOPApplication.Instance);

            pm.Start();

            var buf   = IDPasswordCredentials.PlainPasswordToSecureBuffer("@8luE+5ky=");
            var hash1 = Manager.ComputeHash(PasswordFamily.Text, buf);
            var hash2 = HashedPassword.FromString(hash1.ToString());

            try
            {
                Aver.IsTrue(pm.AreEquivalent(hash1, hash2));
                Aver.Fail("no exception");
            }
            catch (AzosException e)
            {
                Aver.AreEqual(e.Message, StringConsts.DAEMON_INVALID_STATE +
                              typeof(DefaultPasswordManager).Name);
            }

            pm.SignalStop();
            pm.WaitForCompleteStop();

            Aver.IsTrue(pm.AreEquivalent(hash1, hash2));

            Aver.IsFalse(pm.AreEquivalent(null, null));

            var hash3 = new HashedPassword("OTH", hash2.Family);

            hash3["hash"] = hash2["hash"];
            hash3["salt"] = hash2["salt"];
            Aver.IsFalse(pm.AreEquivalent(hash1, hash3));

            hash2 = Manager.ComputeHash(PasswordFamily.Text, buf);
            Aver.IsFalse(pm.AreEquivalent(hash1, hash2));

            buf   = IDPasswordCredentials.PlainPasswordToSecureBuffer("qwerty");
            hash2 = Manager.ComputeHash(PasswordFamily.Text, buf);
            Aver.IsFalse(pm.AreEquivalent(hash1, hash2));
        }