diff --git a/PyPDF2/_encryption.py b/PyPDF2/_encryption.py index 80cd369b6..b2b3f5e46 100644 --- a/PyPDF2/_encryption.py +++ b/PyPDF2/_encryption.py @@ -516,10 +516,10 @@ def verify_owner_password( should match the value in the P key. """ password = password[:127] - if AlgV5.calculate_hash(R, password, o_value[32:40], u_value) != o_value[:32]: + if AlgV5.calculate_hash(R, password, o_value[32:40], u_value[:48]) != o_value[:32]: return b"" iv = bytes(0 for _ in range(16)) - tmp_key = AlgV5.calculate_hash(R, password, o_value[40:], u_value) + tmp_key = AlgV5.calculate_hash(R, password, o_value[40:48], u_value[:48]) key = AES_CBC_decrypt(tmp_key, iv, oe_value) return key @@ -532,7 +532,7 @@ def verify_user_password( if AlgV5.calculate_hash(R, password, u_value[32:40], b"") != u_value[:32]: return b"" iv = bytes(0 for _ in range(16)) - tmp_key = AlgV5.calculate_hash(R, password, u_value[40:], b"") + tmp_key = AlgV5.calculate_hash(R, password, u_value[40:48], b"") return AES_CBC_decrypt(tmp_key, iv, ue_value) @staticmethod