public void receive(byte[] data, int offset, int len) throws ConnectionException, TransportException { if (eof) { throw new ConnectionException("Getting data on EOF'ed stream"); } synchronized (buf) { buf.putRawBytes(data, offset, len); buf.notifyAll(); } // Potential fix for #203 (window consumed below 0). // This seems to be a race condition if we receive more data, while we're already sending a SSH_MSG_CHANNEL_WINDOW_ADJUST // And the window has not expanded yet. synchronized (win) { win.consume(len); } if (chan.getAutoExpand()) { checkWindow(); } }
/** * Private method used while putting new keys into use that will resize the key used to initialize the cipher to the * needed length. * * @param E the key to resize * @param blockSize the cipher block size * @param hash the hash algorithm * @param K the key exchange K parameter * @param H the key exchange H parameter * * @return the resized key */ private static byte[] resizedKey(byte[] E, int blockSize, Digest hash, BigInteger K, byte[] H) { while (blockSize > E.length) { Buffer.PlainBuffer buffer = new Buffer.PlainBuffer().putMPInt(K).putRawBytes(H).putRawBytes(E); hash.update(buffer.array(), 0, buffer.available()); byte[] foo = hash.digest(); byte[] bar = new byte[E.length + foo.length]; System.arraycopy(E, 0, bar, 0, E.length); System.arraycopy(foo, 0, bar, E.length, foo.length); E = bar; } return E; }
leftOvers.putRawBytes(packet.array(), packet.wpos(), leftOverBytes);
.putRawBytes(H) .putByte((byte) 0) // <placeholder> .putRawBytes(sessionID); final int pos = hashInput.available() - sessionID.length - 1; // Position of <placeholder>
.putRawBytes(H) .putByte((byte) 0) // <placeholder> .putRawBytes(sessionID); final int pos = hashInput.available() - sessionID.length - 1; // Position of <placeholder>
leftOvers.putRawBytes(packet.array(), packet.wpos(), leftOverBytes);
leftOvers.putRawBytes(packet.array(), packet.wpos(), leftOverBytes);
/** * Private method used while putting new keys into use that will resize the key used to initialize the cipher to the * needed length. * * @param E the key to resize * @param blockSize the cipher block size * @param hash the hash algorithm * @param K the key exchange K parameter * @param H the key exchange H parameter * * @return the resized key */ private static byte[] resizedKey(byte[] E, int blockSize, Digest hash, BigInteger K, byte[] H) { while (blockSize > E.length) { Buffer.PlainBuffer buffer = new Buffer.PlainBuffer().putMPInt(K).putRawBytes(H).putRawBytes(E); hash.update(buffer.array(), 0, buffer.available()); byte[] foo = hash.digest(); byte[] bar = new byte[E.length + foo.length]; System.arraycopy(E, 0, bar, 0, E.length); System.arraycopy(foo, 0, bar, E.length, foo.length); E = bar; } return E; }
/** * Private method used while putting new keys into use that will resize the key used to initialize the cipher to the * needed length. * * @param E the key to resize * @param blockSize the cipher block size * @param hash the hash algorithm * @param K the key exchange K parameter * @param H the key exchange H parameter * * @return the resized key */ private static byte[] resizedKey(byte[] E, int blockSize, Digest hash, BigInteger K, byte[] H) { while (blockSize > E.length) { Buffer.PlainBuffer buffer = new Buffer.PlainBuffer().putMPInt(K).putRawBytes(H).putRawBytes(E); hash.update(buffer.array(), 0, buffer.available()); byte[] foo = hash.digest(); byte[] bar = new byte[E.length + foo.length]; System.arraycopy(E, 0, bar, 0, E.length); System.arraycopy(foo, 0, bar, E.length, foo.length); E = bar; } return E; }
public void receive(byte[] data, int offset, int len) throws ConnectionException, TransportException { if (eof) { throw new ConnectionException("Getting data on EOF'ed stream"); } synchronized (buf) { buf.putRawBytes(data, offset, len); buf.notifyAll(); } // Potential fix for #203 (window consumed below 0). // This seems to be a race condition if we receive more data, while we're already sending a SSH_MSG_CHANNEL_WINDOW_ADJUST // And the window has not expanded yet. synchronized (win) { win.consume(len); } if (chan.getAutoExpand()) { checkWindow(); } }
public void receive(byte[] data, int offset, int len) throws ConnectionException, TransportException { if (eof) throw new ConnectionException("Getting data on EOF'ed stream"); synchronized (buf) { buf.putRawBytes(data, offset, len); buf.notifyAll(); } win.consume(len); if (chan.getAutoExpand()) checkWindow(); }
.putRawBytes(H) .putByte((byte) 0) // <placeholder> .putRawBytes(sessionID); final int pos = hashInput.available() - sessionID.length - 1; // Position of <placeholder>