diff --git a/pyPdf/generic.py b/pyPdf/generic.py index 576ee0c..ffb19d3 100644 --- a/pyPdf/generic.py +++ b/pyPdf/generic.py @@ -298,7 +298,7 @@ def readStringFromStream(stream): elif tok == b"r": tok = b"\r" elif tok == b"t": - tok = "\t" + tok = b"\t" elif tok == b"b": tok = b"\b" elif tok == b"f": diff --git a/pyPdf/pdf.py b/pyPdf/pdf.py index 25994d4..fb959da 100644 --- a/pyPdf/pdf.py +++ b/pyPdf/pdf.py @@ -903,15 +903,16 @@ def _authenticateUserPassword(self, password): p_entry = encrypt['/P'].getObject() id_entry = self.trailer['/ID'].getObject() id1_entry = id_entry[0].getObject() + real_U = encrypt['/U'].getObject().original_bytes if rev == 2: U, key = _alg34(password, owner_entry, p_entry, id1_entry) + return U == real_U, key elif rev >= 3: U, key = _alg35(password, rev, encrypt["/Length"].getObject() // 8, owner_entry, p_entry, id1_entry, encrypt.get("/EncryptMetadata", BooleanObject(False)).getObject()) - real_U = encrypt['/U'].getObject().original_bytes - return U == real_U, key + return U[:16] == real_U[:16], key def getIsEncrypted(self): return "/Encrypt" in self.trailer