I am wondering if using Skein or the Keccak hash algorithm in this construction (as a stream cipher) is secure:
- $H$ = Keccak or Skein hash with a 256 bit output
- $K$ = The main 256 bit random key, pre-shared between sender and receiver
- $K_M$ = A secondary 256 bit random key for creating the MAC, pre-shared between sender and receiver
- $IV$ = A per message 256 bit random initialization vector, sent in the clear with the ciphertext and MAC
- $i$ = counter starting at 0 for each message which increments by 1 every 256 bit block
- $K_i$ = 256 bit block of the generated key for encrypting the corresponding 256 bit block of the plaintext $P_i$
- $P_i$ = 256 bit block of the plaintext. The final plaintext block would be padded to the right with 0 bits, thus the final concatenated plaintext is a multiple of 256 bits and disguises the true plaintext length.
- $C_i$ = 256 bit block of ciphertext
- $|$ = concatenation
- ⊕ = XOR
- $K_i$ = $H$($K$ | $IV$ | $i$)
- $C_i$ = $K_i$ ⊕ $P_i$
- $H$($K_M$ | $IV$ | $C_i$ ... $C_n$)
I hope I explained that clearly.
My other question: Is there a particular attack on using the same key for encryption and MAC?