| @@ 253-261 (lines=9) @@ | ||
| 250 | // For j = 0 to 5 |
|
| 251 | for ($j = 0; $j <= 5; ++$j) { |
|
| 252 | // For i = 1 to n |
|
| 253 | for ($i = 1; $i <= $n; ++$i) { |
|
| 254 | // B = AES(K, A | R[i]) |
|
| 255 | $B = $this->_encrypt($kek, $A . $R[$i]); |
|
| 256 | // A = MSB(64, B) ^ t where t = (n*j)+i |
|
| 257 | $t = $n * $j + $i; |
|
| 258 | $A = $this->_msb64($B) ^ $this->_uint64($t); |
|
| 259 | // R[i] = LSB(64, B) |
|
| 260 | $R[$i] = $this->_lsb64($B); |
|
| 261 | } |
|
| 262 | } |
|
| 263 | // Set C[0] = A |
|
| 264 | $C = [$A]; |
|
| @@ 327-335 (lines=9) @@ | ||
| 324 | // For j = 5 to 0 |
|
| 325 | for ($j = 5; $j >= 0; --$j) { |
|
| 326 | // For i = n to 1 |
|
| 327 | for ($i = $n; $i >= 1; --$i) { |
|
| 328 | // B = AES-1(K, (A ^ t) | R[i]) where t = n*j+i |
|
| 329 | $t = $n * $j + $i; |
|
| 330 | $B = $this->_decrypt($kek, ($A ^ $this->_uint64($t)) . $R[$i]); |
|
| 331 | // A = MSB(64, B) |
|
| 332 | $A = $this->_msb64($B); |
|
| 333 | // R[i] = LSB(64, B) |
|
| 334 | $R[$i] = $this->_lsb64($B); |
|
| 335 | } |
|
| 336 | } |
|
| 337 | return array($A, $R); |
|
| 338 | } |
|