3 ms·
Right - it is looking more and more like truly constant time code can only be obtained by using hand written assembly or hardware. In that eventuality, I guess
by mike_hearn 12y ago
Right - it is looking more and more like truly constant time code can only be obtained by using hand written assembly or hardware. In that eventuality, I guess the core crypto code in the JVM will have to be changed to use hand written assembly as well, however, SSL is huge and most of it doesn't need to be constant time (certificate parsing, managing network buffers, message parsing etc). That is often where the bugs creep in.
Going with JSSE does have the downside that it's less widely used. Browser makers don't patch it with the latest gizmos like they do with OpenSSL. However, it's at least got a full time development team (unlike OpenSSL until very recently), and ultimately if there are odd conformance bugs lurking the only way they'll be shaken out is by people using it for real. Passing the Qualys test is a good start, but for now my little website is ideal because it is unlikely to ever be popular enough to have serious scaling issues and I can tolerate some incompatibility with odd clients.
- richm44 12y ago"Right - it is looking more and more like truly constant time code can only be obtained by using hand written assembly or hardware. In that eventuality, I guess the core crypto code in the JVM will have to be changed to use hand written assembly as well, however, SSL is huge and most of it doesn't need to be constant time (certificate parsing, managing network buffers, message parsing etc). That is often where the bugs creep in." I completely agree with you there. X.509 is a nightmare and it's not an area where constant time matters at all. Being resistant to buffer overruns and general logic errors is much more important there.
- dvanduzer 12y agoX.509 is a nightmare because it is complex, and the political infrastructure is vulnerable. There is no reason ciphers like djb's that use data-independent code paths couldn't be integrated into X.509 if the will was there. Totally separate issues.
- ars 12y ago> can only be obtained by using hand written assembly or hardware Even that is harder than it looks. For example, a common way of doing a constant time string compare is: $result |= (ord($safe[$i % $safeLen]) ^ ord($user[$i])); i.e. get the character to compare mod the length, so you wrap around if the length of the two strings is not the same. Unfortunately the mod operator does not take a constant time on a CPU! If the result is evenly divisible it's faster. So even in assembly you might not be able to protect from a timing attack. Even if you check your current CPU a new one might be different. (In this case a better way to do the compare is if the strings are not the same length, compare the attackers string against itself, and then return false.)
- nitrogen 12y ago(In this case a better way to do the compare is if the strings are not the same length, compare the attackers string against itself, and then return false.) Is there a reason for using the attacker's string rather than the valid string? Edit: it doesn't seem to me that using the valid string would leak its length unless the attacker knew quite a lot about the target machine.
- plorkyeran 12y agoHow long it takes to do the comparison reveals the length of the string being checked, so you have to check the string which the attacker knows the length of already.
- kentonv 12y ago> Edit: it doesn't seem to me that using the valid string would leak its length unless the attacker knew quite a lot about the target machine. It sounds like you are skeptical that timing attacks can be practically exploited. This is a reasonable skepticism that most people go through on initially learning about them. Unfortunately, there are in fact working exploits for this sort of thing.
- nitrogen 12y agoNo, I definitely realize the seriousness of timing attacks. I'm just curious about this particular implementation detail. I would have guessed that using the attacker's length would reveal more about the system than using a fixed length (unless the length of the valid string changed frequently). I'd like to understand why that isn't the case.