Skip to content

Commit 56220ab

Browse files
authored
STY: Remove Unnecessary assignment before return (#3182)
1 parent e3b37fa commit 56220ab

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

pypdf/_encryption.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ def compute_O_value_key(owner_password: bytes, rev: int, key_size: int) -> bytes
253253
for _ in range(50):
254254
o_hash_digest = hashlib.md5(o_hash_digest).digest()
255255

256-
rc4_key = o_hash_digest[: key_size // 8]
257-
return rc4_key
256+
return o_hash_digest[: key_size // 8]
258257

259258
@staticmethod
260259
def compute_O_value(rc4_key: bytes, user_password: bytes, rev: int) -> bytes:
@@ -303,8 +302,7 @@ def compute_U_value(key: bytes, rev: int, id1_entry: bytes) -> bytes:
303302
304303
"""
305304
if rev <= 2:
306-
value = rc4_encrypt(key, _PADDING)
307-
return value
305+
return rc4_encrypt(key, _PADDING)
308306

309307
"""
310308
Algorithm 5: Computing the encryption dictionary’s U (user password) value.
@@ -542,8 +540,7 @@ def verify_owner_password(
542540
return b""
543541
iv = bytes(0 for _ in range(16))
544542
tmp_key = AlgV5.calculate_hash(R, password, o_value[40:48], u_value[:48])
545-
key = aes_cbc_decrypt(tmp_key, iv, oe_value)
546-
return key
543+
return aes_cbc_decrypt(tmp_key, iv, oe_value)
547544

548545
@staticmethod
549546
def verify_user_password(
@@ -761,8 +758,7 @@ def compute_Perms_value(key: bytes, p: int, metadata_encrypted: bool) -> bytes:
761758
b8 = b"T" if metadata_encrypted else b"F"
762759
rr = secrets.token_bytes(4)
763760
data = struct.pack("<I", p) + b"\xff\xff\xff\xff" + b8 + b"adb" + rr
764-
perms = aes_ecb_encrypt(key, data)
765-
return perms
761+
return aes_ecb_encrypt(key, data)
766762

767763

768764
class PasswordType(IntEnum):

0 commit comments

Comments
 (0)