power consumption in a XOR

I'm trying to understand how a XOR affect traces of power consumption in a Differential Power Analysis on smartcards.

What's the difference in energy radiated in a $1 \oplus 1$ and in a $0 \oplus 1$?

If I understand correctly we have a XOR gate, and if a $1$ is xored with a $0$ then electrons in the 1 branch just continue flowing thus we still have some energy compared to a $0 \oplus 0$.

• Since a difference in energy is asked, that is proportional to a duration, which could be anything from a clock cycle (perhaps down to 10ns in some areas of the Smart Card) to months. That also depends tremendously on where in the Smart Card the XOR occurs (is that in the CPU ALU? An AES block? Some bus encryption unit?); the silicon technology; and exactly what one accounts as radiated. Also, it can happen that whatever quantity is available to the attacker depends more on change of state, than on the state itself.
– fgrieu
Dec 24 '14 at 12:23

The exact details depend on the logic family but basically The difference is that the charge representing those "1" bits need to be discarded somehow. This is done by switching the output to ground, 1^0 is 1 so no charge need to go away but 1^1 is zero meaning at least two gates get discharged to ground slightly raising its voltage due to the non zero resistance in the ground return path.

Though, this really depends on the logic Family, the effect of charging the output gate lowering vcc may be dominant in some like you say. But in most any mos family, some assymetry will be noticed. ECL is notably immune due to steering currents that always flow not charging capacitors.

• That does clarify a lot thanks! Does that mean the same amount of energy radiates from a 1^0 and a 0^0. But you would see a difference if you measure the courant (since 0^0 has no courant going through the circuit) ? Dec 25 '14 at 15:25

Sounds like you are trying to develop or find a sophisticated side-channel attack against XOR encryption. Since XOR is my main type of encryption I also try to find brute-force and side-channel attack methods to test how secure or insecure my own XOR encryption algorithms are.

The XOR gate either passes an input bit to the output or flips the input bit in the output. Flipping a bit is probably a few clock cycles slower than passing a bit.

The first thing and experiment you would have to do is to check whether this assumption is really the case or not. In order to do so I would recommend to code your own XOR encryption function (in C++ or other language) and then add a timer which measures how long it took the program to execute or run through the XOR gate function in each of the two possible cases when input bit was either 0 or 1.

This way you could the test the clock cycle times per frame. As suggested by others the time difference may be so small that it has to be measured in nanoseconds precision. Most timer functions I know of in C++ and other languages, however, can only measure time down to milliseconds which is too slow for that kind of experiment, thus it seems impossible in my opinion to measure the time difference between each single XOR gate code execution. Unless someone can point me to a timer function (C++ prefered) which can measure systemtime in nanoseconds and output the time value into a variable.

• I'm talking about power consumption not time consumed. I gave the example of the smartcard. Dec 24 '14 at 22:38