Files
aes/utils/expandKeyFake.ts
2026-06-24 16:28:42 +02:00

23 lines
737 B
TypeScript

export const expandKeyFake = (key: number[][]): number[][][] => {
/**
* @param {string} key - A string of 128, 192, or 256 bits.
* @returns {string[]} An array of round keys.
*/
const N_k = key[0].length // Number of columns in the key matrix (4 for 128-bit, 6 for 192-bit, 8 for 256-bit)
const N_r = N_k + 6 // Number of rounds (10 for 128-bit, 12 for 192-bit, 14 for 256-bit)
const totalKeys = 4 * (N_r + 1) // Total number of 4-byte words required
const expandedKeys: number[][][] = []
for (let i = 0;i < totalKeys / 4;i++) {
const matrix: number[][] = [
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
]
expandedKeys.push(matrix)
}
return expandedKeys
}