I have a quick question regarding parameters for HSM based symmetric Key Derivation.
My situation is that I have to implement HSM based symmetric key derivation for encryption of sensitive data to be stored inside DB. Each data entry should have distinct AES-256 key used only for that records encryption. There are two cases:
- Users ID has to be encrypted with unique Key per user, so that it would be possible to search by this User ID. My idea was to use ID itself (known at the time) as a parameter to KDF to get predictable encryption key, and use it to encrypt and perform search (
KEYhsm + IDuser -> KEYaes
). I do not see how this differs from hashing, but requirements states that encryption should be used. Should I hash this ID before using it as a parameter? - Second case is as stated before, that each record should use distinct Key for encryption. For this my idea was to use record GUID (stored next to encrypted data) as a parameter to KDF to generate symmetric Key (
KEYhsm + IDresource -> KEYaes
). Again, should I hash it, is this approach secure enough?
It would be really helpful if somebody smarter that me would review my approach and maybe give some hints for algorithms to use (HASH, KDF). I do not know HSM model and maker at the time, but my assumption is that this HSM will be able to use secure private key to generate symmetric AES-256 encryption keys.