A side-channel attack on GnuPG
Using equipment that is reminiscent of the Van Eck phreaking scene in Cryptonomicon, some security researchers have shown that keys can be extracted from a laptop in the next room. It is a passive attack that exploits a side channel in the GNU Privacy Guard (GnuPG) implementation of the Elliptic Curve Diffie-Hellman (ECDH) key-exchange protocol. The problem has been fixed in Libgcrypt, but the possibility of similar weaknesses in other algorithms or implementations makes this kind of attack worthy of some study by those working in cryptography.
The paper [PDF] that describes the technique was authored by Daniel Genkin, Lev Pachmanov, Itamar Pipman, and Eran Tromer, who are researchers at Tel Aviv University. There are pictures of the equipment used in the paper, as well as on a web page with some FAQs on the technique. The current setup costs around $3000 for the equipment needed to intercept the electromagnetic (EM) signals from a computer on the other side of a wall, but it is believed that much less expensive (and more portable) equipment could be developed.
The basic idea is to measure the EM output of the laptop as it decrypts chosen ciphertext. GnuPG is used by tools like the Enigmail plugin for Mozilla Thunderbird, so email can be used as a way to cause the laptop to do the decryption. Enigmail will automatically pass encrypted email to GnuPG for decryption, which means that email sent will result in decryption that can be captured in the next room. Multiple emails were sent to improve the reliability of the key extraction. So, by sending emails encrypted with a victim's public key, an attacker (or government agency) in the next room can recover most of the victim's private key—thus decrypt any other encrypted email that has been intercepted.
In Libgcrypt 1.6.3 and earlier, the decryption algorithm does an optimization that allows the key to be recovered. Large integers (such as keys) are represented in non-adjacent form (NAF) in order to reduce the number of non-zero digits (each of which requires additional arithmetic operations) from roughly one-half to one-third. Numbers in that form are strings of 1, 0, and -1 values.
By observing the operations performed on the ciphertext, the researchers were easily able to distinguish the 0 "bits" in the key, but there was still a problem determining whether the non-zero values were 1 or -1. That's where choosing the ciphertext comes into play. By using specific points on the elliptic curve in the ciphertext, the researchers could reliably distinguish between the sequence of operations done for a 1 value versus those done for a -1 value.
The net result is described in the paper:
While the entire key is not necessarily extracted, the search space has been reduced enormously. Presumably, brute-force techniques can determine the missing digits and any errors in short order.
In order to avoid this side-channel leak, Libgcrypt 1.6.5 was released. It always does the same set of operations for each digit, regardless of its value. The researchers worked with the GnuPG developers to ensure that the change resisted the attack. The new algorithm is slower, but won't be subverted with this technique. Other tools use Libgcrypt, too, of course, so the update is important. The big unknown is whether other implementations of ECDH are vulnerable—and what other side channels (in other cryptographic algorithms) are out there waiting to be found.
Cryptographic algorithms are hard to get right even before considering problems like side channels. While these kinds of attacks are not particularly new, they do represent a threat to users, particularly from targeted, nation-state-level attackers. Though, as noted in the FAQ, this kind of attack is unlikely to be used except against the most security conscious:
For those who are taking more precautions than most, however, these techniques have to be a little worrisome. It is not terribly hard to imagine some agency setting up shop in the next hotel room over and monitoring the activity of the laptop next door, then sending these targeted emails and collecting the data needed. The best defense may well be to ensure that decryption only takes place under the direction of the user—and in a secure location.
| Index entries for this article | |
|---|---|
| Security | Encryption/Side-channel attack |
Posted Feb 18, 2016 8:26 UTC (Thu)
by johill (subscriber, #25196)
[Link] (5 responses)
Posted Feb 18, 2016 9:03 UTC (Thu)
by dd9jn (✭ supporter ✭, #4459)
[Link]
Posted Feb 18, 2016 19:04 UTC (Thu)
by smoogen (subscriber, #97)
[Link]
Posted Feb 19, 2016 7:49 UTC (Fri)
by robbe (guest, #16131)
[Link] (2 responses)
This implementation may or may not be affected by the same problem. Furthermore, smart cards usually run closed-source software, so you can’t even check without expensive equipment.
On the other hand, smart cards /should/ be proofed against this kind of side-channel, and the leakage on a teensy chip should be much less than on your CPU powerhouse.
Finally, if your smart card were affected by a bug: do you know where firmware updates are published? How often do you check? How often do you actually upgrade? For me the answers would be: no, never, never.
Posted Feb 19, 2016 9:32 UTC (Fri)
by xnox (guest, #63320)
[Link] (1 responses)
But it baffles me why individuals would ever choose that over RSA. ECC will be cracked first with quantum computing. Hence I am yet to use ECC.
Posted Feb 19, 2016 14:38 UTC (Fri)
by Trou.fr (subscriber, #26289)
[Link]
Posted Feb 18, 2016 18:27 UTC (Thu)
by fandingo (guest, #67019)
[Link] (5 responses)
What type of radiation are we talking about and what's the source? Is this similar to a timing attack, except instead of time they're measuring EM?
I did find a little info the paper:
> During the decryption of the chosen ciphertext, we measure the EM leakage of the target laptop, focusing on a narrow frequency band (frequencies in the range 1.5–2 MHz). After suitable signal processing, a clean trace is produced which reveals information about the operands used in the elliptic curve operations. This information, in turn, is used in order to reveal the secret key.
> the best signal quality was obtained close to the CPU’s voltage regulator,
I don't understand what about decryption is causing the computer to emit a distinguishable signal.
Posted Feb 18, 2016 19:10 UTC (Thu)
by smoogen (subscriber, #97)
[Link] (2 responses)
Posted Feb 18, 2016 20:36 UTC (Thu)
by apoelstra (subscriber, #75205)
[Link] (1 responses)
In crypto it's often not "hey, I can be clever by optimizing this special case", but rather special cases already existing in the mathematics. In elliptic curves this happens often, because elliptic curves fit most naturally into a projective space, where the only everywhere-defined rational functions are the constant ones. This means that any formula you come up with to add two points is going to have some case where it doesn't work. The textbook case of this results in three formulas:
Absent further trickery, you have to write separate code for each of these cases, since the total addition formula will thus be wrong. And they each take a different amount of time, giving rise to timing attacks.
So the problem here was not special-casing things; it was indeed caused by using a compact scalar representation that had a bunch of 0's in it, but this would also have been true had the programmers done the naive thing and just used normal binary numbers for their scalars. To avoid this attacks requires even more cleverness: (a) finding a representation that has no 0's in it, and (b) doing a scalar multiply with this representation in away that its pattern of doubling vs non-doubling is independent of the underlying secret data.
Posted Feb 19, 2016 9:37 UTC (Fri)
by xnox (guest, #63320)
[Link]
Posted Feb 19, 2016 15:12 UTC (Fri)
by thoughtpolice (subscriber, #87455)
[Link] (1 responses)
for (i = 0 to <CONSTANT>, i++) {
(you can look up the full algorithm, of course).
The "scalar" in this case is actually the private key you generate. You calculate secrets by doing scalar multiplication of a point vs your secret key scalar.
This algorithm admits a very obvious timing attack, namely, that the number of point additions and point doubles is dependent on the input pattern of an input scalar. The scalar 0x10000000 features 8 double operations but only 1 addition operation. 0x11111111 features 8 doubles and 8 additions. Any iteration of the loop where the i'th bit is set will clearly reveal whether that bit is set - either through measuring execution time, or electromagnetic emissions.
It is not clear if this attack in the paper works as well on other curves such as Curve25519 which use the montgomery ladder, which is a constant-time scalar multiplication algorithm, that always does the exact same number of point doubles/additions, regardless of the bit pattern of the input scalar. However, it's probably still possible to recover some information if you can distinguish a point addition from a point double in the core loop. Something like an Edwards curve with unified point addition/doubling and the montgomery ladder will probably make the attack far less effective.
Posted Feb 19, 2016 17:07 UTC (Fri)
by gmaxwell (guest, #30048)
[Link]
The attack combines several EM leaks that are specific to the combination of NAF and field operations which are not constant-EM based on their inputs. E.g. they'd fed a public point whos value or negation has a small coordinate; and in doing so determine if for each position -P or P s being added.
EM sidechannels are incredibly hard to be secure against; since generic computing devices make no real promises about EM sidechannels even for operations which are otherwise constant-time. On top of a generic non-costant time field implementation all bets are off. The best you can likely do is expensive blinding operations.
A side-channel attack on GnuPG
A side-channel attack on GnuPG
A side-channel attack on GnuPG
A side-channel attack on GnuPG
A side-channel attack on GnuPG
A side-channel attack on GnuPG
A side-channel attack on GnuPG
A side-channel attack on GnuPG
A side-channel attack on GnuPG
1. Adding a point to "the point at infinity" gives you that point back. This is basically instant.
2. Adding two distinct non-infinite points requires one formula, which some number of field operations.
3. Adding two equal points (i.e. doubling) requires another, which takes slightly fewer field operations than the above.
A side-channel attack on GnuPG
A side-channel attack on GnuPG
if bit_is_set(i, scalar) {
Q = point_addition(P, Q)
}
point_double(P)
}
A side-channel attack on GnuPG
