I receive emails from my bank with password protected PDF files, and they provide two passwords - either xxxx or yyyy. How is this possible?
Not sure if this is how it is done, but it is one way to do it.
Key A is derived from the first password, and key B is derived from the second password. A random key X is encrypted twice, once with key A and once with key B. Both are stored. The PDF is encrypted with key X.
When the user enters a password, it derives a key from it and tries to decrypt both verisons of X with it. Once X is known, it can be used to decrypt the entire PDF.