Lines Matching defs:block

770 // block, an array of bytes representing a plaintext block, and expandedKey,
772 // keyExpansion(). The ciphertext block is returned as an array of bytes.
774 function encrypt(block, expandedKey) {
776 if (!block || block.length*8 != blockSizeInBits) { return; }
779 block = packBytes(block);
780 addRoundKey(block, expandedKey);
781 for (i=1; i<Nr; i++) { jcRound(block, expandedKey.slice(Nb*i, Nb*(i+1))); }
782 finalRound(block, expandedKey.slice(Nb*Nr));
783 return unpackBytes(block);
787 // block, an array of bytes representing a ciphertext block, and expandedKey,
789 // keyExpansion(). The decrypted block is returned as an array of bytes.
791 function decrypt(block, expandedKey) {
793 if (!block || block.length*8 != blockSizeInBits) { return; }
796 block = packBytes(block);
797 inverseFinalRound(block, expandedKey.slice(Nb*Nr));
799 inverseRound(block, expandedKey.slice(Nb*i, Nb*(i+1)));
801 addRoundKey(block, expandedKey);
802 return unpackBytes(block);
893 // and pads it with pseudorandom bytes if its length is not a multiple of the block
900 var bpb = blockSizeInBits / 8; // bytes per block
947 var bpb = blockSizeInBits / 8; // bytes per block
965 for (var block = 0; block < plaintext.length / bpb; block++) {
966 aBlock = plaintext.slice(block * bpb, (block + 1) * bpb);
969 aBlock[i] ^= ct[(block * bpb) + i];
991 var bpb = blockSizeInBits / 8; // bytes per block
993 var aBlock; // a decrypted block
994 var block; // current block number
1003 for (block=(ciphertext.length / bpb)-1; block>0; block--) {
1005 decrypt(ciphertext.slice(block*bpb,(block+1)*bpb), expandedKey);
1008 pt[(block-1)*bpb + i] = aBlock[i] ^ ciphertext[(block-1)*bpb + i];
1015 // do last block if ECB (skips the IV in CBC)