source: trunk/server/source3/libsmb/clisigning.c@ 745

Last change on this file since 745 was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 2.3 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 SMB Signing Code
4 Copyright (C) Jeremy Allison 2003.
5 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2002-2003
6 Copyright (C) Stefan Metzmacher 2009
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "includes.h"
23#include "libsmb/libsmb.h"
24#include "smb_signing.h"
25
26bool cli_simple_set_signing(struct cli_state *cli,
27 const DATA_BLOB user_session_key,
28 const DATA_BLOB response)
29{
30 bool ok;
31
32 ok = smb_signing_activate(cli->signing_state,
33 user_session_key,
34 response);
35 if (!ok) {
36 return false;
37 }
38
39 cli->readbraw_supported = false;
40 cli->writebraw_supported = false;
41
42 return true;
43}
44
45bool cli_temp_set_signing(struct cli_state *cli)
46{
47 return smb_signing_set_bsrspyl(cli->signing_state);
48}
49
50void cli_calculate_sign_mac(struct cli_state *cli, char *buf, uint32_t *seqnum)
51{
52 *seqnum = smb_signing_next_seqnum(cli->signing_state, false);
53 smb_signing_sign_pdu(cli->signing_state, (uint8_t *)buf, *seqnum);
54}
55
56bool cli_check_sign_mac(struct cli_state *cli, const char *buf, uint32_t seqnum)
57{
58 bool ok;
59
60 ok = smb_signing_check_pdu(cli->signing_state,
61 (const uint8_t *)buf,
62 seqnum);
63
64 if (!ok) {
65 return false;
66 }
67
68 return true;
69}
70
71void cli_set_signing_negotiated(struct cli_state *cli)
72{
73 smb_signing_set_negotiated(cli->signing_state);
74}
75
76bool client_is_signing_on(struct cli_state *cli)
77{
78 return smb_signing_is_active(cli->signing_state);
79}
80
81bool client_is_signing_allowed(struct cli_state *cli)
82{
83 return smb_signing_is_allowed(cli->signing_state);
84}
85
86bool client_is_signing_mandatory(struct cli_state *cli)
87{
88 return smb_signing_is_mandatory(cli->signing_state);
89}
Note: See TracBrowser for help on using the repository browser.