MCPcopy Create free account
hub / github.com/TheAlgorithms/Java / mixColumns

Method mixColumns

src/main/java/com/thealgorithms/ciphers/AES.java:2638–2656  ·  view source on GitHub ↗

Applies the Rijndael MixColumns to the input and returns the result.

(BigInteger ciphertext)

Source from the content-addressed store, hash-verified

2636 * Applies the Rijndael MixColumns to the input and returns the result.
2637 */
2638 public static BigInteger mixColumns(BigInteger ciphertext) {
2639 int[] cells = splitBlockIntoCells(ciphertext);
2640 int[] outputCells = new int[16];
2641
2642 for (int i = 0; i < 4; i++) {
2643 int[] row = {
2644 cells[i * 4],
2645 cells[i * 4 + 1],
2646 cells[i * 4 + 2],
2647 cells[i * 4 + 3],
2648 };
2649
2650 outputCells[i * 4] = MULT2[row[0]] ^ MULT3[row[1]] ^ row[2] ^ row[3];
2651 outputCells[i * 4 + 1] = row[0] ^ MULT2[row[1]] ^ MULT3[row[2]] ^ row[3];
2652 outputCells[i * 4 + 2] = row[0] ^ row[1] ^ MULT2[row[2]] ^ MULT3[row[3]];
2653 outputCells[i * 4 + 3] = MULT3[row[0]] ^ row[1] ^ row[2] ^ MULT2[row[3]];
2654 }
2655 return mergeCellsIntoBlock(outputCells);
2656 }
2657
2658 /**
2659 * Applies the inverse Rijndael MixColumns for decryption to the input and

Callers 1

encryptMethod · 0.95

Calls 2

splitBlockIntoCellsMethod · 0.95
mergeCellsIntoBlockMethod · 0.95

Tested by

no test coverage detected