public int generateBytes(byte[] out, int outOff, int len) throws DataLengthException, IllegalArgumentException { if(out.length - len < outOff) { throw new DataLengthException("output buffer too small"); } else { byte[] hashBuf = new byte[this.hLen];
protected int engineUpdate( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException { if (outputOffset + inputLen > output.length) { throw new ShortBufferException("output buffer too short for input."); } try { cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); return inputLen; } catch (DataLengthException e) { // should never happen throw new IllegalStateException(e.getMessage()); } }
protected int engineUpdate( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException { if (outputOffset + cipher.getUpdateOutputSize(inputLen) > output.length) { throw new ShortBufferException("output buffer too short for input."); } try { return cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); } catch (DataLengthException e) { // should never occur throw new IllegalStateException(e.toString()); } }
protected int engineUpdate( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException { try { cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); return inputLen; } catch (DataLengthException e) { throw new ShortBufferException(e.getMessage()); } }
throw new DataLengthException("output buffer too small");
protected int engineUpdate( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException { try { cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); return inputLen; } catch (DataLengthException e) { throw new ShortBufferException(e.getMessage()); } }
/** * add another byte for processing. * * @param in the input byte. */ public void processByte( byte in) { if (bufOff >= buf.length) { throw new DataLengthException("attempt to process message too long for cipher"); } buf[bufOff++] = in; }
protected byte[] engineDoFinal( byte[] input, int inputOffset, int inputLen) throws IllegalBlockSizeException, BadPaddingException { int len = 0; byte[] tmp = new byte[engineGetOutputSize(inputLen)]; if (inputLen != 0) { len = cipher.processBytes(input, inputOffset, inputLen, tmp, 0); } try { len += cipher.doFinal(tmp, len); } catch (DataLengthException e) { throw new IllegalBlockSizeException(e.getMessage()); } if (len == tmp.length) { return tmp; } byte[] out = new byte[len]; System.arraycopy(tmp, 0, out, 0, len); return out; }
/** * add another byte for processing. * * @param in the input byte. */ public void processByte( byte in) { if (bufOff >= buf.length) { throw new DataLengthException("attempt to process message too long for cipher"); } buf[bufOff++] = in; }
protected byte[] engineDoFinal( byte[] input, int inputOffset, int inputLen) throws IllegalBlockSizeException, BadPaddingException { int len = 0; byte[] tmp = new byte[engineGetOutputSize(inputLen)]; if (inputLen != 0) { len = cipher.processBytes(input, inputOffset, inputLen, tmp, 0); } try { len += cipher.doFinal(tmp, len); } catch (DataLengthException e) { throw new IllegalBlockSizeException(e.getMessage()); } catch (InvalidCipherTextException e) { throw new BadPaddingException(e.getMessage()); } byte[] out = new byte[len]; System.arraycopy(tmp, 0, out, 0, len); return out; }
public void 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 DataLengthException("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); } }
throw new IllegalBlockSizeException(e.getMessage());
public void 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 DataLengthException("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]); } }
protected byte[] engineDoFinal( byte[] input, int inputOffset, int inputLen) throws IllegalBlockSizeException, BadPaddingException { int len = 0; byte[] tmp = new byte[engineGetOutputSize(inputLen)]; if (inputLen != 0) { len = cipher.processBytes(input, inputOffset, inputLen, tmp, 0); } try { len += cipher.doFinal(tmp, len); } catch (DataLengthException e) { throw new IllegalBlockSizeException(e.getMessage()); } catch (InvalidCipherTextException e) { throw new BadPaddingException(e.getMessage()); } byte[] out = new byte[len]; System.arraycopy(tmp, 0, out, 0, len); return out; }
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 + BLOCK_SIZE) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + BLOCK_SIZE) > out.length) { throw new DataLengthException("output buffer too short"); } for (int i = 0; i < BLOCK_SIZE; ++i) { out[outOff + i] = in[inOff + i]; } return BLOCK_SIZE; }
throw new IllegalBlockSizeException(e.getMessage());
public int processBytes(byte[] in, int inOff, int inLen, byte[] out, int outOff) throws DataLengthException, IllegalStateException { if (in.length < (inOff + inLen)) { throw new DataLengthException("input buffer too short"); } data.write(in, inOff, inLen); return 0; }
protected int engineDoFinal( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws IllegalBlockSizeException, BadPaddingException { int len = 0; if (inputLen != 0) { len = cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); } try { return len + cipher.doFinal(output, outputOffset + len); } catch (DataLengthException e) { throw new IllegalBlockSizeException(e.getMessage()); } catch (InvalidCipherTextException e) { throw new BadPaddingException(e.getMessage()); } }
public int processBytes(byte[] in, int inOff, int inLen, byte[] out, int outOff) throws DataLengthException, IllegalStateException { if (in.length < (inOff + inLen)) { throw new DataLengthException("Input buffer too short"); } data.write(in, inOff, inLen); return 0; }
protected int engineDoFinal( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws IllegalBlockSizeException, BadPaddingException { int len = 0; if (inputLen != 0) { len = cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); } try { return len + cipher.doFinal(output, outputOffset + len); } catch (DataLengthException e) { throw new IllegalBlockSizeException(e.getMessage()); } catch (InvalidCipherTextException e) { throw new BadPaddingException(e.getMessage()); } }