@@ 233-241 (lines=9) @@ | ||
230 | // For j = 0 to 5 |
|
231 | for ($j = 0; $j <= 5; ++$j) { |
|
232 | // For i = 1 to n |
|
233 | for ($i = 1; $i <= $n; ++$i) { |
|
234 | // B = AES(K, A | R[i]) |
|
235 | $B = $this->_encrypt($kek, $A . $R[$i]); |
|
236 | // A = MSB(64, B) ^ t where t = (n*j)+i |
|
237 | $t = $n * $j + $i; |
|
238 | $A = $this->_msb64($B) ^ $this->_uint64($t); |
|
239 | // R[i] = LSB(64, B) |
|
240 | $R[$i] = $this->_lsb64($B); |
|
241 | } |
|
242 | } |
|
243 | // Set C[0] = A |
|
244 | $C = [$A]; |
|
@@ 308-316 (lines=9) @@ | ||
305 | // For j = 5 to 0 |
|
306 | for ($j = 5; $j >= 0; --$j) { |
|
307 | // For i = n to 1 |
|
308 | for ($i = $n; $i >= 1; --$i) { |
|
309 | // B = AES-1(K, (A ^ t) | R[i]) where t = n*j+i |
|
310 | $t = $n * $j + $i; |
|
311 | $B = $this->_decrypt($kek, ($A ^ $this->_uint64($t)) . $R[$i]); |
|
312 | // A = MSB(64, B) |
|
313 | $A = $this->_msb64($B); |
|
314 | // R[i] = LSB(64, B) |
|
315 | $R[$i] = $this->_lsb64($B); |
|
316 | } |
|
317 | } |
|
318 | return array($A, $R); |
|
319 | } |