2
$\begingroup$

Let's say I have a list of several million numbers, with only 6-9 digits of secret information per number (this means that an attacker might efficiently guess the other digits). I have to store the list in an unreadable format and when given a new number I want to efficiently know if I have the number in my list or not.

For this purpose I store the HMAC – SHA 256 of my numbers, using the same secret key to generate all the hashes. When given a new number I use the secret key to compute its HMAC - SHA 256 and perform a lookup in my list.

I am also storing the same numbers encrypted with another key in AES CBC mode, but this field is not useful for searching because of the random IVs.

Is this secure, cryptographically speaking? Will it prevent attacks to "open" the hashes, assuming the secret key remains unknown to an attacker?

$\endgroup$
1
  • $\begingroup$ I'm definitely no expert here, but couldn't a stream cipher encrypted data be used instead of both (storing the data twice makes no sense to me)? $\endgroup$
    – maaartinus
    Commented Jan 16, 2014 at 15:03

1 Answer 1

2
$\begingroup$

As long as the key is secret, your list of MACs is safe and the numbers are not guessable.

You probably can truncate your MACs to 80 bits in order to save space, as collisions are highly unlikely for $2^{23}$ entries or so.

If your numbers do not repeat and fit into 128 bits, the simple Electronic Codebook (ECB) mode with AES should also do a good job, you just store the ciphertexts encrypted on the same key.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.