3.1.5 Mapping to libassh components
Here is how the ssh2 protocol architecture outlined above is mapped to software components in the library:
Transport layer implementation [link]
The transport layer is implemented in the library core and relies on algorithm modules for cryptographic processing of the packets and for data compression. It extracts packet objects from the incoming ssh2 stream and also generates the outgoing ssh2 stream from packet objects present in the transmit queue. This layer handles some of the incoming messages and dispatches other messages either to the running key-exchange method or to the running service. Transport related declarations can be found in assh/assh_transport.h.
Key-exchange and service implementations [link]
The key-exchange methods and services both have their own module interface. Among all module interfaces defined, only these two are designed to handle packet exchanges and may report events to the application. Related declarations can be found in assh/assh_kex.h and assh/assh_service.h.
User authentication implementation [link]
The User Authentication Protocol use the service module interface. There are actually two separate modules that implement the server and client sides of the service. Related declarations can be found in assh/assh_userauth_client.h and assh/assh_userauth_server.h.
Connection protocol implementation [link]
The Connection Protocol also use the service module interface. Because this part of the protocol is symmetric, there is a single module that implements both, the client and server sides.
The module implements the generic request and channel mechanisms specified in sections 4 and 5 of rfc4254 and nothing more. The module reports events that allow the application to handle incoming request and channel related messages. It also provides functions to send requests and manage channels but it does not care about the types of request and channel used. It makes no difference if those have a standard type or are private extensions. The related API is described in the Channels and requests section and the related declarations can be found in assh/assh_connection.h.
Section 6 and 7 of the same specification describe some standard channel and request types that support interactive sessions and port forwarding respectively. Because implementation of these features is tightly coupled with both, the operating system and usage, handling of these features is left to the application. Some parsing functions and a basic client state machine for interactive sessions is provided as helper functions as shown in most examples. The related declarations can be found in assh/helper_interactive.h and assh/helper_portfwd.h.