9

In a system where personal information stored in a database is encrypted, but one of the fields only contains data in a minority of cases, would it make more sense to leave the field empty, rather than encrypting an empty string?

On one hand if I choose to leave the field empty, I would be leaking information about the contents of the record (populated or not)

On the other hand, if I encrypt the empty field, most of the time I am giving a potential attacker a known plaintext.

The algorithm being used is AES-256.

I'm aware that an attacker would still have to brute force the key even if they obtained a ciphertext/plaintext pair, however I'm curious what the community feels the best practice approach would be here.

7
  • 2
    Two words: IV.
    – TildalWave
    Jun 10, 2013 at 9:24
  • 1
    @TildalWave Your comment is not helpful with regard to the question being asked. An IV is being used. Encryption is done in CBC mode.
    – Leigh
    Jun 10, 2013 at 9:37
  • 3
    I meant unique and non-predictable IV per each encrypted record. This will produce different ciphertext for each of your empty plaintexts and solve your problem of relaying the information of which field is empty and which not even if you used encryption (but same key + IV) on all records. IV does not necessarily have to be a secret, as long as it's unique and non-predictable (i.e. random, at least to the would-be attacker) ;)
    – TildalWave
    Jun 10, 2013 at 9:39
  • 4
    You realize how much new information that's relevant to your question I've just dug out of you in these comments? Changing both the nature of the question and of a possible answer? CBC mode, per field random IV. And why go the long way around of asking a theoretical question? I now wonder, is there's any more, or can start answering?
    – TildalWave
    Jun 10, 2013 at 11:08
  • 3
    "On the other hand, if I encrypt the empty field, most of the time I am giving a potential attacker a known plaintext." Not, if you care to read the difference in what I said before, and what you said how you're currently doing it. You understand the difference between a field and a record, I presume? And the difference between random and unique? How would the attacker know which record is empty (and with it a known plaintext) for that field in question, if it's using unique IV per each record (not field!)? And let's assume I still don't get it, did @Adnan fail to get it too?
    – TildalWave
    Jun 10, 2013 at 11:44

2 Answers 2

7

Since only a minority of the records might contain actual data in that field (non-empty), an attacker can guess the plaintext (the empty ones) with a high probability. So your assumption is correct. Luckily, for you and for us, as far as we know, AES isn't really susceptible to known-plaintext attacks.

The attacks we already know about require large amounts of plaintext and their corresponding ciphertext, and have very high computational complexity (2254.4 for a 256-bit key).

I'd say don't worry about it. Go with encrypting that data field.

0
3

I suggest you try to salt your data (any form of varying salt). That way even an empty field has "data" and will be a random blob once encrypted.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .