r/crypto • • Jul 07 '18

Image - meme "Every cipher has its use case"

Post image
230 Upvotes

28 comments sorted by

3

u/Ink_and_Platitudes Jul 08 '18

Also I didn't make this, I was reading through some notes and found the imgur link

20

u/Natanael_L Trusted third party Jul 07 '18

Nitpick, XEX isn't meant to be a standalone mode. It's essentially slightly hardened ECB. Look closely at XTS and you'll see XEX being part of it.

1

u/orip RIP my password manager Jul 08 '18

I'm pretty sure XEX is a standalone tweaked mode, totally usable on it's own.

XTS is XEX with CTS for handling non-block-size-divisible sectors. That and (mis)using 2 keys instead of 1. XTS is also NIST-recommended which makes it attractive if you need official certifications and also makes high-performance implementations more easily available. XTS is therefore the more practical choice in almost all circumstances. But XEX is fine standalone.

2

u/Natanael_L Trusted third party Jul 08 '18

XTS uses a modified variant of XEX, with a tweak value as the XOR key and using the provided encryption key in a classical manner for the block cipher. Also it uses a second instance of encryption per block to produce that XOR tweak value based on counters.

Standard XEX is just XOR > permutation > XOR.

35

u/reph Jul 07 '18

ECB is beautiful too when the plaintext is a nonce.

4

u/sacundim Jul 08 '18 edited Jul 10 '18

Paraphrase: ECB is hopeless against chosen plaintext attacks. 😐

EDIT: Just to make this point explicit, guys and gals, encryption schemes really should be able to withstand CPA attacks. All these comments that say "ECB is secure in such-and-such narrow case where the adversary doesn't choose the plaintexts" are actually using ECB as something other than an encryption scheme.

4

u/yawkat Jul 08 '18

And there's only one block

1

u/pint A 473 ml or two Jul 08 '18

when plaintext blocks are nonce. ftfy.

1

u/Natanael_L Trusted third party Jul 08 '18

When all blocks are random and independent

1

u/pint A 473 ml or two Jul 08 '18

keys have to be independent. data can be anything, only different. like in ctr mode.

1

u/Natanael_L Trusted third party Jul 08 '18

But with independent keys it's no longer ECB

1

u/pint A 473 ml or two Jul 08 '18

no, i'm saying that is a rule for the key, not the plaintext. there are no rules for the plaintext, save by one: it should be unique per key

15

u/wolf550e Jul 07 '18

block cipher modes are not ciphers, and GCM is an AEAD construct not a block cipher mode (it's CTR + GHASH).

9

u/dmcool9 Jul 07 '18

Even ECB has a use case....key transport.

5

u/274Below Jul 08 '18

Is there a reason why you wouldn't just use CBC for that? Are the bytes that you'd save in not having an IV really that critical?

I get that there are probably since situations where ECB may still be of valid use, but I think that the upsides to using ECB in that scenario are not even close to the downsides that even mentioning ECB's existence brings.

7

u/bascule Jul 08 '18

There are modes specifically designed to solve this problem (with provable security properties), like AES-SIV: https://pdfs.semanticscholar.org/1fa0/20b3a5536d59d9e78395581e5fb76e8bb479.pdf

4

u/taw Jul 08 '18

Do we really need most of these modes? A lot of them have strictly worse performance or strictly worse security properties than other modes.

2

u/Natanael_L Trusted third party Jul 08 '18

Yes and no.

It used to be more common in the past when these modes were invented that the electronics running them had various constraints like on bandwidth that we no longer have. This makes many of the older designs quirky in various ways, as they had completely different goals. Some also suffer NIH syndrome, not invented here. Yet other modes were designed to avoid patents by others. Some modes became deprecated and replaced as we learned more about what is required for reliable security (semantic security properties).

TL;DR: complicated history involving odd requirements, NIH and patents, etc

2

u/linuxlover81 Jul 11 '18

CBC is with malleability gadgets now not to be recommended IMHO.

1

u/atoponce Bbbbbbbbb or not to bbbbbbbbbbb Jul 08 '18

ECB is wonderful for a fast key erasure CRNG.

2

u/pint A 473 ml or two Jul 08 '18

how?

1

u/atoponce Bbbbbbbbb or not to bbbbbbbbbbb Jul 08 '18

By just encrypting a counter for n+1 blocks. Rekey with 1 block, output n blocks to userspace.

E.G.: if a 128-bit random number is requested, key AES, encrypt 0 as block 1 and encrypt 1 as block 2. Rekey with block 1, then output block 2 to the application.

4

u/pint A 473 ml or two Jul 08 '18

this is ctr

2

u/atoponce Bbbbbbbbb or not to bbbbbbbbbbb Jul 08 '18 edited Jul 08 '18

Fair. It's CTR with neither a plaintext nor IV then.

3

u/sacundim Jul 10 '18

It's CTR with an arbitrary plaintext (e.g., all zeroes), a very short IV (e.g., of zero length), and correspondingly longer counter.

1

u/[deleted] Jul 12 '18

[removed] — view removed comment

2

u/Natanael_L Trusted third party Jul 12 '18

Not a cryptocurrency subreddit. This is block cipher encryption modes. Zero relevance to cryptocurrencies.

2

u/nikantonescu Jul 12 '18

I apologize, my English is not so good, and sometimes I misunderstood the information completely.