I'm studying mechanisms of integrity and authentication in symmetric encryption scenarios. I want to propose some examples to see whether I got the point here:
Let $m$ be the message, $c$ the ciphertext, $h$ the hashed message and $t$ the tag resulting of applying MAC.
Example 1:
Here Alice wants to send an enciphered message to Bob providing authentication and integrity but without using hash functions. Both parties agree on two different keys, $k_{1}$ and $k_{2}$. Alice applies $c=Enc_{k_{1}}(m)$ and computes $t=MAC_{k_{2}}(m)$. Then she sends $c$ and $t$ to Bob. Bob applies $m=Dec_{k_{1}}(c)$ and verifies $t'=MAC_{k_{2}}(m)$ comparing it to Alice's $t$.
Example 2:
Now Alice wants to send an enciphered message to Bob but also hashing the message $m$ for computing the MAC (so HMAC comes in). Both parties agree on two different keys (again), $k_{1}$ and $k_{2}$. Alice applies $c=Enc_{k_{1}}(m)$, computes the hash over the message $h=H(m)$ and finally computes $t=MAC_{k_{2}}(h)$. She sends $c$ and $t$ to Bob. Bob now deciphers $m=Dec_{k_{1}}(c)$, computes the hash $h=H(m)$ and verifies the MAC $t'=MAC_{k_{2}}(h)$ comparing it to Alice's $t$.
In case of CBC-MAC, I have read that both parties must agree on a fixed message length, since an attacker could forge a valid MAC. Is this issue solved when using HMAC?
Do you consider these two examples secure? Am I right or mistaken? Specially in the last one, where both parties use hashes with MAC (I have special interest in that one).
Thanks.