News for hackers. Stuff that matters.
Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @11:52AM (#9375142)
This is a common idea and it's flawed.

Let KC be a well-known and implemented cipher and CC a custom cipher written by you. Instead of communicating like this:

A -> KC-encrypt -> transport -> KC-decrypt -> B

You can use:

A -> KC-encrypt -> CC-encrypt -> transport -> CC-decrypt -> KC-decrpyt -> B

The advantage is it breaks automated cryptoanalysis in case KC is broken.

A better idea than the one you stated is: don't rely solely on custom cryptography.

Re:The Cryptographic Doom Principle by stouset on Tuesday April 14, 2015 @12:44PM (#9375531)
Technically, you're correct. In the real world, you're not.

This mythical protocol just encrypts a blob and sends it over the wire. But real protocols involving cryptography are significantly more complicated, because they often need to authenticate other parties, cryptographically bind all the messages in a session, preserve forward secrecy, preserve anonymity of one of the communicating parties, etc.

Now the problem isn't that you are simply applying your own cipher to the output of a strong cipher. It's that you've now got to implement a damn protocol, because nothing in the world supports your cipher. And that implementation is inevitably going to have more exploitable flaws than a well-maintained open-source project that doesn't implement your bogocipher.

Cryptography is hard, and it's not just the primitives that are ripe for gotchas. Combining primitives, implementing primitives, designing protocols, implementing protocols, and generally anything involving touching something anywhere in the entire stack is fraught with danger. As a rule, the more crypto-related lines of code you write, the more likely it is you have introduced weaknesses rather than added strength.

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @12:51PM (#9375577)
Technically correct is the best way of correct.

I never suggested my proposal for public protocols for communication between two random parties. I first and all wanted to show the root of this thread wrong.

I'd suggest it maybe for highly confidential communication that warrants the trouble.

Re:The Cryptographic Doom Principle by stouset on Tuesday April 14, 2015 @01:59PM (#9376112)
Technically correct is usually the least useful kind of correct.

The root of this thread is extremely sound advice. Don't touch your own crypto unless you're an expert. If you're at the point where your security requirements are so sensitive that you can't possibly risk a break in an underlying well-known cipher, you should hire a real cryptographer and not dick around with inventing your own laughably-broken ciphers.

And once you have that cryptographer under your employ, you can feel free to break the rule of not rolling your own crypto. Although that cryptographer is infinitely more likely to simply compose well-known strong ciphers over deploying their own unpublished ones.

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @02:27PM (#9376296)
So I think it comes down to whether the root

> I think there's a more fundamental cryptographic principle. Don't implement cryptography, unless you are an absolute top expert.

is a sound advice.

I disagree with this advice strongly. Tinkering around with cryptography can teach you a lot. Especially if you are not a top expert.

Furthermore, I described a relatively simple protocol that monotonically increases the security of a communication by applying a custom cipher. I didn't add the restrictions that CC must not know anything about KC anything because I though that would be clear.

Interestingly, you get security through obscurity on top of the previous security from my scheme even when CC is trivial like swapping the nibbles in bytes and then xoring a constant. This makes untargeted mass-surveillance in case of broken KC a lot harder. Depending on the CC it's relatively easy to make it totally impractical.

I think my scheme is interesting because it's unintuitive that it adds any security.

Re:The Cryptographic Doom Principle by stouset on Tuesday April 14, 2015 @04:32PM (#9377118)
Nobody is arguing against tinkering with cryptography as a mechanism for learning. This advice is meant to stop people from writing homebrew encryption for real-world, production systems.

You described a relatively simple protocol that, at worst, does not decrease security in a theoretical sense with at least one critically-important and unmentioned caveat (don't use the same or related keys for both ciphers). In a practical sense, your simple protocol is likely a security disaster.

In the absolute best case, it really only defends against a break in the underlying cipher that is so thoroughly devastating that ciphertexts can be decrypted essentially for free. Even DES hasn't been broken this badly, and it's been considered broken for decades. The reason this is the case is that such a simple transform is only useful against an entity that is automatically decrypting ciphertexts on the wire en masse, and who isn't looking for your data specifically. Against a targeted adversary who can "merely" break AES with substantial effort, the additional cost such a transform would impose is completely negligible. In your example of a transform on top of a TLS connection, it would be completely obvious through packet analysis that the protocol was TLS, and your transform would be trivially understood and reversed after watching a few handshakes.

Re:The Cryptographic Doom Principle by bandrami on Tuesday April 14, 2015 @11:32PM (#9378761)
I described a relatively simple protocol that monotonically increases the security of a communication

Careful. Encryption is decryption, remember. Do any of the rounds of CC undo any of the rounds of KC? Can you verify that bits that were correlated in PT and uncorrelated in KC are still uncorrelated in KC + CC? Does CC change the entropy content of the resulting message? (If it decreases it you have a problem, and most popular ciphers end up with damn near 8 bits per byte in the ciphertext.)

Re:The Cryptographic Doom Principle by madez on Wednesday April 15, 2015 @02:57PM (#9383283)
By definition, if CC doesn't know the key and doesn't search to key space of KC and it reduces the security of KC then CC breaks KC.
Re:The Cryptographic Doom Principle by jxcl on Tuesday April 14, 2015 @12:03PM (#9375212)
That makes sense intuitively, but you can't approach cryptography intuitively. There are many cases where the intuitive answer is "well, the worst case is that it's just as good as without our custom wrapper... so let's do it." But under cryptographic analysis it is revealed that the custom wrapper renders whatever other good, accepted cryptography that is in play completely useless.
Re:The Cryptographic Doom Principle by dustyleary on Tuesday April 14, 2015 @12:16PM (#9375310)
I need to see a citation for this. Something like the parent article exposing how things get mistakenly broken by applying this concept.

It's important to be paranoid about implementing your own crypto, true. But it's not good to take this to dogmatic extremes, ie "never trust any code you write that has crypto in the name or you break everything".

I would never write and deploy a custom cypher. But if I did, and my custom cipher CC, when applied to ciphertext encrypted by AES, somehow leaked any information about the plaintext, then I have accidentally made a cryptanalysis breakthrough that has thwarted hundreds of professional crypto people.

This is unlikely.

Re:The Cryptographic Doom Principle by stouset on Tuesday April 14, 2015 @01:07PM (#9375702)
In madez's case, his construct is provably secure, with some caveats. Specifically, the first cipher must be a secure cipher, and the keys for both ciphers must be independent. If the latter is not the case, the custom cipher could very easily leak bits of the key, which would allow the original cipher to be broken.

But more importantly, it's the implementation of this construct that's likely to introduce weaknesses. As I posted in my direct reply to him, the problem is that no real world protocol is so simple, and he will now have to implement this. See OpenSSL for what can go wrong when implementing ciphers; and that's a highly-used, generally stable project that's had the benefit of multiple eyeballs for years.

Re:The Cryptographic Doom Principle by rudolf0 on Tuesday April 14, 2015 @02:11PM (#9376196)
Exactly. And if the first cipher is a secure cipher, with no obvious sign it'll be broken any time soon (like AES), why not just use it instead of wrapping it over some homebrew solution?
Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @02:29PM (#9376301)
Because you get obscurity which makes automated cryptoanalysis of your communication a lot harder (if not impossible) which in turn makes untargeted surveillance more expensive.
Re:The Cryptographic Doom Principle by rudolf0 on Tuesday April 14, 2015 @03:37PM (#9376735)
That seems ridiculous for 2 reasons.

First, ciphertext is ciphertext. They'd probably be able to determine it's a block cipher and what the block size is, but that's about it. They're not going to be able to tell AES ciphertext from 3DES ciphertext if they're both set to use the same block size. There's no point "obscuring" the fact that you're using AES.

Second, if you're assuming the NSA seriously has the capability to break AES within the next 10 years, then obscuring it with a homebrew cipher is pointless, because they've probably already used their AES decryption capability to find many other ways into your system (through a hosting provider, ISP, domain registrar, DNS provider, admin accounts of coworkers...).

Even quantum algorithms are only able to halve the bits of the key search space (so 2^256 will become 2^128, which is still mostly infeasible even against a government adversary).

I don't think your suggestion would decrease security, if implemented perfectly (which is unlikely), even if the cipher is insecure and vulnerable to cryptanalysis. But I don't think it would increase security either. And since it wouldn't increase it, yet may decrease it in practice due to an implementation flaw which compromises both ciphers, why bother?

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @04:12PM (#9376946)
> First, ciphertext is ciphertext. They'd probably be able to determine it's a block cipher and what the block size is, but that's about it. They're not going to be able to tell AES ciphertext from 3DES ciphertext if they're both set to use the same block size. There's no point "obscuring" the fact that you're using AES.

If you can break a set of ciphers it's trivial to determine which was used for a connection, if one was used; You just try each.

The whole point is to hide which is the real cipher to make it more costly to attack you. Making it more costly for the attacker is what we want.

> Second, (...)

This is no argument for or against the scheme I presented.

> Even quantum algorithms are only able to halve the bits of the key search space (so 2^256 will become 2^128, which is still mostly infeasible even against a government adversary).

Breaking a cipher means to not have to search all the key space. That's the definition of a broken cipher.

> I don't think your suggestion would decrease security, if implemented perfectly (which is unlikely), even if the cipher is insecure and vulnerable to cryptanalysis. But I don't think it would increase security either. And since it wouldn't increase it, yet may decrease it in practice due to an implementation flaw which compromises both ciphers, why bother?

We disagree on the practicality of implementing it without adding another vulnerability to your system.

Re:The Cryptographic Doom Principle by rudolf0 on Tuesday April 14, 2015 @04:28PM (#9377081)
The plausibility of a vulnerability in AES which reduces the search space by more than half of the key bits is essentially 0.
Re:The Cryptographic Doom Principle by bandrami on Wednesday April 15, 2015 @12:31AM (#9378886)
First, ciphertext is ciphertext. They'd probably be able to determine it's a block cipher and what the block size is, but that's about it.

You can tell mode somewhat reliably (I've hit 75% confidence or so) by the entropy content of the ciphertext, and I've never done a Markov chain longer than a native word so I'd assume that gets better the longer your chain is. I would also assume people much smarter than me have compiled heuristics that are more useful than just determining the mode.

Re:The Cryptographic Doom Principle by frankchn on Wednesday April 15, 2015 @01:10AM (#9378995)
I believe it is considered a significant break in a block cipher if you can distinguish messages encrypted via that cipher against random bits constructed in a similar way (i.e. constructing an adversary such that it has a non-negligible advantage in the PRF security game against the family of functions for the block cipher).
Re:The Cryptographic Doom Principle by bandrami on Tuesday April 14, 2015 @11:36PM (#9378772)
I need to see a citation for this

You're looking at it the wrong way. You need to demonstrate for yourself that nothing in your cipher undoes the last round of the underlying cipher.

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @12:12PM (#9375274)
Rendering KC useless by using CC as I described is equivalent to breaking KC. There is no other way of messing with KC when used the way I said. And you won't break KC by chance with your CC. Many people respond like you did and they simply didn't think about what I've said and repeat old ideas.

I hate people.

Re:The Cryptographic Doom Principle by sirclueless on Tuesday April 14, 2015 @12:28PM (#9375401)
This is not a true statement. CC may leak information about the plaintext in ways that KC can't handle, even without breaking it. For example, applying CC might deterministically affect the message length.

One of my favorite cryptographic attacks ever was of this form, known as the CRIME attack [1]. It was a "partial plaintext" attack, where the "CC" in question was plain old gzip. Basically the attackers controlled a small part of the plaintext (for example, a field in an HTTPS request they could send with CSRF) and they were able to use known properties of the CC to get some information to leak into the message length -- namely, if the message fragment they controlled appeared elsewhere in the request, the gzip encoding would be shorter, and hence the encrypted request would be shorter. This is something that happens even with a "perfect" KC that no one could break.

[1]: http://en.wikipedia.org/wiki/CRIME

This is one of the defining characteristics of cryptography to me -- there are no perfect cyphers, there are only good systems. Littering extra cryptography around nearly always decreases security. The most secure system is the simplest system that works.

Re:The Cryptographic Doom Principle by dustyleary on Tuesday April 14, 2015 @12:45PM (#9375539)
What you (and the wiki link) are describing is plaintext -> CC (gzip) -> KC.

This is different than the argument you're replying to which is plaintext -> KC -> CC.

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @12:40PM (#9375489)
Read this thread again. Your statement is not correct since CC never gets to see the plaintext. CC is just a bijective function on (blocksize of KC) bits.
Re:The Cryptographic Doom Principle by sirclueless on Tuesday April 14, 2015 @12:49PM (#9375568)
Did you edit your post? I'm not the only one who misread it. If KC is applied first to the plaintext, then assuming you didn't flub anything in implementation the combined scheme won't be less secure than KC, I agree. Applying CC effectively becomes security through obscurity, which is admittedly sometimes helpful.
Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @01:17PM (#9375757)
No, sirclueless, I didn't change the scheme I wrote about.

Yes, it adds security through obscurity without losing security through well-known recommended ciphers.

Re:The Cryptographic Doom Principle by stouset on Tuesday April 14, 2015 @02:04PM (#9376139)
If you use the same key for KC and CC, CC can (and hell, in all likelihood probably does) leak bits of the key.

So yes, there is a way of breaking this construct when used the way you said.

Re:The Cryptographic Doom Principle by kelson on Tuesday April 14, 2015 @12:12PM (#9375278)
This is almost always less secure than KC alone, when KC is a well-known secure cipher.

A simple example would be a CC that hex-encodes the plaintext before applying some transformation on the data (before you laugh, this exists in enterprise systems today). This means CC would effectively expand the underlying data 200% (0xA1 -> 0x4131) and substantially degrade the security of a block-based cipher (32-bit block -> effectively 16-bits).

Here's a link to a practical case of unsafe composition (in hashing): http://blog.ircmaxell.com/2015/03/security-issue-combining-b...

A bit more detail on randomly composing encryption algorithms: http://blog.cryptographyengineering.com/2012/02/multiple-enc...

edit: It would be better to compose CC(KC(P)) so CC can't leak any information about P or degrade KC. Any reluctance to show the world the output of CC should suggest the low-practical-value of CC.

Re:The Cryptographic Doom Principle by schoen on Tuesday April 14, 2015 @12:36PM (#9375459)
Why does expanding the underlying data that way "substantially degrade the security of a block-based cipher"? Can you think of a generic way that an adversary can gain an advantage against the block cipher because of this transformation/restriction of the plaintext?

(I appreciate the link to Matthew Green's post; I don't think his analysis of the effect of composition is as pessimistic as yours.)

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @12:27PM (#9375393)
CC doesn't get to see the plaintext in the construct I explained.

CC is just a bijective function on (blocksize of KC) bits.

The author of the mentioned blog ignores the fact that cascading ciphers like I described breaks automated cryptoanalysis which is a necessity for mass surveillance in a world with wide-spread cryptography.

Re:The Cryptographic Doom Principle by schoen on Tuesday April 14, 2015 @12:42PM (#9375509)
I think cascading ciphers might be a good idea, but if you're following Kerckhoff's rule, if your system achieves significant use and there is a cryptographic weakness, you should assume an adversary will exploit it even if it's different from the weaknesses of other systems.

I guess there's an economic argument to be made that millions or billions of pairs of communicating parties could develop their own individual means of at least obfuscating their communications so that nobody could expect to find searchable plaintext after decryption. But the economic effort that the pairs of parties invested in creating their obfuscations may have been wasted because if the same level of time or effort had instead been spent to improve mainstream cryptography, it might have yielded major qualitative security improvements for the "official" stuff.

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @03:40PM (#9376760)
I'm well aware that it doesn't stop a devoted attacker. But it needs a devoted attacker. That is the import point which you also recognized (beside many others). Even a devoted attacker has it harder because cracking a code with known algorithm and unknown key is easier than cracking a code with unknown algorithm and unknown key. Even more if the unknown algorithm is not available.

I think your argument that the effort put in custom ciphers maybe should be put in mainstream ciphers instead is interesting.

Tinkering around with custom ciphers can teach you a lot. Maybe you have not the knowledge or no idea how to attack/improve mainstream ciphers.

However, if you can make a difference for mainstream ciphers, of course that's what we need.

Re:The Cryptographic Doom Principle by schoen on Tuesday April 14, 2015 @08:43PM (#9378251)
Just to put the issue in an extreme perspective, suppose that the best mathematically possible attacks against AES-256 in some setting only reduce the attacker's work by the same factor as the best mathematically possible attacks against AES-128. (There's no proof of this now, but it's conceivable that it's true.) In that case, the decision to use AES-256 in a particular application instead of AES-128 improves security against cryptanalysis of AES by a factor of 2¹²⁸ steps for the attacker. (Maybe cryptanalysis of AES isn't actually the weak point anyway, but let's set that aside because that's what inventing new ciphers tries to address.)

If this hypothesis is true, the work that Daemen and Rijmen did to invent AES-256 and the work that a particular implementer did to implement it will produce an almost inconceivably vast security benefit against this particular threat.

The reason this is important is the kind of disproportionality between the effort of Daemen and Rijmen and the AES reviewers and implementers, and the magnitude of the resulting security benefit. They might have spent a total of 500 person-years on making AES-256 work well, and received a security improvement of 340 trillion trillion trillion trillion-fold relative to whatever the security of AES-128 is. Whereas a homegrown cipher that isn't very mathematically sound might be developed with 1 person-year of effort and end up make an attacker do, let's say, 100 trillion operations. In my hypothesis, Daemen and Rijmen and other folks then got somewhere between a trillion trillion trillion and a trillion trillion trillion trillion trillion trillion trillion times better security return on their effort.

Now you might reasonably point out that if you use a standard, known cipher, the attacker's costs for a direct brute force attack are purely computational and don't involve research and development, or attempting to suborn or hack your correspondents or colleagues to discover the principles of operation or your system. Whereas if you do have a homegrown mechanism in play, an attacker incurs these other kinds of novel and sort of one-off costs, notably including making other human beings think about stuff more.

The point that I've taken from a lot of the security experts who've talked about this, though, is that the scaling benefits are the important factor here, again especially if you want to make a system that many people could use for a long time. When the limiting factor is computer time, which is really only likely to be true for systems created, refined, and reviewed by experts, you can sometimes get the really absurd security ratios that are hard to even think about, and require your adversary to spend more money than exists in the world, build more computers than can be made from all the silicon on Earth, consume more energy than the Sun outputs, etc., etc. When the limiting factor is human reasoning, you might say "but that would require human cryptographers to think about my system for 1 year!". But if that's so, that may actually happen, and in any case you can't easily get the order of magnitude of the costs and resources required up to "inhuman" levels.

The point I'd take from your idea is that it could be valuable to try to make adversaries incur diverse costs in attacking your system, especially if you don't know what capabilities and resources your adversaries do and don't have. This is kind of akin to what's happened with key derivation, where people have proposed KDFs that are very CPU-intensive and also KDFs that are very memory-intensive, and if there are other sorts of resources that you could make an attacker burn, there are probably people trying to invent KDFs that burn those, too. It's not clear to me that there's a genuinely scalable way to require human analytical effort as one of those resources, but if there is, that could be a useful property for communications systems to have for defense in depth. But making up a new cipher by hand for every system is probably not going to provide that property very reliably, or be a very effective use of resources, again when other uses of resources can improve security to a staggering extent.

Re:The Cryptographic Doom Principle by kelson on Tuesday April 14, 2015 @12:34PM (#9375445)
You're right; I misread your construct as KC(CC(P)). Your construct [CC(KC(P))] shouldn't be weaker than KC, unless information or resources are shared by CC and KC (such as keys). Shared information or resources may introduce side channel attacks. Per the previous link, this is likely only practicable on entirely separate machines.

Any entity that can break AES at-scale will undoubtedly find any unreviewed cryptographic protocol trivial to break. Any such at-scale effort would already include attacks against typical bad-custom-crypto (because they're extremely easy and common), in addition to the AES attacks. Cascading ciphers, particularly weak ones, will not stop the NSA.

edit: addressed information leak if CC & KC share keys/resources

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @12:44PM (#9375521)
Thanks for agreeing that we don't lose security when using my construct.

> Any entity that can break AES at-scale will undoubtedly find any unreviewed cryptographic protocol trivial to break.

Yes, but it would involve highly paid cryptoanalysts. The reason for my first comment is first of all to disprove the root of this thread. Secondly, it makes surveillance more expensive while it's free for us.

Re:The Cryptographic Doom Principle by kelson on Tuesday April 14, 2015 @12:58PM (#9375637)
> Thanks for agreeing that we don't lose security when using my construct.

I don't agree. The construct may not degrade security under several caveats. Most implementations are extremely likely to share resources, which will introduce weaknesses. I'd wager those weaknesses would degrade security much more than the composition would enhance it, but it'd depend on the exact situation.

> Yes but it would involve highly paid cryptoanalysts. My proposal is first of all to disprove the root of this thread. Secondly, it makes surveillance more expensive while it's free for us. That what's cryptography all about. Making their life harder while not so much for us.

My exact point was that those cryptographers would already need to develop generic attacks for all the non-standard (read: non-secure) cryptosystems out there. Composing a homegrown cipher with a peer-reviewed secure cipher will not make their lives harder. It will make maintaining and improving the system harder. The net result is overwhelmingly likely to be detrimental.

Re:The Cryptographic Doom Principle by angry_octet on Tuesday April 14, 2015 @02:21PM (#9376258)
And it has the added benefit from the NSA's point of view that your connection/data is precisely fingerprinted as 'homebrew-crypto-1629: refer to analysis cell 2865JQ'.

Then the computer is sub basement 19 goes 'ding!' and sends an automated SWAT team to your house.

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @02:55PM (#9376485)
To fingerprint the connection/data by the used cipher they would need to break KC. If they are able to break KC they can fingerprint you also when you only use KC.
Re:The Cryptographic Doom Principle by angry_octet on Wednesday April 15, 2015 @12:14AM (#9378842)
You have said multiple times that the outer wrapper was CC, and the offline, inner wrapper was KC. All they need to do is infer it is CC output, either through online attacks, anomalies in its statistical distribution, block size, etc. Also, certain modes like ECB have watermarking attacks, which inherently reveal that ECB was used.

RC4 is a common stream encryption which can definitely be detected. In contrast AES seems much harder.

It is called a Distinguishing attack. See: https://eprint.iacr.org/2013/176.pdf http://www.security.iitk.ac.in/hack.in/2009/repository/bimal... http://elligator.cr.yp.to/elligator-20130828.pdf http://cr.yp.to/streamciphers/mag/053.pdf http://christina-boura.info/sites/default/files/KeyDifferenc...

Re:The Cryptographic Doom Principle by im3w1l on Tuesday April 14, 2015 @03:32PM (#9376695)
The output of KC is not necessarily completely random. It can contain some metadata. Like "encrypted with KC4096bits, initialization vector is 490282348992489, length of ciphertext is 26728 bytes".

When you pass this through a bad cipher it may create a characteristic fingerprint.

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @04:03PM (#9376898)
I think you confuse cipher with protocol.

To make it clear: for me a cipher is a bijective function on arrays of a predefined length.

Re:The Cryptographic Doom Principle by im3w1l on Saturday April 18, 2015 @06:18AM (#9398897)
What do you propose doing with the initialization vectors then? Afaik, all commonly used encryption algorithms have those, for good reason too.
Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @01:19PM (#9375776)
We don't agree on the effectiveness of security through obscurity.
Re:The Cryptographic Doom Principle by sarciszewski on Tuesday April 14, 2015 @12:34PM (#9375440)
Cascade Ciphers were out of scope. Moxie was addressing the order of operations for authentication and encryption.
Re:The Cryptographic Doom Principle by im3w1l on Tuesday April 14, 2015 @03:04PM (#9376539)
Wait are you telling me there are special classes of inputs that are unsafe to encrypt using the standard algorithms?

This sounds scary and please tell me more. In particular what happens in the pathological case where the input consists of 32/64/128/256 bit blocks, and in each block all bits are zero except the last one which may be one or zero?

Re:The Cryptographic Doom Principle by duaneb on Tuesday April 14, 2015 @05:09PM (#9377381)
If you restrict the search space of the input, you also reduce the possible outputs, and that makes it easier to narrow down the key. However, it's only really plausible on very small inputs, another channel of attack (e.g. the ones illustrated in the article), or if you know something specific about the input.

TL;DR don't base64 without a reason because it gives the attacker more bytes with fewer values to work with.

Re:The Cryptographic Doom Principle by Strilanc on Tuesday April 14, 2015 @12:58PM (#9375630)
Most of the responses seem to be talking about A -> Custom -Strong -> Unstrong -> Uncustom instead of A -> Strong -> Custom -> Uncustom -> Unstrong*.

Some potential problems with applying a custom transform to the cyphertext:

- The custom transform might have effects on cache that create opportunities for timing attacks

- The custom transform might have a buffer-overflow (just like any other excess code)

- The custom transform might support features exploitable in DOS attacks, like run-length encoding

- The custom transform might be slow, costing time and money

- Sometimes applying two transforms is equivalent to encrypting with a different key (e.g. DES has this property). Might create meet-in-the-middle attacks.

- If the custom transform is given the same key as the strong crypto, as a lazy programmer might do, it could leak the key

- Switching the ordering of the transforms is a deadly mistake, but easy to glance over

- If the strong transform starts with an HMAC, as it should, that can be used to break the custom transform's key anyways (see the post we're commenting on)

Mostly those are small things. But the security benefit you get is also small.

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @01:12PM (#9375731)
> Most of the responses seem to be talking about A -> Custom -Strong -> Unstrong -> Uncustom instead of A -> Strong -> Custom -> Uncustom -> Unstrong*.

Yes :(

> Some potential problems with applying a custom transform to the cyphertext:

> - The custom transform might have effects on cache that create opportunities for timing attacks

> - The custom transform might have a buffer-overflow (just like any other excess code)

This are for the point of my comment irrelevant implementation details. You could apply the custom transform on another computer.

> - The custom transform might support features exploitable in DOS attacks, like run-length encoding

The custom transform ought to be a bijective function on (blocksize of Strong) bits.

> - The custom transform might be slow, costing time and money

It was never meant as a suggestion for wide-spread usage.

> - Sometimes applying two transforms is equivalent to encrypting with a different key (e.g. DES has this property). Might create meet-in-the-middle attacks.

> - If the custom transform is given the same key as the strong crypto, as a lazy programmer might do, it could leak the key

The custom transform shouldn't know at all about anything of the strong cipher. Another implementation detail.

> - Switching the ordering of the transforms is a deadly mistake, but easy to glance over

Another implementation detail.

> - If the strong transform starts with an HMAC, as it should, that can be used to break the custom transform's key anyways (see the post we're commenting on)

I just wanted to show the common idea of "cryptography is black magic, you should never touch it, you can only do bad things" wrong.

My scheme adds security through obscurity which may be worth the trouble.

Re:The Cryptographic Doom Principle by kelson on Tuesday April 14, 2015 @01:24PM (#9375824)
> I just wanted to show the common idea of "cryptography is black magic, you should never touch it, you can only do bad things" wrong.

Per the other thread, this is overwhelmingly likely to decrease overall security without any practical benefit.

> My scheme adds security through obscurity which may be worth the trouble.

It adds potential side channels and likely no benefit over KC alone. You've sidelined many potential problems by focusing on "if the composition is properly implemented," but that's a huge problem. The likelihood of properly implementing the composition is vanishingly small. It is very likely to be improperly implemented and provide less security than KC alone (and it costs more!)

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @01:39PM (#9375935)
Okay, this is how I'd ad-hoc implement the scheme I described without the security problems you are commenting. A and B know each other and exchange the custom cipher securely. Imagine they each have a Raspberry Pi which does nothing else then to take each IP package sent from the other side and reverse the custom transform on the data. For each package that it sends to the other party it applies the custom transform to the data. Now A and B can route their internet traffic through their Raspberry Pi and get security by obscurity for their communication on top of the usual security. Even if the custom transform is simple, it's overwhelmingly probable that no automated TLS-break-tool will be able to break the custom transformed TLS traffic to the other party.
Re:The Cryptographic Doom Principle by kelson on Tuesday April 14, 2015 @02:17PM (#9376233)
Was CC and KC both performed on the Pi? That introduces side channel attacks.

Does CC include implementation flaws enabling remote access? An attacker may use the Pi to enhance attacks against the system executing KC.

Does the Pi include any remotely exploitable flaws? See before.

If assume a perfect/non-exploitable CC/Pi, we may not degrade the security of KC. That key word, may, is the problem professional cryptographers spent years analyzing though. If we spent a month thinking about this, we might identify other requirements needed to avoid weakening KC. This is not recommended.

Systems which rely upon cipher-obscurity are not secure. Most amateur cryptosystems are trivially defeated without any knowledge of their internals (FBI has some nice articles on cryptanalysis of criminal ciphers). Advising amateurs to rely upon homegrown ciphers is unprofessional and encourages bad risk mitigation strategies.

We also disagree about the difficulty of breaking non-keyed bijections (trivial) versus AES-at-scale ("not trivial"). The cost of the latter easily exceeds $1B. The former would take a trained cryptanalyst less than a month. Is your data worth <$10,000?

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @02:47PM (#9376421)
> Was CC and KC both performed on the Pi? That introduces side channel attacks.

I specifically said the RPi does nothing else but CC.

> Does CC include implementation flaws enabling remote access? An attacker may use the Pi to enhance attacks against the system executing KC.

> Does the Pi include any remotely exploitable flaws? See before.

The interface from the PC to the RPi should of course have the same security as any internet-facing interface. Thus the remote access to the RPi wouldn't pose a risk for using the protocol beside the obvious risks that you always get in such a scenario.

> Systems which rely upon cipher-obscurity are not secure. Most amateur cryptosystems are trivially defeated without any knowledge of their internals (FBI has some nice articles on cryptanalysis of criminal ciphers). Advising amateurs to rely upon homegrown ciphers is unprofessional and encourages bad risk mitigation strategies.

The system I described is not trivially defeated because defeating it implies defeating KC.

Did you read my comments?

> We also disagree about the difficulty of breaking non-keyed bijections (trivial) versus AES-at-scale ("not trivial"). The cost of the latter easily exceeds $1B. The former would take a trained cryptanalyst less than a month. Is your data worth <$10,000?

To break my cipher an attacker would need to solve _both_ problems.

My point is that _if_ AES is broken without our knowledge, using the system I described can still make untargeted-surveillance impractical. Isn't that an interesting property for a protocol using a custom cipher?

Re:The Cryptographic Doom Principle by kelson on Tuesday April 14, 2015 @03:23PM (#9376637)
> Thus the remote access to the RPi wouldn't pose a risk for using the protocol beside the obvious risks that you always get in such a scenario.

That risk didn't exist without the custom cipher construct (KC-system is still independently vulnerable as it was without the CC-system). This means the construct has increased the attack surface, potentially critically.

> The system I described is not trivially defeated because defeating it implies defeating KC.

Your system introduces potential new vectors to defeat KC. If KC were not broken, this construct likely weakens KC. If KC were broken, this construct may provide some minor protection. Whether it provides sufficient additional protection to actually protect the data from an adversary capable of breaking KC is extremely unlikely. Given KC is a peer-reviewed secure ciphersuite and CC is not, the emphasis should be on keeping KC secure - not weakening it to introduce an untested (likely insecure) ciphersuite in a custom composition. This is doubly the case given significant and on-going real-world costs of implementing and maintaining this custom solution.

> My point is that _if_ AES is broken without our knowledge, using the system I described can still make untargeted-surveillance impractical.

An adversary capable of automating AES decryption would already have automated weak-cryptosystem decryption. This adds nothing except cost, complexity, and faux security.

Re:The Cryptographic Doom Principle by stouset on Tuesday April 14, 2015 @04:46PM (#9377228)
This protects only against an attacker who has broken AES so thoroughly that they can essentially surveil TLS traffic en masse at no cost.

To a targeted attacker, TLS is trivially identifiable through packet analysis. After a few handshakes, your transform (as mentioned elsewhere, reverse some nybbles and XOR against a constant) will be fully understood and broken with likely less effort than it cost you to build in the first place.

Re:The Cryptographic Doom Principle by c22 on Tuesday April 14, 2015 @02:43PM (#9376400)
Why not just use a different mature and trusted cipher on the relaying nodes?
Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @03:01PM (#9376520)
That would give you security against different threats.

I chose a custom cipher for 2 reasons:

1. It gives some security even when assuming that all publicly known ciphers are broken.

2. It works specifically by using a custom cipher which is normally considered bad and thus makes the results unintuitive.

I think that makes it interesting.

Re:The Cryptographic Doom Principle by c22 on Tuesday April 14, 2015 @03:33PM (#9376704)
Are you just attempting to argue the pedantic point that some theoretical subset of homebrew crypto applications may actually be secure? Because taken as practical advice your position requires a lot of awfully strong assumptions.
Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @04:19PM (#9377013)
Every crypto is homebrown - just maybe not in your home.

Everyone cooks just with water.

The scheme I talked about is not entirely homebrew. It consists of a mainstream cipher KC and a custom cipher CC to unite the best of both worlds: Robustness of mainstream crypto with obscurity of homebrew crypto.

Re:The Cryptographic Doom Principle by c22 on Tuesday April 14, 2015 @06:18PM (#9377730)
> Every crypto is homebrown - just maybe not in your home.

> Everyone cooks just with water.

The problem with applying this definition of "homegrown" is that it willfully ignores any distinction implied by the term and thus renders it semantically meaningless. This is a form of straw man.

Regardless, even if we assume that all crypto, at the time of writing, is equally likely to be safe, I posit that the security and cost of implementation benefits achieved by leveraging published techniques far outweighs the benefit of having an obscure fingerprint. This is because previously published methods have the advantage of selection and iterative hardening based on peer review.

Furthermore, I posit that even if you wrap your data in a matryoshka doll of encryption, each of these layers will be more secure when implemented using proven techniques.

For the same reasons I'd also argue that even if you were to develop your own cipher you would benefit more by publishing it than by keeping it a secret.

Another way to think about it is that "an attacker reading the documentation" should not be a failure mode of well-implemented crypto.

Speculating even deeper on the subject, it occurs to me that in the face of a global adversary (of whose automated cryptanalysis your proposal aims to thwart) displaying a unique fingerprint may actually be detrimental to the security of your data as it may flag it specifically for deeper inspection and manual analysis.

Re:The Cryptographic Doom Principle by angry_octet on Tuesday April 14, 2015 @01:43PM (#9375968)
So wrong. Your custom cipher could be leaking key material in the encrypted output, almost certainly leaks the key via timing channels, could be leaking the known cipher key by timing channels and more (and this is assuming separate keys).

The CC decode stage will be subjected to every possible edge case to see if it will do something dumb, like the oracle attacks mentioned in the article. And it could also leak information about the KC decode via timing attacks.

If this was for offline file encryption, where you do the steps separately, maybe okay. But not for online encryption where chosen plaintext is possible.

Re:The Cryptographic Doom Principle by madez on Tuesday April 14, 2015 @01:51PM (#9376034)
Read this thread.

CC is a bijective function on (blocksize of KC) bits.

CC knows nothing at all about KC.

Implementation can be done in another computer without security problem while you get obscurity.

Read this thread.

Re:The Cryptographic Doom Principle by angry_octet on Tuesday April 14, 2015 @02:05PM (#9376143)
You don't mention separate computers until now. It's a big difference. I thought we were discussing implementing crypto, not some theoretical properties you achieve when conditions are just right.

I'm not saying trust the Windows implementation of AES, you can put it through some other cipher with a strong implementation as well, but don't just make up your own one.