public long seekTo(long position) { reset(); return skip(position); }
public void init( boolean forEncryption, //ignored by this CTR mode CipherParameters params) throws IllegalArgumentException { if (params instanceof ParametersWithIV) { ParametersWithIV ivParam = (ParametersWithIV)params; byte[] iv = ivParam.getIV(); System.arraycopy(iv, 0, IV, 0, IV.length); reset(); // if null it's an IV changed only. if (ivParam.getParameters() != null) { cipher.init(true, ivParam.getParameters()); } } else { throw new IllegalArgumentException("SIC mode requires ParametersWithIV"); } }
public void init( boolean forEncryption, //ignored by this CTR mode CipherParameters params) throws IllegalArgumentException { if (params instanceof ParametersWithIV) { ParametersWithIV ivParam = (ParametersWithIV)params; this.IV = Arrays.clone(ivParam.getIV()); if (blockSize < IV.length) { throw new IllegalArgumentException("CTR/SIC mode requires IV no greater than: " + blockSize + " bytes."); } int maxCounterSize = (8 > blockSize / 2) ? blockSize / 2 : 8; if (blockSize - IV.length > maxCounterSize) { throw new IllegalArgumentException("CTR/SIC mode requires IV of at least: " + (blockSize - maxCounterSize) + " bytes."); } // if null it's an IV changed only. if (ivParam.getParameters() != null) { cipher.init(true, ivParam.getParameters()); } reset(); } else { throw new IllegalArgumentException("CTR/SIC mode requires ParametersWithIV"); } }
private void reset( boolean clearMac) { cipher.reset(); mac.reset(); bufOff = 0; Arrays.fill(bufBlock, (byte)0); if (clearMac) { Arrays.fill(macBlock, (byte)0); } byte[] tag = new byte[blockSize]; tag[blockSize - 1] = cTAG; mac.update(tag, 0, blockSize); }
private void reset( boolean clearMac) { cipher.reset(); // TODO Redundant since the mac will reset it? mac.reset(); bufOff = 0; Arrays.fill(bufBlock, (byte)0); if (clearMac) { Arrays.fill(macBlock, (byte)0); } byte[] tag = new byte[blockSize]; tag[blockSize - 1] = hTAG; mac.update(tag, 0, blockSize); cipherInitialized = false; if (initialAssociatedText != null) { processAADBytes(initialAssociatedText, 0, initialAssociatedText.length); } }