diff options
author | Stefan Metzmacher <metze@samba.org> | 2012-08-01 08:53:30 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2012-08-01 12:30:26 +0200 |
commit | c3cb672d3810cb2fb0076fac3b949df5f2462451 (patch) | |
tree | d574351376e55dcf4bb8fa7a0b55cca4b6d32cbf /libcli | |
parent | 9b9ef9270129c162988785fdd7d0308f2df86604 (diff) | |
download | samba-c3cb672d3810cb2fb0076fac3b949df5f2462451.tar.gz samba-c3cb672d3810cb2fb0076fac3b949df5f2462451.tar.bz2 samba-c3cb672d3810cb2fb0076fac3b949df5f2462451.zip |
libcli/smb: add smb1cli_session_set_session_key()
metze
Diffstat (limited to 'libcli')
-rw-r--r-- | libcli/smb/smbXcli_base.c | 34 | ||||
-rw-r--r-- | libcli/smb/smbXcli_base.h | 2 |
2 files changed, 36 insertions, 0 deletions
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c index a363b4451c..66cb8732ec 100644 --- a/libcli/smb/smbXcli_base.c +++ b/libcli/smb/smbXcli_base.c @@ -148,6 +148,7 @@ struct smbXcli_session { struct { uint16_t session_id; + DATA_BLOB application_key; } smb1; struct smb2cli_session *smb2; @@ -4304,6 +4305,39 @@ void smb1cli_session_set_id(struct smbXcli_session *session, session->smb1.session_id = session_id; } +NTSTATUS smb1cli_session_set_session_key(struct smbXcli_session *session, + const DATA_BLOB _session_key) +{ + struct smbXcli_conn *conn = session->conn; + uint8_t session_key[16]; + + if (conn == NULL) { + return NT_STATUS_INVALID_PARAMETER_MIX; + } + + if (session->smb1.application_key.length != 0) { + return NT_STATUS_INVALID_PARAMETER_MIX; + } + + if (_session_key.length == 0) { + return NT_STATUS_OK; + } + + ZERO_STRUCT(session_key); + memcpy(session_key, _session_key.data, + MIN(_session_key.length, sizeof(session_key))); + + session->smb1.application_key = data_blob_talloc(session, + session_key, + sizeof(session_key)); + ZERO_STRUCT(session_key); + if (session->smb1.application_key.data == NULL) { + return NT_STATUS_NO_MEMORY; + } + + return NT_STATUS_OK; +} + uint8_t smb2cli_session_security_mode(struct smbXcli_session *session) { struct smbXcli_conn *conn = session->conn; diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h index c55bf53691..2f78247c60 100644 --- a/libcli/smb/smbXcli_base.h +++ b/libcli/smb/smbXcli_base.h @@ -251,6 +251,8 @@ struct smbXcli_session *smbXcli_session_create(TALLOC_CTX *mem_ctx, uint16_t smb1cli_session_current_id(struct smbXcli_session* session); void smb1cli_session_set_id(struct smbXcli_session* session, uint16_t session_id); +NTSTATUS smb1cli_session_set_session_key(struct smbXcli_session *session, + const DATA_BLOB _session_key); uint8_t smb2cli_session_security_mode(struct smbXcli_session *session); uint64_t smb2cli_session_current_id(struct smbXcli_session *session); uint16_t smb2cli_session_get_flags(struct smbXcli_session *session); |