Share encrypted files without giving master key Imagine I have four files I want to encrypt. I have master key, and from that master key I derive four keys, one for each file: 

key1 = HMAC-SHA-2(masterKey, filename1)
key2 = HMAC-SHA-2(masterKey, filename2)
key3 = HMAC-SHA-2(masterKey, filename3)
key4 = HMAC-SHA-2(masterKey, filename4)


After that, I encrypt each file with AES, each with its own derived key (file1 encrypted with key 1, file2 encrypted with key2, etc).

Imagine Alice (owner of the master key) publishes every encrypted file publicly and only shares key3 with Bob. 


Is it then safe to assume that Bob will only be able to decrypt file
three because he only has key3, and no one else will be able to
encrypt the other files (except Alice)?
Is Bob able to decrypt the other files, when he knows that his key
was made by using HMAC-SHA-2(masterKey, filename3), even though he
doesn't have the keys for the other files?
If all four keys are handed out to one person (and that person also
knows the four filenames) , is that person then able to derive the
master key?
Yes, it's safe, as you can't calculate the secret key from the HMAC result. HMAC would be useless without this feature
No, Bob will not be able to use his key to calculate the other keys, as long as you use a  reasonable hash function (SHA-2 should fit)
It's the same as 1., Bob doesn't get more information by more derived keys


But when Bob get the key for filename2 and Carlos for filename3, then it's important that Bob nor Carlos are able to affect the filenames.
Otherwise they could create a key for a encrypted file related to another person