Ejemplo n.º 1
0
 /**
  * Function F - To calculate f, we first expand each block Rn-1 from 32 bits to 48 bits.
  * This is done by using a selection table that repeats some of the bits in Rn-1. We'll
  * call the use of this selection table the function E. Thus E(Rn-1) has a 32 bit input
  * block, and a 48 bit output block.
  *
  * @param array $r  32 bit binary, each bit in an array element
  * @param string $k 48 bit binary string
  * @return string 48 bit binary string
  */
 private function f($r, $k)
 {
     $bin = parent::xorBin($k, $this->E($r));
     // create a 32-bit string from $bits by passing it through the S-Boxes
     $bin = $this->s($bin);
     // now send permute $bin as defined by table self::$_p
     $bin = $this->p($bin);
     return $bin;
 }