1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

libcli:smb: Add smb2_signing_key_destructor()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andreas Schneider 2019-03-13 18:56:05 +01:00 committed by Andrew Bartlett
parent 9e16adff08
commit 3f252816ad
4 changed files with 22 additions and 5 deletions

View File

@ -27,6 +27,16 @@
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
int smb2_signing_key_destructor(struct smb2_signing_key *key)
{
if (key->hmac_hnd != NULL) {
gnutls_hmac_deinit(key->hmac_hnd, NULL);
key->hmac_hnd = NULL;
}
return 0;
}
bool smb2_signing_key_valid(const struct smb2_signing_key *key)
{
if (key == NULL) {

View File

@ -31,6 +31,8 @@ struct smb2_signing_key {
DATA_BLOB blob;
};
int smb2_signing_key_destructor(struct smb2_signing_key *key);
bool smb2_signing_key_valid(const struct smb2_signing_key *key);
NTSTATUS smb2_signing_sign_pdu(DATA_BLOB signing_key,

View File

@ -5964,7 +5964,8 @@ NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
ZERO_STRUCT(session_key);
return NT_STATUS_NO_MEMORY;
}
/* TODO: setup destructor once we cache the hmac handle */
talloc_set_destructor(session->smb2->signing_key,
smb2_signing_key_destructor);
session->smb2->signing_key->blob =
data_blob_talloc(session->smb2->signing_key,
@ -6041,7 +6042,8 @@ NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
if (session->smb2_channel.signing_key == NULL) {
return NT_STATUS_NO_MEMORY;
}
/* TODO: setup destructor once we cache the hmac handle */
talloc_set_destructor(session->smb2_channel.signing_key,
smb2_signing_key_destructor);
session->smb2_channel.signing_key->blob =
data_blob_dup_talloc(session->smb2_channel.signing_key,

View File

@ -329,7 +329,8 @@ static NTSTATUS smbd_smb2_auth_generic_return(struct smbXsrv_session *session,
ZERO_STRUCT(session_key);
return NT_STATUS_NO_MEMORY;
}
/* TODO: setup destructor once we cache the hmac handle */
talloc_set_destructor(x->global->signing_key,
smb2_signing_key_destructor);
x->global->signing_key->blob =
x->global->signing_key_blob =
@ -459,7 +460,8 @@ static NTSTATUS smbd_smb2_auth_generic_return(struct smbXsrv_session *session,
if (x->global->channels[0].signing_key == NULL) {
return NT_STATUS_NO_MEMORY;
}
/* TODO: setup destructor once we cache the hmac handle */
talloc_set_destructor(x->global->channels[0].signing_key,
smb2_signing_key_destructor);
x->global->channels[0].signing_key->blob =
x->global->channels[0].signing_key_blob =
@ -700,7 +702,8 @@ static NTSTATUS smbd_smb2_bind_auth_return(struct smbXsrv_session *session,
ZERO_STRUCT(session_key);
return NT_STATUS_NO_MEMORY;
}
/* TODO: setup destructor once we cache the hmac handle */
talloc_set_destructor(c->signing_key,
smb2_signing_key_destructor);
c->signing_key->blob =
c->signing_key_blob =