Comp Sci Is it addition or xor in AES mix column?

  • Thread starter Thread starter shivajikobardan
  • Start date Start date
  • Tags Tags
    Addition Column
AI Thread Summary
The discussion centers on the confusion between using XOR and normal hex addition in the AES MixColumns operation, particularly regarding the expression B7 + 4B. Participants clarify that while both operations can yield the same results in some cases, the correct operation in this context is arithmetic addition, which can overflow. The conversation also highlights that binary multiplication is involved, where constants are multiplied and then combined using bit-wise XOR. Additionally, a participant confirms that the result of E3 is correct, pointing out an error in binary to hex conversion in the referenced material. Understanding these operations is crucial for correctly implementing AES algorithms.
shivajikobardan
Messages
637
Reaction score
54
Homework Statement
XOR or normal hexa addition in AES?
Relevant Equations
None
https://www.networkdls.com//Articles/AESbyExample.pdf

I'm confused because there are lots of XOR in this case. And I am not very technically aware when we'd XOR vs when we'd add. I just follow the guidelines given in standards. But here I got confused in page 9 of that pdf. When we do B7+4B, is it normal hex addition or XOR? Because both are giving same results. I tried for some of my other examples, and they were giving same results. I think it's normal hex addition, but I'm not 100% sure about that.

I was studying the below book and thus. It is not saying that's wrong, but it uses lots of XOR. So, it got me confused.

https://books.google.com.np/books?i...nepage&q=advanced encryption standard&f=false
 
Physics news on Phys.org
PS another question:
1661484760188.png

I'm getting the result as E3 using my networkdls pdf method. Can you check the results?
 
shivajikobardan said:
When we do B7+4B, is it normal hex addition or XOR? Because both are giving same results.
⊕ is a binary EXOR operation.
+ is a binary OR operation.
Those operations can be executed on wide bit-streams in parallel.

+ is also an arithmetic addition operation on a registers of bits.
There is no arithmetic addition of data in the DES algorithm.

When you process bits one by one, the arithmetic binary add will perform an EXOR of the two input LSBs, with the result placed in the output LSB. That is how binary addition is done. But when the arithmetic addition operation generates carry from the LSB, it will probably corrupt some higher bits. I expect that is why your arithmetic LSB seems to produce the same result as your EXOR.
 
Baluncore said:
⊕ is a binary EXOR operation.
+ is a binary OR operation.
Those operations can be executed on wide bit-streams in parallel.

+ is also an arithmetic addition operation on a registers of bits.
There is no arithmetic addition of data in the DES algorithm.

When you process bits one by one, the arithmetic binary add will perform an EXOR of the two input LSBs, with the result placed in the output LSB. That is how binary addition is done. But when the arithmetic addition operation generates carry from the LSB, it will probably corrupt some higher bits. I expect that is why your arithmetic LSB seems to produce the same result as your EXOR.
Can you give example of each operation you told(in hexa form)? I'm ofc aware of all of them, but I'm trying to understand about your answer. It's not clear what this one is based on the answer. Instead, I'm now more confused.
 
shivajikobardan said:
But here I got confused in page 9 of that pdf. When we do B7+4B, is it normal hex addition or XOR?
It is arithmetic addition.

Given two bytes, a and b, compute the output c.
L(a) and L(b) are 8 bit lookup operations in the L() table.
h'FF is the hexadecimal constant "FF".

sum = L(a) + L(b) ; where “+” is an arithmetic addition that can overflow.
If sum > h'FF then sum = sum - h'FF ; where "-" is arithmetic subtraction.
c = E( sum ) ; lookup the result in table E() ; Note:
There is a simple way to handle the addition overflow without needing to test for overflow. In a byte, because h'FF is the same as -1, arithmetic subtraction of h'FF is the same as addition of h'01.
You can arithmetically add the two 8 bit bytes, giving a 9 bit result in a 16 bit register. The high byte will have a value of h'00, or h'01 if the addition overflowed.
Simply add the high and low bytes to make a one byte result.
 
shivajikobardan said:
I'm getting the result as E3 using my networkdls pdf method. Can you check the results?
(1*36)⊕(2*b9)⊕(3*a5)⊕(3*38) = (1*h'36)⊕(2*h'b9)⊕(3*h'a5)⊕(3*h'38)

This is performing arithmetic multiplication "*" by constants of 1, 2 or 3.
Binary multiplication can be seen as a shift and add operation.
(1 * x) = x
(2 * x) = x + x = (x shifted left one bit). Where "+" is arithmetic addition.
(3 * x) = x + x + x = x + (x shifted left one bit).

Once the arithmetic addition is done, the 4 terms are merged using bit-wise EXOR.

You are correct; b'1110 0011 = h'E3.
They make an error in the binary to hex conversion in the last line.
 
  • Like
Likes shivajikobardan
Baluncore said:
(1*36)⊕(2*b9)⊕(3*a5)⊕(3*38) = (1*h'36)⊕(2*h'b9)⊕(3*h'a5)⊕(3*h'38)

This is performing arithmetic multiplication "*" by constants of 1, 2 or 3.
Binary multiplication can be seen as a shift and add operation.
(1 * x) = x
(2 * x) = x + x = (x shifted left one bit). Where "+" is arithmetic addition.
(3 * x) = x + x + x = x + (x shifted left one bit).

Once the arithmetic addition is done, the 4 terms are merged using bit-wise EXOR.

You are correct; b'1110 0011 = h'E3.
They make an error in the binary to hex conversion in the last line.
oh thank you.
 
Back
Top