I have message (m), and I want to store some data to verify its integrity after sending it by an insecure way..
I can create a digital signature (DSA / RSA).
- S(m) = digital signature of m.
Or I can calculate a digest (hash) and cipher it.
- H(m) = digest of m
- C( H(m) ) = ciphered data of H(m)
In any case, when the receiver gets the message should verify its integrity.
What method is more secure S(m) or C( H(m) )?
UPDATE
Suppose Alice want to send a message to Bob
Using digital signature:
Alice's part:
- Compute S(m) using her private key
- Send m, S(m) and her public key to Bob
Bob's part:
- Bob receive S(m), m and Alice's public key
- Bob verify the S(m) using m and Alice's key.
Using digest:
Alice's part:
- compute C( H(m) ) using Bob's public key
- send C( H(m) ) and m to Bob
Bob's part:
- decipher C( H(m) ) using his private key (d)
- compute H(m)
- verify integrity of m ( H(m) = d )
I saw a software using the second method I posted, but I think the first one is more secure, am I right?
UPDATE 2
In conclusion, the best way is to use the first method sharing Alice's public key with Bob using a secure way.
The second method provide not security at all.
Thanks to @Perseids