Browse Source

Instead of padding the key, it's hashed,

This is supposed to be more secure.
oz123 11 years ago
parent
commit
554838674a
1 changed files with 3 additions and 4 deletions
  1. 3 4
      pwman/util/crypto.py

+ 3 - 4
pwman/util/crypto.py

@@ -49,16 +49,15 @@ from Crypto.Cipher import ARC4 as cARC4
 from Crypto.Cipher import CAST as cCAST
 from Crypto.Cipher import CAST as cCAST
 from Crypto.Cipher import DES as cDES
 from Crypto.Cipher import DES as cDES
 from Crypto.Cipher import DES3 as cDES3
 from Crypto.Cipher import DES3 as cDES3
-
 from Crypto.Random import OSRNG
 from Crypto.Random import OSRNG
 
 
-
 from pwman.util.callback import Callback
 from pwman.util.callback import Callback
 import pwman.util.config as config
 import pwman.util.config as config
 import cPickle
 import cPickle
 import time
 import time
 import sys
 import sys
 import ctypes
 import ctypes
+import hashlib
 
 
 
 
 def zerome(string):
 def zerome(string):
@@ -349,8 +348,8 @@ password again")
         form PyCrypto
         form PyCrypto
         """
         """
         if (algo == "AES"):
         if (algo == "AES"):
-            key = self._padkey(key, [16, 24, 32])
-            cipher = cAES.new(key, cAES.MODE_ECB)
+            key = hashlib.sha256(key)
+            cipher = cAES.new(key.digest(), cAES.MODE_ECB)
         elif (algo == 'ARC2'):
         elif (algo == 'ARC2'):
             cipher = cARC2.new(key, cARC2.MODE_ECB)
             cipher = cARC2.new(key, cARC2.MODE_ECB)
         elif (algo == 'ARC4'):
         elif (algo == 'ARC4'):