Skip to content

Commit 725d1df

Browse files
committed
fix 410, blank string as db password
1 parent 81b1236 commit 725d1df

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
- fixed #410 - support empty string as password
2+
13
4.1.0 - 2024-06-26
24
------------------
35
- merged #389 - add PyKeePass.database_name and database_description

pykeepass/kdbx_parsing/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def compute_key_composite(password=None, keyfile=None):
121121
Used in header verification and payload decryption."""
122122

123123
# hash the password
124-
if password:
124+
if password is not None:
125125
password_composite = hashlib.sha256(password.encode('utf-8')).digest()
126126
else:
127127
password_composite = b''

tests/tests.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,7 @@ def test_open_save(self):
11701170
base_dir / 'test4_chacha20_uncompressed.kdbx',# KDBX v4 ChaCha uncompressed
11711171
base_dir / 'test4_argon2id.kdbx', # KDBX v4 Argon2id
11721172
base_dir / 'test4.kdbx', # KDBX v4 with keyfile file descriptor
1173+
base_dir / 'test4_blankpass.kdbx', # KDBX v4 blank password
11731174
]
11741175
filenames_out = [
11751176
base_dir / 'test3.kdbx.out',
@@ -1186,6 +1187,7 @@ def test_open_save(self):
11861187
base_dir / 'test4_chacha20_uncompressed.kdbx.out',# KDBX v4 ChaCha uncompressed
11871188
base_dir / 'test4_argon2id.kdbx.out',
11881189
base_dir / 'test4.kdbx.out', # KDBX v4 with keyfile file descriptor
1190+
base_dir / 'test4_blankpass.kdbx.out', # KDBX v4 with keyfile file descriptor
11891191
]
11901192
passwords = [
11911193
'password',
@@ -1202,6 +1204,7 @@ def test_open_save(self):
12021204
'password',
12031205
'password',
12041206
'password',
1207+
'',
12051208
]
12061209
transformed_keys = [
12071210
None,
@@ -1218,6 +1221,7 @@ def test_open_save(self):
12181221
None,
12191222
None,
12201223
None,
1224+
None,
12211225
]
12221226
keyfiles = [
12231227
base_dir / 'test3.key',
@@ -1233,7 +1237,8 @@ def test_open_save(self):
12331237
None,
12341238
None,
12351239
None,
1236-
keyfile_fd
1240+
keyfile_fd,
1241+
base_dir / 'test4.key',
12371242
]
12381243
encryption_algorithms = [
12391244
'aes256',
@@ -1250,6 +1255,7 @@ def test_open_save(self):
12501255
'chacha20',
12511256
'aes256',
12521257
'chacha20',
1258+
'aes256',
12531259
]
12541260
kdf_algorithms = [
12551261
'aeskdf',
@@ -1266,6 +1272,7 @@ def test_open_save(self):
12661272
'argon2',
12671273
'argon2id',
12681274
'argon2',
1275+
'argon2',
12691276
]
12701277
versions = [
12711278
(3, 1),
@@ -1282,6 +1289,7 @@ def test_open_save(self):
12821289
(4, 0),
12831290
(4, 0),
12841291
(4, 0),
1292+
(4, 0),
12851293
]
12861294

12871295
for (filename_in, filename_out, password, transformed_key,

0 commit comments

Comments
 (0)