s3: smbd: Fix schedule_smb2_aio_read() to allow the last read in a compound to go...
[Samba.git] / libcli / smb / smb2_signing.h
blobcf6fbe50db80ccc7ec2522ad7016d1b2fa5ba96f
1 /*
2 Unix SMB/CIFS implementation.
3 SMB2 signing
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 struct iovec;
26 struct smb2_signing_derivation {
27 DATA_BLOB label;
28 DATA_BLOB context;
31 struct smb2_signing_derivations {
32 struct smb2_signing_derivation __signing;
33 const struct smb2_signing_derivation *signing;
34 struct smb2_signing_derivation __cipher_c2s;
35 const struct smb2_signing_derivation *cipher_c2s;
36 struct smb2_signing_derivation __cipher_s2c;
37 const struct smb2_signing_derivation *cipher_s2c;
38 struct smb2_signing_derivation __application;
39 const struct smb2_signing_derivation *application;
42 void smb2_signing_derivations_fill_const_stack(struct smb2_signing_derivations *ds,
43 enum protocol_types protocol,
44 const DATA_BLOB preauth_hash);
46 struct smb2_signing_key {
47 DATA_BLOB blob;
48 uint16_t sign_algo_id;
49 union {
50 #ifdef SMB2_SIGNING_KEY_GNUTLS_TYPES
51 gnutls_hmac_hd_t hmac_hnd;
52 #endif
53 void *__hmac_hnd;
55 uint16_t cipher_algo_id;
56 union {
57 #ifdef SMB2_SIGNING_KEY_GNUTLS_TYPES
58 gnutls_aead_cipher_hd_t cipher_hnd;
59 #endif
60 void *__cipher_hnd;
64 NTSTATUS smb2_signing_key_copy(TALLOC_CTX *mem_ctx,
65 const struct smb2_signing_key *src,
66 struct smb2_signing_key **_dst);
67 NTSTATUS smb2_signing_key_sign_create(TALLOC_CTX *mem_ctx,
68 uint16_t sign_algo_id,
69 const DATA_BLOB *master_key,
70 const struct smb2_signing_derivation *d,
71 struct smb2_signing_key **_key);
72 NTSTATUS smb2_signing_key_cipher_create(TALLOC_CTX *mem_ctx,
73 uint16_t cipher_algo_id,
74 const DATA_BLOB *master_key,
75 const struct smb2_signing_derivation *d,
76 struct smb2_signing_key **_key);
78 bool smb2_signing_key_valid(const struct smb2_signing_key *key);
80 NTSTATUS smb2_signing_sign_pdu(struct smb2_signing_key *signing_key,
81 struct iovec *vector,
82 int count);
84 NTSTATUS smb2_signing_check_pdu(struct smb2_signing_key *signing_key,
85 const struct iovec *vector,
86 int count);
88 NTSTATUS smb2_key_derivation(const uint8_t *KI, size_t KI_len,
89 const uint8_t *Label, size_t Label_len,
90 const uint8_t *Context, size_t Context_len,
91 uint8_t *KO, size_t KO_len);
93 NTSTATUS smb2_signing_encrypt_pdu(struct smb2_signing_key *encryption_key,
94 struct iovec *vector,
95 int count);
96 NTSTATUS smb2_signing_decrypt_pdu(struct smb2_signing_key *decryption_key,
97 struct iovec *vector,
98 int count);
100 #endif /* _LIBCLI_SMB_SMB2_SIGNING_H_ */