I have a signed PDF. It was signed using TCPDF. Now I want to check it out. This is my decision:
- Get signed pdf content.
- Get the original contents and base of the character values ββin the / ByRange field.
- Get the encrypted digest message from the signature value. This is the octet string at the end of the signature value.
- Use the Openssl_public_decrypt () function to decrypt the encrypted digest message using the public key. Then we have a line that has a prefix ("3021300906052b0e03021a05000414"). This prefix denotes the SHA-1 hash function used. After removing the prefix, we get the digest message D1.
- Use the SHA1 () function for the original contents of the hash, we get a D2 message for digests.
- Compare D1 with D2. If D1 = D2, then the signature is valid and vice versa.
My problem is the last step, when I compare D1 with D2, they are not equal. I do not know why. Thanks for any help.
source
share