Skip to content

Commit c23b0a3

Browse files
committed
fixed string encoding of SSHA encoded passwords in Python 3
1 parent 0dced74 commit c23b0a3

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ Python v2.5 and v2.6. Starting with the v1.6 releases of Roundup
1111
v2.7.2 or later are required to run newer releases of Roundup. From v2.0
1212
onwards Python 3.4 and later are also supported.
1313

14+
2020-XX-YY 2.0.0 beta 1
15+
16+
Fixed:
17+
18+
- encoding for SSHA encoded passwords with Python 3 (Christof
19+
Meerwald)
1420

1521
2020-04-05 2.0.0 beta 0
1622

roundup/password.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def ssha(password, salt):
114114
'''
115115
shaval = sha1(password) # nosec
116116
shaval.update(salt)
117-
ssha_digest = b64encode(shaval.digest() + salt).strip()
117+
ssha_digest = b2s(b64encode(shaval.digest() + salt).strip())
118118
return ssha_digest
119119

120120

@@ -359,13 +359,17 @@ def __str__(self):
359359
def test():
360360
# SHA
361361
p = Password('sekrit')
362+
assert Password(encrypted=str(p)) == 'sekrit'
363+
assert 'sekrit' == Password(encrypted=str(p))
362364
assert p == 'sekrit'
363365
assert p != 'not sekrit'
364366
assert 'sekrit' == p
365367
assert 'not sekrit' != p
366368

367369
# MD5
368370
p = Password('sekrit', 'MD5')
371+
assert Password(encrypted=str(p)) == 'sekrit'
372+
assert 'sekrit' == Password(encrypted=str(p))
369373
assert p == 'sekrit'
370374
assert p != 'not sekrit'
371375
assert 'sekrit' == p
@@ -374,13 +378,17 @@ def test():
374378
# crypt
375379
if crypt: # not available on Windows
376380
p = Password('sekrit', 'crypt')
381+
assert Password(encrypted=str(p)) == 'sekrit'
382+
assert 'sekrit' == Password(encrypted=str(p))
377383
assert p == 'sekrit'
378384
assert p != 'not sekrit'
379385
assert 'sekrit' == p
380386
assert 'not sekrit' != p
381387

382388
# SSHA
383389
p = Password('sekrit', 'SSHA')
390+
assert Password(encrypted=str(p)) == 'sekrit'
391+
assert 'sekrit' == Password(encrypted=str(p))
384392
assert p == 'sekrit'
385393
assert p != 'not sekrit'
386394
assert 'sekrit' == p
@@ -397,6 +405,8 @@ def test():
397405

398406
# PBKDF2 - high level integration
399407
p = Password('sekrit', 'PBKDF2')
408+
assert Password(encrypted=str(p)) == 'sekrit'
409+
assert 'sekrit' == Password(encrypted=str(p))
400410
assert p == 'sekrit'
401411
assert p != 'not sekrit'
402412
assert 'sekrit' == p

0 commit comments

Comments
 (0)