public static void littleEndianToLong(byte[] bs, int off, long[] ns) { for (int i = 0; i < ns.length; ++i) { ns[i] = littleEndianToLong(bs, off); off += 8; } }
public static void littleEndianToLong(byte[] bs, int bsOff, long[] ns, int nsOff, int nsLen) { for (int i = 0; i < nsLen; ++i) { ns[nsOff + i] = littleEndianToLong(bs, bsOff); bsOff += 8; } }
private void KeccakAbsorb(byte[] data, int off) { int count = rate >> 6; for (int i = 0; i < count; ++i) { state[i] ^= Pack.littleEndianToLong(data, off); off += 8; } KeccakPermutation(); }
private void RotateLeft(long[] value) { int rotateBytesLength = 2 * value.length + 3; int bytesLength = value.length * (BITS_IN_WORD / BITS_IN_BYTE); byte[] bytes = new byte[value.length * BITS_IN_LONG / BITS_IN_BYTE]; Pack.longToLittleEndian(value, bytes, 0); byte[] buffer = new byte[rotateBytesLength]; System.arraycopy(bytes, 0, buffer, 0, rotateBytesLength); System.arraycopy(bytes, rotateBytesLength, bytes, 0, bytesLength - rotateBytesLength); System.arraycopy(buffer, 0, bytes, bytesLength - rotateBytesLength, rotateBytesLength); Pack.littleEndianToLong(bytes, 0, value); }
private void ShiftRows() { int row, col; int shift = -1; Pack.longToLittleEndian(internalState, internalStateBytes, 0); for (row = 0; row < BITS_IN_LONG / BITS_IN_BYTE; row++) { if (row % (BITS_IN_LONG / BITS_IN_BYTE / wordsInBlock) == 0) { shift += 1; } for (col = 0; col < wordsInBlock; col++) { tempInternalStateBytes[row + ((col + shift) % wordsInBlock) * BITS_IN_LONG / BITS_IN_BYTE] = internalStateBytes[row + col * BITS_IN_LONG / BITS_IN_BYTE]; } } Pack.littleEndianToLong(tempInternalStateBytes, 0, internalState); }
private void InvShiftRows() { int row, col; int shift = -1; Pack.longToLittleEndian(internalState, internalStateBytes, 0); for (row = 0; row < BITS_IN_LONG / BITS_IN_BYTE; row++) { if (row % (BITS_IN_LONG / BITS_IN_BYTE / wordsInBlock) == 0) { shift += 1; } for (col = 0; col < wordsInBlock; col++) { tempInternalStateBytes[row + col * BITS_IN_LONG / BITS_IN_BYTE] = internalStateBytes[row + ((col + shift) % wordsInBlock) * BITS_IN_LONG / BITS_IN_BYTE]; } } Pack.littleEndianToLong(tempInternalStateBytes, 0, internalState); }
public void init(CipherParameters params) throws IllegalArgumentException { if (!(params instanceof KeyParameter)) { throw new IllegalArgumentException("'params' must be an instance of KeyParameter"); } KeyParameter keyParameter = (KeyParameter)params; byte[] key = keyParameter.getKey(); if (key.length != 16) { throw new IllegalArgumentException("'params' must be a 128-bit key"); } this.k0 = Pack.littleEndianToLong(key, 0); this.k1 = Pack.littleEndianToLong(key, 8); reset(); }
for (int i = 0; i < full; ++i) state[i] ^= Pack.littleEndianToLong(dataQueue, off); off += 8; state[full] ^= Pack.littleEndianToLong(dataQueue, off) & mask;
m = Pack.littleEndianToLong(input, offset + i); processMessageWord(); for (; i < fullWords; i += 8) long n = Pack.littleEndianToLong(input, offset + i); m = (n << bits) | (m >>> -bits); processMessageWord();
public void init(boolean forEncryption, CipherParameters parameters) { if (!(parameters instanceof ParametersWithIV)) { throw new IllegalArgumentException("Invalid parameters passed"); } ParametersWithIV ivParam = (ParametersWithIV)parameters; parameters = ivParam.getParameters(); byte[] iv = ivParam.getIV(); /* * TODO We need to check what the rule is supposed to be for IVs that aren't exactly one block. * * Given general little-endianness, presumably a short IV should be right-padded with zeroes. */ if (iv.length != blockSize) { throw new IllegalArgumentException("Currently only support IVs of exactly one block"); } byte[] tweak = new byte[blockSize]; System.arraycopy(iv, 0, tweak, 0, blockSize); cipher.init(true, parameters); cipher.processBlock(tweak, 0, tweak, 0); cipher.init(forEncryption, parameters); Pack.littleEndianToLong(tweak, 0, tw_init); System.arraycopy(tw_init, 0, tw_current, 0, tw_init.length); counter = 0; }
Pack.littleEndianToLong(keyBytes, 0, workingKey);
tempLongBuffer[columnIndex] = Pack.littleEndianToLong(tempState2[columnIndex], 0);
rnd[j] = Pack.littleEndianToLong(bRnd, j * 8);
Pack.littleEndianToLong(in, inOff, internalState); Pack.littleEndianToLong(in, inOff, internalState);