public int processBlock(byte[] in, int inOff, byte[] out, int outOff) throws DataLengthException, IllegalStateException { if (!initialised) { throw new IllegalStateException("Null engine not initialised"); } if ((inOff + blockSize) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + blockSize) > out.length) { throw new OutputLengthException("output buffer too short"); } for (int i = 0; i < blockSize; ++i) { out[outOff + i] = in[inOff + i]; } return blockSize; }
protected int engineDoFinal( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws IllegalBlockSizeException, BadPaddingException, ShortBufferException { int len = 0; if (outputOffset + engineGetOutputSize(inputLen) > output.length) { throw new ShortBufferException("output buffer too short for input."); } try { if (inputLen != 0) { len = cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); } return (len + cipher.doFinal(output, outputOffset + len)); } catch (OutputLengthException e) { throw new IllegalBlockSizeException(e.getMessage()); } catch (DataLengthException e) { throw new IllegalBlockSizeException(e.getMessage()); } }
public int processBlock(byte[] in, int inOff, byte[] out, int outOff) throws DataLengthException, IllegalStateException { if (!initialised) { throw new IllegalStateException("Null engine not initialised"); } if ((inOff + blockSize) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + blockSize) > out.length) { throw new OutputLengthException("output buffer too short"); } for (int i = 0; i < blockSize; ++i) { out[outOff + i] = in[inOff + i]; } return blockSize; }
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff) { if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } for (int i = 0; i < len; i++) { s = P[(s + P[n & 0xff]) & 0xff]; byte z = P[(P[(P[s & 0xff]) & 0xff] + 1) & 0xff]; // encryption byte temp = P[n & 0xff]; P[n & 0xff] = P[s & 0xff]; P[s & 0xff] = temp; n = (byte) ((n + 1) & 0xff); // xor out[i + outOff] = (byte) (in[i + inOff] ^ z); } return len; }
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff) { if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } for (int i = 0; i < len; i++) { s = P[(s + P[n & 0xff]) & 0xff]; byte z = P[(P[(P[s & 0xff]) & 0xff] + 1) & 0xff]; // encryption byte temp = P[n & 0xff]; P[n & 0xff] = P[s & 0xff]; P[s & 0xff] = temp; n = (byte) ((n + 1) & 0xff); // xor out[i + outOff] = (byte) (in[i + inOff] ^ z); } return len; }
public int processBytes( byte[] in, int inOff, int len, byte[] out, int outOff) { if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } for (int i = 0; i < len ; i++) { x = (x + 1) & 0xff; y = (engineState[x] + y) & 0xff; // swap byte tmp = engineState[x]; engineState[x] = engineState[y]; engineState[y] = tmp; // xor out[i+outOff] = (byte)(in[i + inOff] ^ engineState[(engineState[x] + engineState[y]) & 0xff]); } return len; }
public int processBytes( byte[] in, int inOff, int len, byte[] out, int outOff) { if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } for (int i = 0; i < len ; i++) { x = (x + 1) & 0xff; y = (engineState[x] + y) & 0xff; // swap byte tmp = engineState[x]; engineState[x] = engineState[y]; engineState[y] = tmp; // xor out[i+outOff] = (byte)(in[i + inOff] ^ engineState[(engineState[x] + engineState[y]) & 0xff]); } return len; }
public int processBlock(byte[] in, int inOff, byte[] out, int outOff) throws DataLengthException, IllegalStateException { if (subKeys == null) { throw new IllegalStateException("GOST3412_2015 engine not initialised"); } if ((inOff + BLOCK_SIZE) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + BLOCK_SIZE) > out.length) { throw new OutputLengthException("output buffer too short"); } GOST3412_2015Func(in, inOff, out, outOff); return BLOCK_SIZE; }
public int processBlock( byte[] in, int inOff, byte[] out, int outOff) { if (workingKey == null) { throw new IllegalStateException("GOST28147 engine not initialised"); } if ((inOff + BLOCK_SIZE) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + BLOCK_SIZE) > out.length) { throw new OutputLengthException("output buffer too short"); } GOST28147Func(workingKey, in, inOff, out, outOff); return BLOCK_SIZE; }
private void outputBlock(byte[] output, int offset) { if (output.length < (offset + BLOCK_SIZE)) { throw new OutputLengthException("Output buffer too short"); } if (totalLength == 0) { initCipher(); } gCTRBlock(bufBlock, output, offset); if (forEncryption) { bufOff = 0; } else { System.arraycopy(bufBlock, BLOCK_SIZE, bufBlock, 0, macSize); bufOff = macSize; } }
public int processBlock( byte[] in, int inOff, byte[] out, int outOff) { if (workingKey == null) { throw new IllegalStateException("IDEA engine not initialised"); } if ((inOff + BLOCK_SIZE) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + BLOCK_SIZE) > out.length) { throw new OutputLengthException("output buffer too short"); } ideaFunc(workingKey, in, inOff, out, outOff); return BLOCK_SIZE; }
public int processBytes(byte[] input, int inOff, int len, byte[] output, int outOff) { if (input.length - inOff < len) { throw new DataLengthException("Input buffer too short"); } if (output.length - inOff < len) { throw new OutputLengthException("Output buffer too short"); } if (len % blockSize != 0) { throw new IllegalArgumentException("Partial blocks not supported"); } for (int pos = 0; pos < len; pos += blockSize) { processBlock(input, inOff + pos, output, outOff + pos); } return len; }
public int processBlock( byte[] in, int inOff, byte[] out, int outOff) { if (workingKey == null) { throw new IllegalStateException("DES engine not initialised"); } if ((inOff + BLOCK_SIZE) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + BLOCK_SIZE) > out.length) { throw new OutputLengthException("output buffer too short"); } desFunc(workingKey, in, inOff, out, outOff); return BLOCK_SIZE; }
public int processBlock( byte[] in, int inOff, byte[] out, int outOff) { if (workingKey == null) { throw new IllegalStateException("DES engine not initialised"); } if ((inOff + BLOCK_SIZE) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + BLOCK_SIZE) > out.length) { throw new OutputLengthException("output buffer too short"); } desFunc(workingKey, in, inOff, out, outOff); return BLOCK_SIZE; }
public int processBlock( byte[] in, int inOff, byte[] out, int outOff) { if (workingKey == null) { throw new IllegalStateException("GOST28147 engine not initialised"); } if ((inOff + BLOCK_SIZE) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + BLOCK_SIZE) > out.length) { throw new OutputLengthException("output buffer too short"); } GOST28147Func(workingKey, in, inOff, out, outOff); return BLOCK_SIZE; }
public int processBlock( byte[] in, int inOff, byte[] out, int outOff) { if (workingKey == null) { throw new IllegalStateException("IDEA engine not initialised"); } if ((inOff + BLOCK_SIZE) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + BLOCK_SIZE) > out.length) { throw new OutputLengthException("output buffer too short"); } ideaFunc(workingKey, in, inOff, out, outOff); return BLOCK_SIZE; }
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff) throws DataLengthException { if (inOff + len > in.length) { throw new DataLengthException("input buffer too small"); } if (outOff + len > out.length) { throw new OutputLengthException("output buffer too short"); } int inStart = inOff; int inEnd = inOff + len; int outStart = outOff; while (inStart < inEnd) { out[outStart++] = calculateByte(in[inStart++]); } return len; }
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff) throws DataLengthException { if (!initialised) { throw new IllegalStateException(getAlgorithmName() + " not initialised"); } if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } for (int i = 0; i < len; i++) { out[outOff + i] = (byte)(in[inOff + i] ^ getByte()); } return len; }
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff) throws DataLengthException { if (!initialised) { throw new IllegalStateException(getAlgorithmName() + " not initialised"); } if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } for (int i = 0; i < len; i++) { out[outOff + i] = (byte)(in[inOff + i] ^ getByte()); } return len; }
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff) throws DataLengthException { if (!initialised) { throw new IllegalStateException(getAlgorithmName() + " not initialised"); } if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + len) > out.length) { throw new OutputLengthException("output buffer too short"); } for (int i = 0; i < len; i++) { out[outOff + i] = (byte)(in[inOff + i] ^ getByte()); } return len; }