private function createKeySchedule() { $end = sizeof($this->roundKey) - 1; $first = 0; $rcon = 0; for ($k = 0; $k < 20; $k++) { $endColumn = $this->getColumn($this->roundKey, $end); $rconColumn = $this->getColumn($this->rcon, $rcon); $firstColumn = $this->getColumn($this->roundKey, $first); $endColumn = AES::rotWord($endColumn); $endColumn = AES::subWord($endColumn, $this->subArray); for ($i = 0; $i < sizeof($endColumn); $i++) { $bin_one = str_pad(base_convert($endColumn[$i], 16, 2), 8, "0", STR_PAD_LEFT); $bin_two = str_pad(base_convert($firstColumn[$i], 16, 2), 8, "0", STR_PAD_LEFT); $bin_three = str_pad(base_convert($rconColumn[$i], 16, 2), 8, "0", STR_PAD_LEFT); $xor = AES::ffAdd($bin_one, $bin_two); $xor_bin = str_pad(base_convert($xor, 16, 2), 8, "0", STR_PAD_LEFT); $this->roundKey[$i][] = AES::ffAdd($xor_bin, $bin_three); } $rcon++; $end++; $first++; for ($j = 0; $j < 3; $j++) { $endColumn = $this->getColumn($this->roundKey, $end); $firstColumn = $this->getColumn($this->roundKey, $first); for ($i = 0; $i < sizeof($endColumn); $i++) { $bin_one = str_pad(base_convert($endColumn[$i], 16, 2), 8, "0", STR_PAD_LEFT); $bin_two = str_pad(base_convert($firstColumn[$i], 16, 2), 8, "0", STR_PAD_LEFT); $this->roundKey[$i][] = AES::ffAdd($bin_one, $bin_two); } $end++; $first++; } } //rotWord //take last column and rotate one column //sub byte sin this last column //xor the first column with the last column and the next row in Rcon }