The Java Secure Socket Extension Reference Guide (http://
docs.oracle.com/javase/6/docs/technotes/guides/security/jsse/
JSSERefGuide.html) says this about HMAC:
"If Alice wants to be sure that Charlie does not tamper with her
message to Bob, she can calculate an HMAC for her message and append
the HMAC to her original message. She can then encrypt the message
plus the HMAC using a secret key she shares with Bob. When Bob
decrypts the message and calculates the HMAC, he will be able to tell
if the message was modified in transit. With SSL, an HMAC is used with
the transmission of secure data."
Suppose that Alice doesn't care whether Charlie can read her message
to Bob; she cares only that Charlie can't tamper with it. In that
case, is is necessary for Alice to encrypt the message (plus the
HMAC), or could she send the plaintext of the message plus the HMAC?
If it's necessary for Alice to encrypt the message plus HMAC, is it
necessary that the encryption key be different than the one used to
compute the HMAC?