Just as a preface: I'm not implementing a HMAC - I just want to understand it, as it is part of of my *Computer Science* course.

When using Hash-based message authentication codes, I understand that you need to protect the front and back of the MAC to prevent an adversary from modifying the HMAC while in transit.

    HMAC (K,m) = H((K ⊕ opad) ∥ H((K ⊕ ipad) ∥ m))

As such, a HMAC is constructed by hashing the XOR of the secret key `K` with the outer padding `opad` concatentated with the hash of the secret key `K` XORed with the inner padding `ipad` concatenated with the message.

Can someone explain how these “secret keys XORed with padding” protect the HMAC from modification by an adversary (such as appending data to the end of the MAC)?