From 5f25567c2efd24a27bbb30f35a593bd3d9c3784f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 1 Aug 2012 08:59:01 +0200 Subject: libcli/smb: add smbXcli_session_application_key() metze --- libcli/smb/smbXcli_base.c | 30 ++++++++++++++++++++++++++++++ libcli/smb/smbXcli_base.h | 3 +++ 2 files changed, 33 insertions(+) diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c index ff24688f08..ea6f647b76 100644 --- a/libcli/smb/smbXcli_base.c +++ b/libcli/smb/smbXcli_base.c @@ -4294,6 +4294,36 @@ struct smbXcli_session *smbXcli_session_create(TALLOC_CTX *mem_ctx, return session; } +NTSTATUS smbXcli_session_application_key(struct smbXcli_session *session, + TALLOC_CTX *mem_ctx, + DATA_BLOB *key) +{ + const DATA_BLOB *application_key; + + *key = data_blob_null; + + if (session->conn == NULL) { + return NT_STATUS_NO_USER_SESSION_KEY; + } + + if (session->conn->protocol >= PROTOCOL_SMB2_02) { + application_key = &session->smb2->application_key; + } else { + application_key = &session->smb1.application_key; + } + + if (application_key->length == 0) { + return NT_STATUS_NO_USER_SESSION_KEY; + } + + *key = data_blob_dup_talloc(mem_ctx, *application_key); + if (key->data == NULL) { + return NT_STATUS_NO_MEMORY; + } + + return NT_STATUS_OK; +} + uint16_t smb1cli_session_current_id(struct smbXcli_session *session) { return session->smb1.session_id; diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h index 2f78247c60..c35811ac0b 100644 --- a/libcli/smb/smbXcli_base.h +++ b/libcli/smb/smbXcli_base.h @@ -248,6 +248,9 @@ NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn, struct smbXcli_session *smbXcli_session_create(TALLOC_CTX *mem_ctx, struct smbXcli_conn *conn); +NTSTATUS smbXcli_session_application_key(struct smbXcli_session *session, + TALLOC_CTX *mem_ctx, + DATA_BLOB *key); uint16_t smb1cli_session_current_id(struct smbXcli_session* session); void smb1cli_session_set_id(struct smbXcli_session* session, uint16_t session_id); -- cgit