From 11e3552c9f0ee3c64408c083794c310d3d2c5640 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 4 Mar 2019 16:53:39 +0100 Subject: [PATCH] libcli:smb: Introduce a structure for the smb2_singing_key This also adds a new function to validate the structure. Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- libcli/smb/smb2_signing.c | 13 +++++++++++++ libcli/smb/smb2_signing.h | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/libcli/smb/smb2_signing.c b/libcli/smb/smb2_signing.c index 11168170a5b..c2a86b850e0 100644 --- a/libcli/smb/smb2_signing.c +++ b/libcli/smb/smb2_signing.c @@ -27,6 +27,19 @@ #include #include +bool smb2_signing_key_valid(const struct smb2_signing_key *key) +{ + if (key == NULL) { + return false; + } + + if (key->blob.length == 0 || key->blob.data == NULL) { + return false; + } + + return true; +} + NTSTATUS smb2_signing_sign_pdu(DATA_BLOB signing_key, enum protocol_types protocol, struct iovec *vector, diff --git a/libcli/smb/smb2_signing.h b/libcli/smb/smb2_signing.h index 107af5bac1e..668e48ae124 100644 --- a/libcli/smb/smb2_signing.h +++ b/libcli/smb/smb2_signing.h @@ -21,8 +21,18 @@ #ifndef _LIBCLI_SMB_SMB2_SIGNING_H_ #define _LIBCLI_SMB_SMB2_SIGNING_H_ +#include +#include + struct iovec; +struct smb2_signing_key { + gnutls_hmac_hd_t hmac_hnd; + DATA_BLOB blob; +}; + +bool smb2_signing_key_valid(const struct smb2_signing_key *key); + NTSTATUS smb2_signing_sign_pdu(DATA_BLOB signing_key, enum protocol_types protocol, struct iovec *vector,