Class Decoder
java.lang.Object
net.schmizz.sshj.transport.Converter
net.schmizz.sshj.transport.Decoder
Decodes packets from the SSH binary protocol per the current algorithms.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SSHPacketBuffer where as-yet undecoded data livesprivate final org.slf4j.Loggerprivate byte[]MAC result is stored hereprivate static final intprivate intHow many bytes do we need, before a call to decode() can succeed at decoding at least packet length, OR the whole packet?private final SSHPacketHandlerWhat we pass decoded packets toprivate int-1 if packet length not yet been decoded, else the packet lengthprivate final SSHPacketUsed in case compression is active to store the uncompressed dataFields inherited from class Converter
authed, authMode, cipher, cipherSize, compression, etm, mac, seq -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckMAC(byte[] data) private voidcheckPacketLength(int len) private intdecode()Returns advised number of bytes that should be made available in decoderBuffer before the method should be called again.private SSHPacketprivate voiddecryptBuffer(int offset, int length) private intprivate int(package private) Compression.Mode(package private) int(package private) intreceived(byte[] b, int len) Addslenbytes frombto the decoder buffer.(package private) voidsetAlgorithms(Cipher cipher, MAC mac, Compression compression) Methods inherited from class Converter
getSequenceNumber, isSequenceNumberAtMax, resetSequenceNumber, setAuthenticated, usingCompression
-
Field Details
-
MAX_PACKET_LEN
private static final int MAX_PACKET_LEN- See Also:
-
log
private final org.slf4j.Logger log -
packetHandler
What we pass decoded packets to -
inputBuffer
Buffer where as-yet undecoded data lives -
uncompressBuffer
Used in case compression is active to store the uncompressed data -
macResult
private byte[] macResultMAC result is stored here -
packetLength
private int packetLength-1 if packet length not yet been decoded, else the packet length -
needed
private int neededHow many bytes do we need, before a call to decode() can succeed at decoding at least packet length, OR the whole packet?
-
-
Constructor Details
-
Decoder
Decoder(Transport packetHandler)
-
-
Method Details
-
decode
Returns advised number of bytes that should be made available in decoderBuffer before the method should be called again.- Returns:
- number of bytes needed before further decoding possible
- Throws:
SSHException
-
checkMAC
- Throws:
TransportException
-
decompressed
- Throws:
TransportException
-
decryptLengthAAD
- Throws:
TransportException
-
decryptLength
- Throws:
TransportException
-
decryptBuffer
private void decryptBuffer(int offset, int length) -
checkPacketLength
- Throws:
TransportException
-
received
Addslenbytes frombto the decoder buffer. When a packet has been successfully decoded, hooks in toSSHPacketHandler.handle(Message, SSHPacket)of theSSHPacketHandlerthis decoder was initialized with. Returns the number of bytes expected in the next call in order to decode the packet length, and if the packet length has already been decoded; to decode the payload. This number is accurate and should be taken to heart.- Throws:
SSHException
-
setAlgorithms
- Overrides:
setAlgorithmsin classConverter
-
getCompressionType
Compression.Mode getCompressionType()- Specified by:
getCompressionTypein classConverter
-
getMaxPacketLength
int getMaxPacketLength()
-