The title says it all really...let's say I have a packet of data that one of my applications needs to store encrypted with a public key (RSA, say, with the private key kept elsewhere). Let's say the application also then needs a way of determining if said packet has already been stored, so I combine it with a randomly generated salt and save the hash of packet+salt so I can check it later (e.g. MD5). Does storing the combination of these three pieces of data...i.e. encrypted packet, the salt and the hash....result in data that is significantly less secure than the encrypted packet alone?

I realize "significantly less secure" is an arbitrary metric. I'm not after anything military grade (for want of a better nonsensical term), I just want to make sure I'm not doing anything overtly silly.


1 Answer 1


The hashing does not compromise security in any way. Assuming you're calculating hash(ciphertext+salt), the hash provides no new information that an attacker with access to your ciphertexts doesn't already have.

A secure hash like SHA-3 is a one-way function, safe even on a salted plaintext, and the outputs of such are stored in authenticated encryption. You can actually strengthen your system by using a HMAC rather than just a hash and incorporating an authentication mechanism.

As for whether the whole system is secure, it depends on what you're storing.

Checking if the packet has been stored is likely to create an oracle for a side channel attack. If the attacker can send packets to encrypt and your response or its timing is in any way different for duplicates, they can verify if a certain file of interest or a certain password is being stored in your system.

Whether it's effective depends on the search space for the plaintext. If it's small, e.g. passwords, or files people don't want to be known to possess, that's a vulnerability. Deduplication is generally at odds with security, and creating secure deduplication is a current challenge.

N.B. I've addressed only security, not utility above. Keep in mind that you can only compare hashes with the same salt, so this scheme may have limited effectiveness for deduplication.

  • $\begingroup$ Thanks Therac. My main concern was that storing the packet with both RSA and a salted hash would create some type of mathematical vulnerability that would be easier to crack than storing just the RSA or hash alone. If I'm understanding your reply correctly, that's not where an attack vector would likely be from and I should concentrate on secure implementations of the algorithms I do choose? $\endgroup$ Apr 13, 2018 at 20:59
  • 1
    $\begingroup$ Yes, a secure hash (SHA) and crypto don't compromise the plaintext. The most discussed vector of attack in such cases is side channel verification of plaintext guesses. $\endgroup$
    – Therac
    Apr 13, 2018 at 21:23

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.