2 Unix SMB/Netbios implementation.
5 Copyright (C) Guenther Deschner 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/>.
22 #include "../librpc/gen_ndr/ndr_ntlmssp.h"
23 #include "libsmb/ntlmssp_ndr.h"
25 #define NTLMSSP_PULL_MESSAGE(type, blob, mem_ctx, ic, r) \
27 enum ndr_err_code __ndr_err; \
28 __ndr_err = ndr_pull_struct_blob(blob, mem_ctx, ic, r, \
29 (ndr_pull_flags_fn_t)ndr_pull_ ##type); \
30 if (!NDR_ERR_CODE_IS_SUCCESS(__ndr_err)) { \
31 return ndr_map_error2ntstatus(__ndr_err); \
33 if (memcmp(r->Signature, "NTLMSSP\0", 8)) {\
34 return NT_STATUS_INVALID_PARAMETER; \
36 return NT_STATUS_OK; \
39 #define NTLMSSP_PUSH_MESSAGE(type, blob, mem_ctx, ic, r) \
41 enum ndr_err_code __ndr_err; \
42 __ndr_err = ndr_push_struct_blob(blob, mem_ctx, ic, r, \
43 (ndr_push_flags_fn_t)ndr_push_ ##type); \
44 if (!NDR_ERR_CODE_IS_SUCCESS(__ndr_err)) { \
45 return ndr_map_error2ntstatus(__ndr_err); \
47 return NT_STATUS_OK; \
52 * Pull NTLMSSP NEGOTIATE_MESSAGE struct from a blob
53 * @param blob The plain packet blob
54 * @param mem_ctx A talloc context
55 * @param ic Iconv convenience structure
56 * @param r Pointer to a NTLMSSP NEGOTIATE_MESSAGE structure
59 NTSTATUS
ntlmssp_pull_NEGOTIATE_MESSAGE(const DATA_BLOB
*blob
,
61 struct smb_iconv_convenience
*ic
,
62 struct NEGOTIATE_MESSAGE
*r
)
64 NTLMSSP_PULL_MESSAGE(NEGOTIATE_MESSAGE
, blob
, mem_ctx
, ic
, r
);
68 * Pull NTLMSSP CHALLENGE_MESSAGE struct from a blob
69 * @param blob The plain packet blob
70 * @param mem_ctx A talloc context
71 * @param ic Iconv convenience structure
72 * @param r Pointer to a NTLMSSP CHALLENGE_MESSAGE structure
75 NTSTATUS
ntlmssp_pull_CHALLENGE_MESSAGE(const DATA_BLOB
*blob
,
77 struct smb_iconv_convenience
*ic
,
78 struct CHALLENGE_MESSAGE
*r
)
80 NTLMSSP_PULL_MESSAGE(CHALLENGE_MESSAGE
, blob
, mem_ctx
, ic
, r
);
84 * Pull NTLMSSP AUTHENTICATE_MESSAGE struct from a blob
85 * @param blob The plain packet blob
86 * @param mem_ctx A talloc context
87 * @param ic Iconv convenience structure
88 * @param r Pointer to a NTLMSSP AUTHENTICATE_MESSAGE structure
91 NTSTATUS
ntlmssp_pull_AUTHENTICATE_MESSAGE(const DATA_BLOB
*blob
,
93 struct smb_iconv_convenience
*ic
,
94 struct AUTHENTICATE_MESSAGE
*r
)
96 NTLMSSP_PULL_MESSAGE(AUTHENTICATE_MESSAGE
, blob
, mem_ctx
, ic
, r
);
100 * Push NTLMSSP NEGOTIATE_MESSAGE struct into a blob
101 * @param blob The plain packet blob
102 * @param mem_ctx A talloc context
103 * @param ic Iconv convenience structure
104 * @param r Pointer to a NTLMSSP NEGOTIATE_MESSAGE structure
107 NTSTATUS
ntlmssp_push_NEGOTIATE_MESSAGE(DATA_BLOB
*blob
,
109 struct smb_iconv_convenience
*ic
,
110 const struct NEGOTIATE_MESSAGE
*r
)
112 NTLMSSP_PUSH_MESSAGE(NEGOTIATE_MESSAGE
, blob
, mem_ctx
, ic
, r
);
116 * Push NTLMSSP CHALLENGE_MESSAGE struct into a blob
117 * @param blob The plain packet blob
118 * @param mem_ctx A talloc context
119 * @param ic Iconv convenience structure
120 * @param r Pointer to a NTLMSSP CHALLENGE_MESSAGE structure
123 NTSTATUS
ntlmssp_push_CHALLENGE_MESSAGE(DATA_BLOB
*blob
,
125 struct smb_iconv_convenience
*ic
,
126 const struct CHALLENGE_MESSAGE
*r
)
128 NTLMSSP_PUSH_MESSAGE(CHALLENGE_MESSAGE
, blob
, mem_ctx
, ic
, r
);
132 * Push NTLMSSP AUTHENTICATE_MESSAGE struct into a blob
133 * @param blob The plain packet blob
134 * @param mem_ctx A talloc context
135 * @param ic Iconv convenience structure
136 * @param r Pointer to a NTLMSSP AUTHENTICATE_MESSAGE structure
139 NTSTATUS
ntlmssp_push_AUTHENTICATE_MESSAGE(DATA_BLOB
*blob
,
141 struct smb_iconv_convenience
*ic
,
142 const struct AUTHENTICATE_MESSAGE
*r
)
144 NTLMSSP_PUSH_MESSAGE(AUTHENTICATE_MESSAGE
, blob
, mem_ctx
, ic
, r
);