Well, possibly I might be overthinking but it would be really great if my query is answered.
Let's assume Alice is sending a digitally signed document to Bob over an unencrypted channel. The message is "YES".
What if a MITM, let's assume she is also named Alice intercepts the message, strips the digital signature of the original Alice, alter the content from "YES" to "NO" and signs the message with her own Private Key thereby sending her Public Key to Bob.
This way a new message digest can be created which will further encrypted with Duplicate Alice's private key along with the Hash Algorithm. Further she signs the message which contains Duplicate Alice's public key and Encrypted Hash.
Is the above hypothesis possible?
Digital signature is validated against some public key. Typically such public keys are extracted from certificates, either attached to a message or obtained through other channels. Whichever way, the recipient must check that the certificate corresponds to the originator of the message.
In the case of secure mail (S/MIME) the e-mail of the originator must be in the distinguished name or subjectAltName
field of the certificate. If an email from [email protected]
is intercepted and altered by [email protected]
, Bob will either reject the digital signature - in the case when Alice2 alters the message but keeps the original certificate - or rejects the certificate, since the mail address in From
field doesn't match the certificate DN/subjectAltName
Sure thing, the certificate of [email protected]
shouldn't be self-signed, otherwise Alice2 can create a new certificate with the name [email protected]
and properly sign the altered document.
Concerning your question about PDF documents - Adobe supports PKI (Public Key Infrastructure). If your certificate is issued by a government-trusted Certification Authority, then they don't need your public key beforehand. They will extract the certificate from the signature dictionary, compare certificate's DN with the name of the document creator/signer/updater and check the chain of trust. If the certificate matches your name (as saved in the PDF document) and it is signed by the trusted CA, then they will trust your signature.