| @@ 225-233 (lines=9) @@ | ||
| 222 | // For j = 0 to 5 |
|
| 223 | for ($j = 0; $j <= 5; ++$j) { |
|
| 224 | // For i = 1 to n |
|
| 225 | for ($i = 1; $i <= $n; ++$i) { |
|
| 226 | // B = AES(K, A | R[i]) |
|
| 227 | $B = $this->_encrypt($kek, $A . $R[$i]); |
|
| 228 | // A = MSB(64, B) ^ t where t = (n*j)+i |
|
| 229 | $t = $n * $j + $i; |
|
| 230 | $A = $this->_msb64($B) ^ $this->_uint64($t); |
|
| 231 | // R[i] = LSB(64, B) |
|
| 232 | $R[$i] = $this->_lsb64($B); |
|
| 233 | } |
|
| 234 | } |
|
| 235 | // Set C[0] = A |
|
| 236 | $C = [$A]; |
|
| @@ 300-308 (lines=9) @@ | ||
| 297 | // For j = 5 to 0 |
|
| 298 | for ($j = 5; $j >= 0; --$j) { |
|
| 299 | // For i = n to 1 |
|
| 300 | for ($i = $n; $i >= 1; --$i) { |
|
| 301 | // B = AES-1(K, (A ^ t) | R[i]) where t = n*j+i |
|
| 302 | $t = $n * $j + $i; |
|
| 303 | $B = $this->_decrypt($kek, ($A ^ $this->_uint64($t)) . $R[$i]); |
|
| 304 | // A = MSB(64, B) |
|
| 305 | $A = $this->_msb64($B); |
|
| 306 | // R[i] = LSB(64, B) |
|
| 307 | $R[$i] = $this->_lsb64($B); |
|
| 308 | } |
|
| 309 | } |
|
| 310 | return array($A, $R); |
|
| 311 | } |
|