Bladeren bron

Merge branch 'master' of https://github.com/pwman3/pwman3

oz123 12 jaren geleden
bovenliggende
commit
e9a75eb5e1
5 gewijzigde bestanden met toevoegingen van 15 en 7 verwijderingen
  1. 2 0
      .gitignore
  2. 4 0
      documentation/general_notes.txt
  3. 4 3
      pwman/util/crypto.py
  4. 4 4
      pwman/util/generator.py
  5. 1 0
      scripts/pwman3

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+*.pyc
+build

+ 4 - 0
documentation/general_notes.txt

@@ -54,3 +54,7 @@ finally you should step into:
 
     node.get_username()
 
+# New features to implement:
+  1. Password expiry date - register password date,  remind when password is about to expire.
+  2. Make new passwords according to user defined rules. 
+

+ 4 - 3
pwman/util/crypto.py

@@ -50,7 +50,8 @@ from Crypto.Cipher import CAST as cCAST
 from Crypto.Cipher import DES as cDES
 from Crypto.Cipher import DES3 as cDES3
 
-from Crypto.Util.randpool import RandomPool
+from Crypto.Random import OSRNG
+
 
 from pwman.util.callback import Callback
 import pwman.util.config as config
@@ -211,8 +212,8 @@ specified")
         if (self._keycrypted == None):
             # Generate a new key, 32 bits in length, if that's
             # too long for the Cipher, _getCipherReal will sort it out
-            random = RandomPool()
-            key = str(random.get_bytes(32)).encode('base64')
+            random = OSRNG.new()
+            key = str(random.read(32)).encode('base64')
         else:
             password = self._callback.getsecret("Please enter your current \
 password")

+ 4 - 4
pwman/util/generator.py

@@ -31,7 +31,7 @@ minlen = 6
 maxlen = 8
 (word, hypenated_word) = PwGen.generate_password(minlen, maxlen)
 """
-import random
+from Crypto.Random import random
 
 class PasswordGenerationException(Exception):
     def __init__(self, message):
@@ -53,7 +53,7 @@ def generate_password(minlen, maxlen, capitals = True, symbols = False, numerics
 def randomly_capitalize(password):
     newpassword = str()
     for l in password:
-        if (random.random() >= 0.5):
+        if random.randint(0, 1):
             l = l.upper()
         newpassword = newpassword + l
     return newpassword
@@ -61,7 +61,7 @@ def randomly_capitalize(password):
 def leetify(password):
     newpassword = str()
     for l in password:
-        if (random.random() >= 0.5):
+        if random.randint(0, 1):
             l = leetify_char(l)
         newpassword = newpassword + l
     return newpassword
@@ -69,7 +69,7 @@ def leetify(password):
 def change_numerics(password):
     newpassword = str()
     for l in password:
-        if (random.random() >= 0.5):
+        if random.randint(0, 1):
             l = change_numerics_char(l)
         newpassword = newpassword + l
     return newpassword

+ 1 - 0
scripts/pwman3

@@ -56,6 +56,7 @@ if 'darwin' in sys.platform:
     OSX=True
 else:
     from pwman.ui.cli import PwmanCli
+    OSX=False
 
 import pwman.util.config as config
 import pwman.data.factory