libcli:smb: Introduce a structure for the smb2_singing_key
authorAndreas Schneider <asn@samba.org>
Mon, 4 Mar 2019 15:53:39 +0000 (16:53 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 30 Apr 2019 23:18:28 +0000 (23:18 +0000)
This also adds a new function to validate the structure.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
libcli/smb/smb2_signing.c
libcli/smb/smb2_signing.h

index 11168170a5b62544f082221ff107cbebb544b43e..c2a86b850e06239cc862c3b3b3ff62d922e6f8dd 100644 (file)
 #include <gnutls/gnutls.h>
 #include <gnutls/crypto.h>
 
+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,
index 107af5bac1e6c307eebf51bec918d1f14ce93c68..668e48ae124b284875de7263ef9d6926a336c52b 100644 (file)
 #ifndef _LIBCLI_SMB_SMB2_SIGNING_H_
 #define _LIBCLI_SMB_SMB2_SIGNING_H_
 
+#include <gnutls/gnutls.h>
+#include <gnutls/crypto.h>
+
 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,