title: Understanding parts of GNU Crypto DES algorithm (Java)
body: <p>I'm currently confused as to the behaviour of the DES algorithm provided by the GNU Crypto package. Here's a link to the algorithm in question: <a href="http://www.koders.com/java/fidAB38AE11014325A9B6C9CB3531A9FF9C6111C1E7.aspx" rel="nofollow">GNU Crypto DES algorithm</a></p>
  
  <p>Originally I was merely wanting to extract the state of the key(s) at certain points, i.e. after PC-1, PC-2, the sub keys, etc. However, this plan's not going too well as the 56bit key expected after PC-1, appears to be 48 bits, going by the pc1m variable (working on the assumption that representation of the key (pc1m's value) when converted from decimal to binary is sound). As such I tried to figure out this piece of code:</p>
  
  <blockquote>
    <p>for (i = 0; i &lt; 56; i++) {
            l = PC1[i];
            pc1m |= ((kb[l >>> 3] &amp; (0x80 >>> (l &amp; 7))) != 0)
                  ? (1L &lt;&lt; (55 - i)) : 0;
         }</p>
  </blockquote>
  
  <p>However, my understanding of the bitwise operations is ropey, and although I have a vague understanding of how it's evaluating, I can't see the overall logic to it and how it works (or, rather why it appears to not actually work -- although the algorithm does encrypt and decrypt successfully going by the official test vectors). Where can I get the 56 bit permutation after PC-1?</p>
  
  <p>It is also unclear to me what the code does after " // Encryption key first. ", as the pc1m variable is unchanged, and pcr appears to just copy the value after all that.</p>
  
  <p>On the brightside, it appears clear, that "cooking" the keys creates the subkeys for the Feistel rounds.</p>
  
  <p>As an aside, any other non-copyrighted Java implementations you can reference would be of interest to me, however, I would quite like to work with this implementation.</p>
  
  <p>Any help would be much, much appreciated! Thanks.</p>