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; } }
private static void xorWithInput(long[] z, byte[] buf, int off) { for (int i = 0; i < z.length; ++i) { z[i] ^= Pack.littleEndianToLong(buf, off); off += 8; } }
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; } }
void fromBytes(byte[] input) { if (input.length != ARGON2_BLOCK_SIZE) { throw new IllegalArgumentException("input shorter than blocksize"); } for (int i = 0; i < v.length; i++) { v[i] = Pack.littleEndianToLong(input, i * 8); } }
if (salt != null) chainValue[4] ^= Pack.littleEndianToLong(salt, 0); chainValue[5] ^= Pack.littleEndianToLong(salt, 8); if (personalization != null) chainValue[6] ^= Pack.littleEndianToLong(personalization, 0); chainValue[7] ^= Pack.littleEndianToLong(personalization, 8);
XTSTweak next() { long lo = Pack.littleEndianToLong(tweak, 0); long hi = Pack.littleEndianToLong(tweak, 8); long fdbk = (hi & MSB) == 0 ? 0L : FDBK; hi = (hi << 1) | (lo >>> 63); lo = (lo << 1) ^ fdbk; Pack.longToLittleEndian(lo, tweak, 0); Pack.longToLittleEndian(hi, tweak, 8); return this; } }
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(); }
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(); }
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(); }
private void padAndSwitchToSqueezingPhase() { dataQueue[bitsInQueue >> 3] |= (byte)(1L << (bitsInQueue & 7)); if (++bitsInQueue == rate) { KeccakAbsorb(dataQueue, 0); bitsInQueue = 0; } { int full = bitsInQueue >> 6, partial = bitsInQueue & 63; int off = 0; for (int i = 0; i < full; ++i) { state[i] ^= Pack.littleEndianToLong(dataQueue, off); off += 8; } if (partial > 0) { long mask = (1L << partial) - 1L; state[full] ^= Pack.littleEndianToLong(dataQueue, off) & mask; } state[(rate - 1) >> 6] ^= (1L << 63); } KeccakPermutation(); KeccakExtract(); bitsInQueue = rate; squeezing = true; }
private void processBlock(byte[] input, int inOff) { int pos = inOff; for (int col = 0; col < columns; ++col) { long word = Pack.littleEndianToLong(input, pos); pos += 8; tempState1[col] = state[col] ^ word; tempState2[col] = word; } P(tempState1); Q(tempState2); for (int col = 0; col < columns; ++col) { state[col] ^= tempState1[col] ^ tempState2[col]; } }
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();
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);
private void decryptBlock_128(byte[] in, int inOff, byte[] out, int outOff) long c0 = Pack.littleEndianToLong(in, inOff); long c1 = Pack.littleEndianToLong(in, inOff + 8);
private void encryptBlock_128(byte[] in, int inOff, byte[] out, int outOff) long c0 = Pack.littleEndianToLong(in, inOff); long c1 = Pack.littleEndianToLong(in, inOff + 8);
private void compress(byte[] message, int messagePos) { initializeInternalState(); long[] m = new long[16]; for (int j = 0; j < 16; j++) { m[j] = Pack.littleEndianToLong(message, messagePos + j * 8); } for (int round = 0; round < ROUNDS; round++) { // G apply to columns of internalState:m[blake2b_sigma[round][2 * // blockPos]] /+1 G(m[blake2b_sigma[round][0]], m[blake2b_sigma[round][1]], 0, 4, 8, 12); G(m[blake2b_sigma[round][2]], m[blake2b_sigma[round][3]], 1, 5, 9, 13); G(m[blake2b_sigma[round][4]], m[blake2b_sigma[round][5]], 2, 6, 10, 14); G(m[blake2b_sigma[round][6]], m[blake2b_sigma[round][7]], 3, 7, 11, 15); // G apply to diagonals of internalState: G(m[blake2b_sigma[round][8]], m[blake2b_sigma[round][9]], 0, 5, 10, 15); G(m[blake2b_sigma[round][10]], m[blake2b_sigma[round][11]], 1, 6, 11, 12); G(m[blake2b_sigma[round][12]], m[blake2b_sigma[round][13]], 2, 7, 8, 13); G(m[blake2b_sigma[round][14]], m[blake2b_sigma[round][15]], 3, 4, 9, 14); } // update chain values: for (int offset = 0; offset < chainValue.length; offset++) { chainValue[offset] = chainValue[offset] ^ internalState[offset] ^ internalState[offset + 8]; } }
engine.processBlock(temp, 0, temp, 0); long[] H = new long[blockSize >>> 3]; Pack.littleEndianToLong(temp, 0, H); multiplier.init(H); Arrays.fill(temp, (byte)0);