简体   繁体   English

如何验证用于解密文件的密码?

[英]How is a password to decrypt a file verified?

Let's say I have a password-protected PDF file, mypdf.pdf , with the password '1234' . 假设我有一个受密码保护的PDF文件mypdf.pdf ,其密码为'1234' When I enter the password into the PDF reader to decrypt it, how does the software know I entered the correct password? 当我在PDF阅读器中输入密码进行解密时,软件如何知道我输入了正确的密码?

My understanding is that when I enter in a password an operation is performed on all of the bytes inside the PDF file using the entered password as the key. 我的理解是,当我输入密码时,将使用输入的密码作为密钥对PDF文件中的所有字节执行操作。 So even if I enter the wrong password the data is still being transformed, with the incorrect key. 因此,即使我输入了错误的密码,仍会使用错误的密钥来转换数据。

My question is how the software can distinguish between data that is the result of a correct password being typed in and data that is the result of a wrong password. 我的问题是该软件如何区分输入正确密码后的数据和密码错误后的数据。

The content of a PDF document is not decrypted unless an authentication algorithm passes. 除非通过认证算法,否则不会解密PDF文档的内容。

These algorithms are defined in eg PDF 32000-1:2008 - 7.6.3.4 Password Algorithms. 这些算法在例如PDF 32000-1: 2008-7.6.3.4密码算法中定义。

In simple words: When creating an encrypted PDF the user and owner password are used to calculate static values (O, U, OE and UE) which were saved in the PDF file itself. 简而言之:创建加密的PDF时,将使用用户名和所有者密码来计算保存在PDF文件本身中的静态值(O,U,OE和UE)。 The authentication is a "simple" process of recreating these values by the given password and comparing them with the static values in the PDF file. 身份验证是一个“简单”的过程,通过给定的密码重新创建这些值并将它们与PDF文件中的静态值进行比较。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM