assume i have:
One-key cipher: E.
Hash: H
My application is authentication. I have a shared secret key with Bob for the One-key cipher.
So, when I send an message to Bob, I also send an authentication code. It is over an insecure channel, so I may have man-in-the-middle attack, etc.
I wonder if below schemes for authentication code are safe or have special weakness.
- M and H(E(M))
I apply one-key-encryption to the message and then hash it.
any problem with this scheme?
- M and E(H(M))
I hash the message then apply one-key-encryption to the hash value.
in this scheme, the attacker may change M and H(M), but without knowing the secret key, no way for him to generate E?
(they key point is not to argue that E can be an insecure scheme. the question here is, over an insecure channel, if E is secured by a shared secret and H is collision resistant, is that any difference to H(E(M)) and E(H(M))? any comparative advantage or disadvantage to these two schemes.. appreciated for advice)
it seems to me both schemes are same and fine, but I am not sure..