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];
throw new DataLengthException("output buffer too small");
/** * 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; }
/** * 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; }
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; }
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; }
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; }
public void update(byte[] in, int inOff, int len) throws DataLengthException, IllegalStateException { if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } for (int i = 0; i < len; i++) { update(in[i]); } } }
public void update(byte[] in, int inOff, int len) throws DataLengthException, IllegalStateException { if ((inOff + len) > in.length) { throw new DataLengthException("input buffer too short"); } for (int i = 0; i < len; i++) { update(in[inOff + i]); } } }
public void update(byte[] in, int inOff, int len) throws DataLengthException, IllegalStateException { if (in.length - inOff < len) { throw new DataLengthException("Input buffer too short"); } if (paddedKey == null) { throw new IllegalStateException(getAlgorithmName() + " not initialised"); } engine.update(in, inOff, len); inputLength += len; }
public int processBlock( byte[] in, int inOff, byte[] out, int outOff) { if (!_initialised) { throw new IllegalStateException(getAlgorithmName()+" not initialised"); } if ((inOff + genericSize) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + genericSize) > out.length) { throw new DataLengthException("output buffer too short"); } return (_forEncryption) ? encryptBlock(in, inOff, out, outOff) : decryptBlock(in, inOff, out, outOff); }
/** * Generate a commitment for the passed in message. * * @param message the message to be committed to, * @return a Commitment */ public Commitment commit(byte[] message) { if (message.length > byteLength / 2) { throw new DataLengthException("Message to be committed to too large for digest."); } byte[] w = new byte[byteLength - message.length]; random.nextBytes(w); return new Commitment(w, calculateCommitment(w, message)); }
/** * Generate a commitment for the passed in message. * * @param message the message to be committed to, * @return a Commitment */ public Commitment commit(byte[] message) { if (message.length > byteLength / 2) { throw new DataLengthException("Message to be committed to too large for digest."); } byte[] w = new byte[byteLength - message.length]; random.nextBytes(w); return new Commitment(w, calculateCommitment(w, message)); }
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff) throws DataLengthException { initCipher(); if (in.length < (inOff + len)) { throw new DataLengthException("Input buffer too short"); } int resultLen = 0; for (int i = 0; i != len; i++) { resultLen += process(in[inOff + i], out, outOff + resultLen); } return resultLen; }
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 doFinal(byte[] out, int outOff) throws DataLengthException, IllegalStateException { if (bufOff % buf.length != 0) { throw new DataLengthException("input must be a multiple of blocksize"); } //Last block xor(c, 0, buf, 0, cTemp); xor(cTemp, 0, kDelta, 0, c); engine.processBlock(c, 0, c, 0); if (macSize + outOff > out.length) { throw new OutputLengthException("output buffer too short"); } System.arraycopy(c, 0, out, outOff, macSize); return macSize; }
public int processBlock( byte[] in, int inOff, byte[] out, int outOff) { if (!_initialised) { throw new IllegalStateException(getAlgorithmName()+" 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"); } return (_forEncryption) ? encryptBlock(in, inOff, out, outOff) : decryptBlock(in, inOff, out, outOff); }
/** * Return true if the passed in commitment represents a commitment to the passed in message. * * @param commitment a commitment previously generated. * @param message the message that was expected to have been committed to. * @return true if commitment matches message, false otherwise. */ public boolean isRevealed(Commitment commitment, byte[] message) { if (message.length + commitment.getSecret().length != byteLength) { throw new DataLengthException("Message and witness secret lengths do not match."); } byte[] calcCommitment = calculateCommitment(commitment.getSecret(), message); return Arrays.constantTimeAreEqual(commitment.getCommitment(), calcCommitment); }
/** * Return true if the passed in commitment represents a commitment to the passed in message. * * @param commitment a commitment previously generated. * @param message the message that was expected to have been committed to. * @return true if commitment matches message, false otherwise. */ public boolean isRevealed(Commitment commitment, byte[] message) { if (message.length + commitment.getSecret().length != byteLength) { throw new DataLengthException("Message and witness secret lengths do not match."); } byte[] calcCommitment = calculateCommitment(commitment.getSecret(), message); return Arrays.constantTimeAreEqual(commitment.getCommitment(), calcCommitment); }
public int processBlock(byte[] in, int inOff, byte[] out, int outOff) throws DataLengthException, IllegalStateException { if (in.length - inOff < getBlockSize()) { throw new DataLengthException("input buffer too short"); } if (out.length - outOff < getBlockSize()) { throw new OutputLengthException("output buffer too short"); } processBytes(in, inOff, getBlockSize(), out, outOff); return getBlockSize(); }