private int decryptBlock( byte[] in, int inOff, byte[] out, int outOff) { long A = bytesToWord(in, inOff); long B = bytesToWord(in, inOff + bytesPerWord); for (int i = _noRounds; i >= 1; i--) { B = rotateRight(B - _S[2*i+1], A) ^ A; A = rotateRight(A - _S[2*i], B) ^ B; } wordToBytes(A - _S[0], out, outOff); wordToBytes(B - _S[1], out, outOff + bytesPerWord); return 2 * bytesPerWord; }
private int decryptBlock( byte[] in, int inOff, byte[] out, int outOff) { long A = bytesToWord(in, inOff); long B = bytesToWord(in, inOff + bytesPerWord); for (int i = _noRounds; i >= 1; i--) { B = rotateRight(B - _S[2*i+1], A) ^ A; A = rotateRight(A - _S[2*i], B) ^ B; } wordToBytes(A - _S[0], out, outOff); wordToBytes(B - _S[1], 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; }
/** * 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; }