6 ms·
> If security is important, the answer to that is no It's a little more nuanced than that. Compression may cause information leaks or it can prevent them depe
by lisper 10y ago
> If security is important, the answer to that is no
It's a little more nuanced than that. Compression may cause information leaks or it can prevent them depending on the circumstances. If you're encrypting an audio stream, then compressing it first can cause leaks. If you're encrypting a document, then compressing it first may prevent leaks.
- IncRnd 10y agoAre you talking about compressing plain text larger than a block, then encrypting per each block of the compressed output?
- lisper 10y agoYes, of course. What would be the alternative?
- IncRnd 10y agoThank you. Your comment wasn’t clear for several reasons. Stream ciphers are regularly blocked in TLS, compression can occur per block. Compression may be done per block, not just against a file larger than a single block.
- witty_username 10y ago@lisper Stream ciphers.
- lisper 10y agoWhy would you use a stream cipher to encrypt a document?
- deleted 10y ago[deleted]
- StavrosK 10y agoWhy wouldn't you?
- lisper 10y agohttp://security.stackexchange.com/questions/334/advantages-and-disadvantages-of-stream-versus-block-ciphers http://security.stackexchange.com/questions/334/advantages-a... Not that this really matters. The advantages/disadvantages of compression are the same in both cases.
- s_tec 10y agoThe AES-GCM mode of operation turns the AES block cipher into a stream cipher. Doing this makes it possible to add authentication on top for relatively cheap. The ChaCha20-poly1305 has a similar construction. These are the two most secure and efficient ciphers available in TLS, so they get a lot of use. If you are sending documents over HTTPS, you definitely want them encrypted with one of these two.
- lisper 10y agoFair enough, I concede the point.
- niftich 10y agoIn GCM, the 'C' is for counter, and hence turning AES into a stream cipher. This part is usually known as 'AES-CTR'. The 'G' is Galois for 'Galois field multiplication', which allows for a parallelizable way of computing a MAC. AES-GCM packages AES-CTR (a stream cipher made from a block cipher) and GMAC (the Galois MAC) together into a primitive. This type of scheme, which combines confidentiality, integrity, and authenticity is called 'authenticated encryption with associated data' (AEAD) [1]. A stream cipher is the easiest way of accomplishing that the cipherstream will safely expand to cover all the plaintext. Other famous AEAD schemes are: - CCM (Counter with CBC-MAC), packages AES-CTR and CBC-MAC together in an authenticate-then-encrypt regime - ChaCha20-Poly1305, which packages together the stream cipher ChaCha20 and the MAC Poly1305. [1] https://en.wikipedia.org/wiki/Authenticated_encryption https://en.wikipedia.org/wiki/Authenticated_encryption
- witty_username 10y ago> If you're encrypting a document, then compressing it first may prevent leaks. I think this is only true if you use a bad encryption algorithm where same plaintext blocks have the same ciphertext.
- lisper 10y agoOh, I'm not talking about leaking plaintext, I'm talking about leaking the length of the document.
- belorn 10y agoCould you elaborate what kind of scenario would work on a audio stream but not on a document? In order to use CRIME, the attacker would need to repeatably injected content before the compression stage in order to test if it matches some part of the source. Audio is kind of heavy uncompressed and aren't normally streamed as such.
- lisper 10y agoA raw audio stream is a constant bit rate stream. If you compress it, it becomes (in general) a variable bit rate stream. The bit rate contains information about the raw audio which survives encryption. If you compress a document that simply obscures the size of the original document.
- danbruc 10y agoIf you compress a document that simply obscures the size of the original document. That is not generally true - if you compress AAA and ABC then the compressed version also leaks information about the content exactly like in the case of an audio stream and it reveals more information then the lengths of the uncompressed documents which don't differ.
- lisper 10y agoYes, you can concoct theoretical cases where compressing documents leaks information. But there's a huge difference: compressing a document only leaks a single data point whereas compressing a stream produces a continual information leak. Furthermore, there are common use cases (with audio being the poster child) where compression leaks in streams can be used in practical attacks. I'm not aware of even a single case of a compression leak being used in a real attack on an encrypted document.
- AlyssaRowan 10y agoImagine a voice call, using a variable-bitrate codec, broken into small packets (not necessarily over the internet), of interest to a passive eavesdropper who cannot decrypt the content, but can observe metadata: the timing of packets and their sizes. Feed that information into a prebuilt phoneme-in-context model trained on that codec and language, and said eavesdropper could probably reconstruct a pretty good estimated transcript - different phonemes compress differently. There is no reason this would not work in bulk: I am under the impression GCHQ have done a fair amount of research in this area, for example.
- fleitz 10y agoIt's more about whether the attacker has control of the any portion of the compressed contents. If they have control over the stream then you don't want compression, if they don't you do.
- lisper 10y agoNo, control is not necessary for compression to leak information. It's enough for the attacker simply to know something about the original stream content (e.g. that it is audio) and how it compresses.
- jrockway 10y agoI think compression is a read herring here. Think about keyboard-interactive ssh authentication. Whether or not the data is compressed, the timing of the packets depends on the timing between when you pressed the keys on your keyboard. Thus information is leaked, and compression was not involved. Therefore, I feel like compression complicates the discussion unnecessarily. Information that's not encrypted (the time a key was typed or the spacing between phonemes in a word) can be recovered by an attacker without breaking the encryption. Obvious when you say it like that ;)
- lisper 10y agoWell, yeah, but the point is that compression can cause the leakage of information through timing that would not otherwise have leaked.
- DougBTX 10y agoYes, in other words compression can move information from the content of the data (which is encrypted) to the size of the data (which is not encrypted).
- hinkley 10y agoWhich is one of the selling points of block cyphers. They may not conceal the magnitude of the payload but they do obscure the exact byte count by rounding up. But that probably doesn't stop CRIME from being workable.
- angry_octet 10y agoHmm, I don't think it is really a selling point. A block cipher also implies needing a technique like CBC to prevent watermarking, and using CBC actually helps with oracle attacks. An interesting paper on using padding to obscure length: http://cihangir.forgottenlance.com/papers/lengthhiding-corrected.pdf http://cihangir.forgottenlance.com/papers/lengthhiding-corre...
- admax88q 10y agoYou can't compress after encryption. Encrypted content should be indistinguishable from random data. So encrypt than compress shouldn't be able to yield any reasonable compression.
- deleted 10y ago[deleted]
- choosername 10y agowit truly random data, patterns should randomly appear.
- gameofdrones 10y agohttps://en.wikipedia.org/wiki/Entropy_(information_theory) https://en.wikipedia.org/wiki/Entropy_(information_theory)
- choosername 10y agoI'm sorry, that article is far too long to tell me what you are trying to say. All I can gather is, I was wrong
- LeoPanthera 10y agotl;dr Random data may appear to have patterns, but those patterns do not repeat, so they cannot be compressed.
- angry_octet 10y agoAh, but they can repeat! There is a finite chance that any sequence of any length will occur in a random sequence. So while a compression alg applied to a very large amount of random data is unlikely to reduce the size, it is quite possible to achieve some compression on smaller blocks.
- labianchin 10y agoInteresting. Keepass[0] (password store) compress with GZip by default before encryption. [0] http://keepass.info/help/v2/dbsettings.html#compression http://keepass.info/help/v2/dbsettings.html#compression