1 | /*
|
---|
2 | * Unix SMB/CIFS implementation.
|
---|
3 | * Version 3.0
|
---|
4 | * NTLMSSP Signing routines
|
---|
5 | * Copyright (C) Luke Kenneth Casson Leighton 1996-2001
|
---|
6 | * Copyright (C) Andrew Bartlett <abartlet@samba.org> 2003-2005
|
---|
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 "auth/ntlmssp/ntlmssp.h"
|
---|
24 | #include "auth/gensec/gensec.h"
|
---|
25 | #include "../libcli/auth/ntlmssp_private.h"
|
---|
26 |
|
---|
27 | NTSTATUS gensec_ntlmssp_sign_packet(struct gensec_security *gensec_security,
|
---|
28 | TALLOC_CTX *sig_mem_ctx,
|
---|
29 | const uint8_t *data, size_t length,
|
---|
30 | const uint8_t *whole_pdu, size_t pdu_length,
|
---|
31 | DATA_BLOB *sig)
|
---|
32 | {
|
---|
33 | struct gensec_ntlmssp_context *gensec_ntlmssp =
|
---|
34 | talloc_get_type_abort(gensec_security->private_data,
|
---|
35 | struct gensec_ntlmssp_context);
|
---|
36 | NTSTATUS nt_status;
|
---|
37 |
|
---|
38 | nt_status = ntlmssp_sign_packet(gensec_ntlmssp->ntlmssp_state,
|
---|
39 | sig_mem_ctx,
|
---|
40 | data, length,
|
---|
41 | whole_pdu, pdu_length,
|
---|
42 | sig);
|
---|
43 |
|
---|
44 | return nt_status;
|
---|
45 | }
|
---|
46 |
|
---|
47 | NTSTATUS gensec_ntlmssp_check_packet(struct gensec_security *gensec_security,
|
---|
48 | TALLOC_CTX *sig_mem_ctx,
|
---|
49 | const uint8_t *data, size_t length,
|
---|
50 | const uint8_t *whole_pdu, size_t pdu_length,
|
---|
51 | const DATA_BLOB *sig)
|
---|
52 | {
|
---|
53 | struct gensec_ntlmssp_context *gensec_ntlmssp =
|
---|
54 | talloc_get_type_abort(gensec_security->private_data,
|
---|
55 | struct gensec_ntlmssp_context);
|
---|
56 | NTSTATUS nt_status;
|
---|
57 |
|
---|
58 | nt_status = ntlmssp_check_packet(gensec_ntlmssp->ntlmssp_state,
|
---|
59 | data, length,
|
---|
60 | whole_pdu, pdu_length,
|
---|
61 | sig);
|
---|
62 |
|
---|
63 | return nt_status;
|
---|
64 | }
|
---|
65 |
|
---|
66 | NTSTATUS gensec_ntlmssp_seal_packet(struct gensec_security *gensec_security,
|
---|
67 | TALLOC_CTX *sig_mem_ctx,
|
---|
68 | uint8_t *data, size_t length,
|
---|
69 | const uint8_t *whole_pdu, size_t pdu_length,
|
---|
70 | DATA_BLOB *sig)
|
---|
71 | {
|
---|
72 | struct gensec_ntlmssp_context *gensec_ntlmssp =
|
---|
73 | talloc_get_type_abort(gensec_security->private_data,
|
---|
74 | struct gensec_ntlmssp_context);
|
---|
75 | NTSTATUS nt_status;
|
---|
76 |
|
---|
77 | nt_status = ntlmssp_seal_packet(gensec_ntlmssp->ntlmssp_state,
|
---|
78 | sig_mem_ctx,
|
---|
79 | data, length,
|
---|
80 | whole_pdu, pdu_length,
|
---|
81 | sig);
|
---|
82 |
|
---|
83 | return nt_status;
|
---|
84 | }
|
---|
85 |
|
---|
86 | /*
|
---|
87 | wrappers for the ntlmssp_*() functions
|
---|
88 | */
|
---|
89 | NTSTATUS gensec_ntlmssp_unseal_packet(struct gensec_security *gensec_security,
|
---|
90 | TALLOC_CTX *sig_mem_ctx,
|
---|
91 | uint8_t *data, size_t length,
|
---|
92 | const uint8_t *whole_pdu, size_t pdu_length,
|
---|
93 | const DATA_BLOB *sig)
|
---|
94 | {
|
---|
95 | struct gensec_ntlmssp_context *gensec_ntlmssp =
|
---|
96 | talloc_get_type_abort(gensec_security->private_data,
|
---|
97 | struct gensec_ntlmssp_context);
|
---|
98 | NTSTATUS nt_status;
|
---|
99 |
|
---|
100 | nt_status = ntlmssp_unseal_packet(gensec_ntlmssp->ntlmssp_state,
|
---|
101 | data, length,
|
---|
102 | whole_pdu, pdu_length,
|
---|
103 | sig);
|
---|
104 |
|
---|
105 | return nt_status;
|
---|
106 | }
|
---|
107 |
|
---|
108 | size_t gensec_ntlmssp_sig_size(struct gensec_security *gensec_security, size_t data_size)
|
---|
109 | {
|
---|
110 | return NTLMSSP_SIG_SIZE;
|
---|
111 | }
|
---|
112 |
|
---|
113 | NTSTATUS gensec_ntlmssp_wrap(struct gensec_security *gensec_security,
|
---|
114 | TALLOC_CTX *out_mem_ctx,
|
---|
115 | const DATA_BLOB *in,
|
---|
116 | DATA_BLOB *out)
|
---|
117 | {
|
---|
118 | struct gensec_ntlmssp_context *gensec_ntlmssp =
|
---|
119 | talloc_get_type_abort(gensec_security->private_data,
|
---|
120 | struct gensec_ntlmssp_context);
|
---|
121 |
|
---|
122 | return ntlmssp_wrap(gensec_ntlmssp->ntlmssp_state,
|
---|
123 | out_mem_ctx,
|
---|
124 | in, out);
|
---|
125 | }
|
---|
126 |
|
---|
127 |
|
---|
128 | NTSTATUS gensec_ntlmssp_unwrap(struct gensec_security *gensec_security,
|
---|
129 | TALLOC_CTX *out_mem_ctx,
|
---|
130 | const DATA_BLOB *in,
|
---|
131 | DATA_BLOB *out)
|
---|
132 | {
|
---|
133 | struct gensec_ntlmssp_context *gensec_ntlmssp =
|
---|
134 | talloc_get_type_abort(gensec_security->private_data,
|
---|
135 | struct gensec_ntlmssp_context);
|
---|
136 |
|
---|
137 | return ntlmssp_unwrap(gensec_ntlmssp->ntlmssp_state,
|
---|
138 | out_mem_ctx,
|
---|
139 | in, out);
|
---|
140 | }
|
---|