this post was submitted on 10 Aug 2023
538 points (97.9% liked)

Programmer Humor

19187 readers
1309 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 10 points 1 year ago* (last edited 1 year ago) (9 children)

Don't compress encrypted data since it opens you up to attacks like CRIME, unless it's at rest and static data.

[–] [email protected] 15 points 1 year ago (6 children)

If that's true, what's to stop someone else from just compressing it themself and opening the same attack vector?

[–] harbor9964 5 points 1 year ago (1 children)

Compressing what themselves? Compress then encrypt leaks information about the data being encrypted if an adversary can affect some part of the data being encrypted. If the data is at rest and repeated encryptions are needed , then this isn't a concern.

[–] [email protected] 13 points 1 year ago (1 children)

Compress the encrypted data. You're talking about encrypting compressed data, this was talking about compressing encrypted data.

[–] [email protected] 2 points 1 year ago (1 children)

Technically you would be fine to compress the encrypted data, but encrypted data doesn't compress well so it's not really worth your time

[–] [email protected] 1 points 1 year ago (1 children)

Depends on if you're using lossless or lossy compression. Lossless compression will usually make it bigger, because it relies entirely on data being formatted so their are common patterns or elements that can be described with fewer parts. Like, an ok compression algorithm for a book written in English and stored as Unicode would be to convert it to ASCII and have a thing that will denote Unicode if there happens to be anything that can't convert. An encrypted version of that book would look indestinguishable from random characters, so compressing it at that point would just put that Unicode denoter before every single character, making the book end up taking more space.

[–] [email protected] 1 points 1 year ago (1 children)

The problem is that when you compress before you encrypt, the file size becomes a source of data about the contents. If an attacker has control of part of the data - say - a query string, they can use that to repeatedly add things to your data and see how the size changes as a result.

[–] [email protected] 1 points 1 year ago

So it sounds like compression before encryption should only be done in specific circumstances because it can be a security issue depending on use case, but encryption before compression should never be done because it will almost always increase the size of the file

load more comments (4 replies)
load more comments (6 replies)