Lines Matching defs:state

538 //       you would probably expect, as array[row][column]. The state arrays
539 // are 2d arrays of the form state[4][Nb].
638 // state information (see spec) and direction is string indicating whether
642 function byteSub(state, direction) {
646 for (var i = 0; i < 4; i++) { // Substitute for every byte in state
647 for (var j = 0; j < Nb; j++) { state[i][j] = S[state[i][j]]; }
653 function shiftRow(state, direction) {
656 state[i] = cyclicShiftLeft(state[i], shiftOffsets[Nb][i]);
658 state[i] = cyclicShiftLeft(state[i], Nb - shiftOffsets[Nb][i]);
668 function mixColumn(state, direction) {
674 b[i] = mult_GF256(state[i][j], 2) ^ // perform mixing
675 mult_GF256(state[(i+1)%4][j], 3) ^
676 state[(i+2)%4][j] ^
677 state[(i+3)%4][j];
679 b[i] = mult_GF256(state[i][j], 0xE) ^
680 mult_GF256(state[(i+1)%4][j], 0xB) ^
681 mult_GF256(state[(i+2)%4][j], 0xD) ^
682 mult_GF256(state[(i+3)%4][j], 9);
686 state[i][j] = b[i];
691 // Adds the current round key to the state information. Straightforward.
693 function addRoundKey(state, roundKey) {
695 state[0][j] ^= (roundKey[j] & 0xFF); // and XOR
696 state[1][j] ^= ((roundKey[j]>>8) & 0xFF);
697 state[2][j] ^= ((roundKey[j]>>16) & 0xFF);
698 state[3][j] ^= ((roundKey[j]>>24) & 0xFF);
743 function jcRound(state, roundKey) {
744 byteSub(state, "encrypt");
745 shiftRow(state, "encrypt");
746 mixColumn(state, "encrypt");
747 addRoundKey(state, roundKey);
750 function inverseRound(state, roundKey) {
751 addRoundKey(state, roundKey);
752 mixColumn(state, "decrypt");
753 shiftRow(state, "decrypt");
754 byteSub(state, "decrypt");
757 function finalRound(state, roundKey) {
758 byteSub(state, "encrypt");
759 shiftRow(state, "encrypt");
760 addRoundKey(state, roundKey);
763 function inverseFinalRound(state, roundKey){
764 addRoundKey(state, roundKey);
765 shiftRow(state, "decrypt");
766 byteSub(state, "decrypt");
862 var state = [];
865 state[0] = []; state[1] = [];
866 state[2] = []; state[3] = [];
868 state[0][j/4] = octets[j];
869 state[1][j/4] = octets[j+1];
870 state[2][j/4] = octets[j+2];
871 state[3][j/4] = octets[j+3];
873 return state;
1303 i = Math.floor(this.state / 67108862);
1305 // New state is sum of generators modulo one of their moduli
1307 this.state = Math.round((this.shuffle[i] + this.gen2) % 2147483563);
1313 return this.state;
1360 this.state = this.shuffle[0];
1484 var state = [];
1561 a = state[0];
1562 b = state[1];
1563 c = state[2];
1564 d = state[3];
1645 state[0] += a;
1646 state[1] += b;
1647 state[2] += c;
1648 state[3] += d;
1654 state[0] = 0x67452301;
1655 state[1] = 0xefcdab89;
1656 state[2] = 0x98badcfe;
1657 state[3] = 0x10325476;
1704 digestBits[i * 4 + j] = and(shr(state[i], (j * 8)) , 0xFF);