Lines Matching refs:Nb
14 var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
15 var Nr = w.length/Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
18 for (var i=0; i<4*Nb; i++) state[i%4][Math.floor(i/4)] = input[i];
20 state = AddRoundKey(state, w, 0, Nb);
23 state = SubBytes(state, Nb);
24 state = ShiftRows(state, Nb);
25 state = MixColumns(state, Nb);
26 state = AddRoundKey(state, w, round, Nb);
29 state = SubBytes(state, Nb);
30 state = ShiftRows(state, Nb);
31 state = AddRoundKey(state, w, Nr, Nb);
33 var output = new Array(4*Nb); // convert state to 1-d array before returning [§3.4]
34 for (var i=0; i<4*Nb; i++) output[i] = state[i%4][Math.floor(i/4)];
39 function SubBytes(s, Nb) { // apply SBox to state S [§5.1.1] argument
41 for (var c=0; c<Nb; c++) s[r][c] = Sbox[s[r][c]];
47 function ShiftRows(s, Nb) { // shift row r of state S left by r bytes [§5.1.2] argument
50 for (var c=0; c<4; c++) t[c] = s[r][(c+r)%Nb]; // shift into temp copy
57 function MixColumns(s, Nb) { // combine bytes of each col of state S [§5.1.3] argument
75 function AddRoundKey(state, w, rnd, Nb) { // xor Round Key into state S [§5.1.4] argument
77 for (var c=0; c<Nb; c++) state[r][c] ^= w[rnd*4+c][r];
84 var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
88 var w = new Array(Nb*(Nr+1));
96 for (var i=Nk; i<(Nb*(Nr+1)); i++) {