A = _S[i] = rotateLeft(_S[i] + A + B, 3); B = L[j] = rotateLeft(L[j] + A + B, A+B); i = (i+1) % _S.length; j = (j+1) % L.length;
A = _S[i] = rotateLeft(_S[i] + A + B, 3); B = L[j] = rotateLeft(L[j] + A + B, A+B); i = (i+1) % _S.length; j = (j+1) % L.length;
/** * Encrypt the given block starting at the given offset and place * the result in the provided buffer starting at the given offset. * <p> * @param in in byte buffer containing data to encrypt * @param inOff offset into src buffer * @param out out buffer where encrypted data is written * @param outOff offset into out buffer */ private int encryptBlock( byte[] in, int inOff, byte[] out, int outOff) { long A = bytesToWord(in, inOff) + _S[0]; long B = bytesToWord(in, inOff + bytesPerWord) + _S[1]; for (int i = 1; i <= _noRounds; i++) { A = rotateLeft(A ^ B, B) + _S[2*i]; B = rotateLeft(B ^ A, A) + _S[2*i+1]; } wordToBytes(A, out, outOff); wordToBytes(B, out, outOff + bytesPerWord); return 2 * bytesPerWord; }
/** * Encrypt the given block starting at the given offset and place * the result in the provided buffer starting at the given offset. * <p> * @param in in byte buffer containing data to encrypt * @param inOff offset into src buffer * @param out out buffer where encrypted data is written * @param outOff offset into out buffer */ private int encryptBlock( byte[] in, int inOff, byte[] out, int outOff) { long A = bytesToWord(in, inOff) + _S[0]; long B = bytesToWord(in, inOff + bytesPerWord) + _S[1]; for (int i = 1; i <= _noRounds; i++) { A = rotateLeft(A ^ B, B) + _S[2*i]; B = rotateLeft(B ^ A, A) + _S[2*i+1]; } wordToBytes(A, out, outOff); wordToBytes(B, out, outOff + bytesPerWord); return 2 * bytesPerWord; }