Cell permutation step for decryption . Shifts cells within the rows of the input and returns the result.
(BigInteger ciphertext)
| 2602 | * the input and returns the result. |
| 2603 | */ |
| 2604 | public static BigInteger shiftRowsDec(BigInteger ciphertext) { |
| 2605 | int[] cells = splitBlockIntoCells(ciphertext); |
| 2606 | int[] output = new int[16]; |
| 2607 | |
| 2608 | // do nothing in the first row |
| 2609 | output[0] = cells[0]; |
| 2610 | output[4] = cells[4]; |
| 2611 | output[8] = cells[8]; |
| 2612 | output[12] = cells[12]; |
| 2613 | |
| 2614 | // shift the second row forwards by one cell |
| 2615 | output[1] = cells[13]; |
| 2616 | output[5] = cells[1]; |
| 2617 | output[9] = cells[5]; |
| 2618 | output[13] = cells[9]; |
| 2619 | |
| 2620 | // shift the third row forwards by two cell |
| 2621 | output[2] = cells[10]; |
| 2622 | output[6] = cells[14]; |
| 2623 | output[10] = cells[2]; |
| 2624 | output[14] = cells[6]; |
| 2625 | |
| 2626 | // shift the forth row forwards by tree cell |
| 2627 | output[3] = cells[7]; |
| 2628 | output[7] = cells[11]; |
| 2629 | output[11] = cells[15]; |
| 2630 | output[15] = cells[3]; |
| 2631 | |
| 2632 | return mergeCellsIntoBlock(output); |
| 2633 | } |
| 2634 | |
| 2635 | /** |
| 2636 | * Applies the Rijndael MixColumns to the input and returns the result. |
no test coverage detected