Browse Source

Fix failing tests with new crypto_engine

oz123 10 years ago
parent
commit
0f5ac04ffb
2 changed files with 5 additions and 6 deletions
  1. 0 1
      pwman/tests/db_tests.py
  2. 5 5
      pwman/util/crypto_engine.py

+ 0 - 1
pwman/tests/db_tests.py

@@ -107,7 +107,6 @@ class DBTests(unittest.TestCase):
         password = u'Password'
         password = u'Password'
         url = u'example.org'
         url = u'example.org'
         notes = u'some notes'
         notes = u'some notes'
-        # node = NewNode(username, password, url, notes)
         node = NewNode()
         node = NewNode()
         node.username = username
         node.username = username
         node.password = password
         node.password = password

+ 5 - 5
pwman/util/crypto_engine.py

@@ -212,7 +212,7 @@ class CryptoEngine(object):  # pagma: no cover
         finish the execution an return the password and salt which
         finish the execution an return the password and salt which
         are read from the file.
         are read from the file.
         """
         """
-        salt, digest = get_digest_from_file('passwords.txt')
+        salt, digest = self._salt, self._digest
         tries = 0
         tries = 0
         while tries < 5:
         while tries < 5:
             password = self._getsecret("Please type in your master password:"
             password = self._getsecret("Please type in your master password:"
@@ -222,7 +222,6 @@ class CryptoEngine(object):  # pagma: no cover
 
 
             print("You entered a wrong password...")
             print("You entered a wrong password...")
             tries += 1
             tries += 1
-
         raise CryptoException("You entered wrong password 5 times..")
         raise CryptoException("You entered wrong password 5 times..")
 
 
     def encrypt(self, text):
     def encrypt(self, text):
@@ -236,7 +235,7 @@ class CryptoEngine(object):  # pagma: no cover
 
 
     def decrypt(self, cipher_text):
     def decrypt(self, cipher_text):
         if not self._is_authenticated():
         if not self._is_authenticated():
-            p, s = cli_auth(self._reader)
+            p, s = self._auth()
             cipher = get_cipher(p, s)
             cipher = get_cipher(p, s)
             del(p)
             del(p)
             return DecodeAES(cipher, prepare_data(cipher_text, AES.block_size))
             return DecodeAES(cipher, prepare_data(cipher_text, AES.block_size))
@@ -307,13 +306,14 @@ class CryptoEngine(object):  # pagma: no cover
         # TODO: rename this method!
         # TODO: rename this method!
         salt, digest = key.split('$6$')
         salt, digest = key.split('$6$')
         self._digest = digest.encode('utf-8')
         self._digest = digest.encode('utf-8')
-        self._salt = salt.encode('utf-8'),
+        self._salt = salt.encode('utf-8')
+
     def get_cryptedkey(self):
     def get_cryptedkey(self):
         # TODO: rename this method!
         # TODO: rename this method!
         """
         """
         return _keycrypted
         return _keycrypted
         """
         """
-        return self._keycrypted
+        return self._salt + '$6$' + self._digest
 
 
 
 
 if __name__ == '__main__':  # pragma: no cover
 if __name__ == '__main__':  # pragma: no cover