by tptacek · 16y ago · 0 comments
http://rdist.root.org/2010/01/07/timing-independent-array-co...
I've been following your comments and I think you need to recalibrate your expectations about timing accuracy.
That said: you're right: you can add random sleeps to increase the number of measurements attackers need to take. But I don't think you can reasonably add enough delay to make the attack infeasible (where "infeasible", as always, means "not worth conducting").
In Crosby & Wallach, you'll see that there's also an arms race brewing between defenders who hope to add noise to confound exploits, and attackers deploying signal processing techniques to see through that noise with fewer measurements.
A more reasonable "half-assed" countermeasure would be to rig something up that notices invalid tokens, and re-key after a threshold.
1. decrypt the string; if a padding exception occurs, then run a decrypt of a string the same size with correct padding. do not throw an error.
2. decrypt the string; if a padding exception does not occur, then run some instructions on a string with the same size and incorrect padding, forcing a padding error.
In both 1 & 2, we do not throw any visible errors to the user. Wouldn't this at least shrink the measurable difference significantly by ensuring that the instruction set is always going to be the same, and hopefully average out closer to a constant time, regardless of whether an error "occurs"?