I need to generate some session keys from a master key that was generated from an ECDH key exchange. The master key is 256 bits and I need 256 bit sessions keys.
Is it safe to use SHA256_HMAC with a counter as the HMAC input to get the session keys?
skey1 = SHA256_HMAC(master_key, 1);
skey2 = SHA256_HMAC(master_key, 2);
skeyN = SHA256_HMAC(master_key, N);
The counter is meaningful to the application to know which session key to use. I have also looked at Hashed Key Derivation Functions (HKDF) but it seems like that is more useful when you need a long random output from a given input. My output length is the same as the input length and I need to be able to generate the correct session key based on a counter value (might not be sequential calls). The counter is essentially an id.