2 Unix SMB/CIFS implementation.
5 Copyright (C) Stefan Metzmacher 2009
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef _LIBCLI_SMB_SMB2_SIGNING_H_
22 #define _LIBCLI_SMB_SMB2_SIGNING_H_
24 #include <gnutls/gnutls.h>
26 #include "lib/util/data_blob.h"
28 #include "libcli/smb/smb_constants.h"
29 #include "libcli/util/ntstatus.h"
33 struct smb2_signing_derivation
{
38 struct smb2_signing_derivations
{
39 struct smb2_signing_derivation __signing
;
40 const struct smb2_signing_derivation
*signing
;
41 struct smb2_signing_derivation __cipher_c2s
;
42 const struct smb2_signing_derivation
*cipher_c2s
;
43 struct smb2_signing_derivation __cipher_s2c
;
44 const struct smb2_signing_derivation
*cipher_s2c
;
45 struct smb2_signing_derivation __application
;
46 const struct smb2_signing_derivation
*application
;
49 void smb2_signing_derivations_fill_const_stack(struct smb2_signing_derivations
*ds
,
50 enum protocol_types protocol
,
51 const DATA_BLOB preauth_hash
);
53 struct smb2_signing_key
{
55 uint16_t sign_algo_id
;
57 #ifdef SMB2_SIGNING_KEY_GNUTLS_TYPES
58 gnutls_hmac_hd_t hmac_hnd
;
62 uint16_t cipher_algo_id
;
64 #ifdef SMB2_SIGNING_KEY_GNUTLS_TYPES
65 gnutls_aead_cipher_hd_t cipher_hnd
;
71 NTSTATUS
smb2_signing_key_copy(TALLOC_CTX
*mem_ctx
,
72 const struct smb2_signing_key
*src
,
73 struct smb2_signing_key
**_dst
);
74 NTSTATUS
smb2_signing_key_sign_create(TALLOC_CTX
*mem_ctx
,
75 uint16_t sign_algo_id
,
76 const DATA_BLOB
*master_key
,
77 const struct smb2_signing_derivation
*d
,
78 struct smb2_signing_key
**_key
);
79 NTSTATUS
smb2_signing_key_cipher_create(TALLOC_CTX
*mem_ctx
,
80 uint16_t cipher_algo_id
,
81 const DATA_BLOB
*master_key
,
82 const struct smb2_signing_derivation
*d
,
83 struct smb2_signing_key
**_key
);
85 bool smb2_signing_key_valid(const struct smb2_signing_key
*key
);
87 NTSTATUS
smb2_signing_sign_pdu(struct smb2_signing_key
*signing_key
,
91 NTSTATUS
smb2_signing_check_pdu(struct smb2_signing_key
*signing_key
,
92 const struct iovec
*vector
,
95 NTSTATUS
smb2_signing_encrypt_pdu(struct smb2_signing_key
*encryption_key
,
98 NTSTATUS
smb2_signing_decrypt_pdu(struct smb2_signing_key
*decryption_key
,
102 #endif /* _LIBCLI_SMB_SMB2_SIGNING_H_ */