# Would a non-deterministic (read: randomized) compression algorithm be crypto-safe?

Would a compression algorithm that randomly shifts stuff around every iteration be TLS/crypto-safe?

This randomization would prevent the same byte sequence from appearing twice in a row, thus making it harder to figure out the key and stuff. Altho I don't have any crypto knowledge...

Note that it would only apply to the compression step. The decompression step would always produce the same output when given the same input.

• How would the decompression step reverse the randomness? Do you have to pass the randomness from the compressor to the decompresser in a way that the attacker can see? – Mike Ounsworth Mar 11 '16 at 13:47
• I honestly think that designing the compression algorithm so it concentrates only on compressing data will be more beneficial, and if You want crypto-safe just use any already proven PRGs from any known stream cipher and just xor the compressed data with pseudorandom sequence. – Filip Franik Mar 11 '16 at 13:51
• @FilipFranik so now the PRNG's seed is a private key, you've just invented a cipher. How do you securely get that private key to the decryptor / decompressor? – Mike Ounsworth Mar 11 '16 at 14:08
• @MikeOunsworth the same "unmentioned" way SoniEx2 was planning to deliver it in hes/hers original design. Most probably using human readable password passed through KDF. – Filip Franik Mar 11 '16 at 14:14
• What means "crypto-safe" for you? – Paŭlo Ebermann Mar 11 '16 at 14:56

This is starting to sound more and more like you're reinventing SSL / TLS, so why not compress your file and then encrypt / send it using a stock TLS library like openssl?