Cell permutation step. Shifts cells within the rows of the input and returns the result.
(BigInteger ciphertext)
| 2567 | * returns the result. |
| 2568 | */ |
| 2569 | public static BigInteger shiftRows(BigInteger ciphertext) { |
| 2570 | int[] cells = splitBlockIntoCells(ciphertext); |
| 2571 | int[] output = new int[16]; |
| 2572 | |
| 2573 | // do nothing in the first row |
| 2574 | output[0] = cells[0]; |
| 2575 | output[4] = cells[4]; |
| 2576 | output[8] = cells[8]; |
| 2577 | output[12] = cells[12]; |
| 2578 | |
| 2579 | // shift the second row backwards by one cell |
| 2580 | output[1] = cells[5]; |
| 2581 | output[5] = cells[9]; |
| 2582 | output[9] = cells[13]; |
| 2583 | output[13] = cells[1]; |
| 2584 | |
| 2585 | // shift the third row backwards by two cell |
| 2586 | output[2] = cells[10]; |
| 2587 | output[6] = cells[14]; |
| 2588 | output[10] = cells[2]; |
| 2589 | output[14] = cells[6]; |
| 2590 | |
| 2591 | // shift the forth row backwards by tree cell |
| 2592 | output[3] = cells[15]; |
| 2593 | output[7] = cells[3]; |
| 2594 | output[11] = cells[7]; |
| 2595 | output[15] = cells[11]; |
| 2596 | |
| 2597 | return mergeCellsIntoBlock(output); |
| 2598 | } |
| 2599 | |
| 2600 | /** |
| 2601 | * Cell permutation step for decryption . Shifts cells within the rows of |
no test coverage detected