Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Let's consider the three common bitwise logical operators</p> <p>Let's say we can choose some number (let's call it the mask) and combine it with an unknown value</p> <ul> <li>AND is about forcing some bits to zero (those that are set to zero in the mask)</li> <li>OR is about forcing some bits to one (those that are set to one in the mask)</li> </ul> <p>XOR is more subtle you can't know for sure the value of any bit of the result, whatever the mask you choose. But if you apply your mask <strong>two times</strong> you get back your initial value.</p> <p>In other words the purpose of AND and OR is to remove some information, and that's definitely not what you want in cryptographic algorithms (symmetric or asymmetric cipher, or digital signature). If you lose information you won't be able to get it back (decrypt) or signature would tolerate some minute changes in message, thus defeating it's purpose.</p> <p>All that said, that is true of cryptographic algorithms, not of their implementations. Most implementations of cryptographic algorithms also use many ANDs, usually to extract individual bytes from 32 or 64 internal registers.</p> <p>You typically get code like that (this is some nearly random extract of aes_core.c)</p> <pre><code>rk[ 6] = rk[ 0] ^ (Te2[(temp &gt;&gt; 16) &amp; 0xff] &amp; 0xff000000) ^ (Te3[(temp &gt;&gt; 8) &amp; 0xff] &amp; 0x00ff0000) ^ (Te0[(temp ) &amp; 0xff] &amp; 0x0000ff00) ^ (Te1[(temp &gt;&gt; 24) ] &amp; 0x000000ff) ^ rcon[i]; rk[ 7] = rk[ 1] ^ rk[ 6]; rk[ 8] = rk[ 2] ^ rk[ 7]; rk[ 9] = rk[ 3] ^ rk[ 8]; </code></pre> <p>8 XORs and 7 ANDs if I count right</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload