pub struct Session {
pub session_id: SessionId,
pub signing_key: Vec<u8>,
pub encryption_key: Option<Vec<u8>>,
pub decryption_key: Option<Vec<u8>>,
pub signing_algorithm: SigningAlgorithm,
pub should_sign: bool,
pub should_encrypt: bool,
}Expand description
An authenticated SMB2 session with derived keys.
Fields§
§session_id: SessionIdThe session ID assigned by the server.
signing_key: Vec<u8>Key used to sign outgoing messages.
encryption_key: Option<Vec<u8>>Key used to encrypt outgoing messages (SMB 3.x).
decryption_key: Option<Vec<u8>>Key used to decrypt incoming messages (SMB 3.x).
signing_algorithm: SigningAlgorithmThe signing algorithm to use.
should_sign: boolWhether outgoing messages should be signed.
should_encrypt: boolWhether outgoing messages should be encrypted.
Implementations§
Source§impl Session
impl Session
Sourcepub async fn setup(
conn: &mut Connection,
username: &str,
password: &str,
domain: &str,
) -> Result<Session>
pub async fn setup( conn: &mut Connection, username: &str, password: &str, domain: &str, ) -> Result<Session>
Perform the multi-round-trip SESSION_SETUP exchange.
Steps:
- Send NTLM NEGOTIATE_MESSAGE in SESSION_SETUP.
- Receive STATUS_MORE_PROCESSING_REQUIRED with CHALLENGE_MESSAGE.
- Update preauth hash with request+response.
- Send NTLM AUTHENTICATE_MESSAGE in SESSION_SETUP.
- Receive STATUS_SUCCESS with session flags.
- Update preauth hash with request+response.
- Derive signing/encryption keys.
- Activate signing on the connection.
Sourcepub async fn setup_kerberos_from_ccache(
conn: &mut Connection,
credentials: &KerberosCredentials,
server_hostname: &str,
ccache: &CCache,
) -> Result<Session>
pub async fn setup_kerberos_from_ccache( conn: &mut Connection, credentials: &KerberosCredentials, server_hostname: &str, ccache: &CCache, ) -> Result<Session>
Perform Kerberos-based SESSION_SETUP.
Authenticates against the KDC first (AS + TGS), then sends the SPNEGO-wrapped AP-REQ in SESSION_SETUP. Handles both single-round (STATUS_SUCCESS) and mutual-auth (STATUS_MORE_PROCESSING_REQUIRED) flows.
The session key comes from the Kerberos TGS exchange, not from the SMB server response. Perform Kerberos-based SESSION_SETUP using a credential cache.
Reads cached tickets from the ccache. If a service ticket for
cifs/<server_hostname> is cached, uses it directly (no KDC needed).
If only a TGT is cached, does a TGS exchange for the service ticket.
Sourcepub async fn setup_kerberos(
conn: &mut Connection,
credentials: &KerberosCredentials,
server_hostname: &str,
) -> Result<Session>
pub async fn setup_kerberos( conn: &mut Connection, credentials: &KerberosCredentials, server_hostname: &str, ) -> Result<Session>
Perform Kerberos-based SESSION_SETUP.
Authenticates against the KDC first (AS + TGS), then sends the SPNEGO-wrapped AP-REQ in SESSION_SETUP. Handles both single-round (STATUS_SUCCESS) and mutual-auth (STATUS_MORE_PROCESSING_REQUIRED) flows.
The session key comes from the Kerberos TGS exchange, not from the SMB server response.