#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) {
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,
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,
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,
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 =
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 =
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 =