secur32: Avoid size_t and fix some printf formats.
[wine/multimedia.git] / dlls / secur32 / secur32_priv.h
blob2d2fc1e35a414fad77d5affc4f50f596db073939
1 /*
2 * secur32 private definitions.
4 * Copyright (C) 2004 Juan Lang
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __SECUR32_PRIV_H__
22 #define __SECUR32_PRIV_H__
24 #include <sys/types.h>
25 #include <limits.h>
26 #include "wine/list.h"
27 #include "schannel.h"
29 typedef struct _SecureProvider
31 struct list entry;
32 BOOL loaded;
33 PWSTR moduleName;
34 HMODULE lib;
35 SecurityFunctionTableA fnTableA;
36 SecurityFunctionTableW fnTableW;
37 } SecureProvider;
39 typedef struct _SecurePackage
41 struct list entry;
42 SecPkgInfoW infoW;
43 SecureProvider *provider;
44 } SecurePackage;
46 typedef enum _helper_mode {
47 NTLM_SERVER,
48 NTLM_CLIENT,
49 NUM_HELPER_MODES
50 } HelperMode;
52 typedef struct tag_arc4_info {
53 unsigned char x, y;
54 unsigned char state[256];
55 } arc4_info;
57 typedef struct _NegoHelper {
58 pid_t helper_pid;
59 HelperMode mode;
60 int pipe_in;
61 int pipe_out;
62 int major;
63 int minor;
64 int micro;
65 char *com_buf;
66 int com_buf_size;
67 int com_buf_offset;
68 BYTE *session_key;
69 ULONG neg_flags;
70 struct {
71 struct {
72 ULONG seq_num;
73 arc4_info *a4i;
74 } ntlm;
75 struct {
76 BYTE *send_sign_key;
77 BYTE *send_seal_key;
78 BYTE *recv_sign_key;
79 BYTE *recv_seal_key;
80 ULONG send_seq_no;
81 ULONG recv_seq_no;
82 arc4_info *send_a4i;
83 arc4_info *recv_a4i;
84 } ntlm2;
85 } crypt;
86 } NegoHelper, *PNegoHelper;
88 typedef enum _sign_direction {
89 NTLM_SEND,
90 NTLM_RECV
91 } SignDirection;
93 /* Allocates space for and initializes a new provider. If fnTableA or fnTableW
94 * is non-NULL, assumes the provider is built-in, and if moduleName is non-NULL,
95 * means must load the LSA/user mode functions tables from external SSP/AP module.
96 * Otherwise moduleName must not be NULL.
97 * Returns a pointer to the stored provider entry, for use adding packages.
99 SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
100 const SecurityFunctionTableW *fnTableW, PCWSTR moduleName) DECLSPEC_HIDDEN;
102 /* Allocates space for and adds toAdd packages with the given provider.
103 * provider must not be NULL, and either infoA or infoW may be NULL, but not
104 * both.
106 void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
107 const SecPkgInfoA *infoA, const SecPkgInfoW *infoW) DECLSPEC_HIDDEN;
109 /* Tries to find the package named packageName. If it finds it, implicitly
110 * loads the package if it isn't already loaded.
112 SecurePackage *SECUR32_findPackageW(PCWSTR packageName) DECLSPEC_HIDDEN;
114 /* Tries to find the package named packageName. (Thunks to _findPackageW)
116 SecurePackage *SECUR32_findPackageA(PCSTR packageName) DECLSPEC_HIDDEN;
118 /* A few string helpers; will return NULL if str is NULL. Free return with
119 * HeapFree */
120 PWSTR SECUR32_AllocWideFromMultiByte(PCSTR str) DECLSPEC_HIDDEN;
121 PSTR SECUR32_AllocMultiByteFromWide(PCWSTR str) DECLSPEC_HIDDEN;
123 /* Initialization functions for built-in providers */
124 void SECUR32_initSchannelSP(void) DECLSPEC_HIDDEN;
125 void SECUR32_initNegotiateSP(void) DECLSPEC_HIDDEN;
126 void SECUR32_initNTLMSP(void) DECLSPEC_HIDDEN;
128 /* Cleanup functions for built-in providers */
129 void SECUR32_deinitSchannelSP(void) DECLSPEC_HIDDEN;
131 /* Functions from dispatcher.c used elsewhere in the code */
132 SECURITY_STATUS fork_helper(PNegoHelper *new_helper, const char *prog,
133 char * const argv[]) DECLSPEC_HIDDEN;
135 SECURITY_STATUS run_helper(PNegoHelper helper, char *buffer,
136 unsigned int max_buflen, int *buflen) DECLSPEC_HIDDEN;
138 void cleanup_helper(PNegoHelper helper) DECLSPEC_HIDDEN;
140 void check_version(PNegoHelper helper) DECLSPEC_HIDDEN;
142 /* Functions from base64_codec.c used elsewhere */
143 SECURITY_STATUS encodeBase64(PBYTE in_buf, int in_len, char* out_buf,
144 int max_len, int *out_len) DECLSPEC_HIDDEN;
146 SECURITY_STATUS decodeBase64(char *in_buf, int in_len, BYTE *out_buf,
147 int max_len, int *out_len) DECLSPEC_HIDDEN;
149 /* Functions from util.c */
150 ULONG ComputeCrc32(const BYTE *pData, INT iLen, ULONG initial_crc) DECLSPEC_HIDDEN;
151 SECURITY_STATUS SECUR32_CreateNTLM1SessionKey(PBYTE password, int len, PBYTE session_key) DECLSPEC_HIDDEN;
152 SECURITY_STATUS SECUR32_CreateNTLM2SubKeys(PNegoHelper helper) DECLSPEC_HIDDEN;
153 arc4_info *SECUR32_arc4Alloc(void) DECLSPEC_HIDDEN;
154 void SECUR32_arc4Init(arc4_info *a4i, const BYTE *key, unsigned int keyLen) DECLSPEC_HIDDEN;
155 void SECUR32_arc4Process(arc4_info *a4i, BYTE *inoutString, unsigned int length) DECLSPEC_HIDDEN;
156 void SECUR32_arc4Cleanup(arc4_info *a4i) DECLSPEC_HIDDEN;
158 /* NTLMSSP flags indicating the negotiated features */
159 #define NTLMSSP_NEGOTIATE_UNICODE 0x00000001
160 #define NTLMSSP_NEGOTIATE_OEM 0x00000002
161 #define NTLMSSP_REQUEST_TARGET 0x00000004
162 #define NTLMSSP_NEGOTIATE_SIGN 0x00000010
163 #define NTLMSSP_NEGOTIATE_SEAL 0x00000020
164 #define NTLMSSP_NEGOTIATE_DATAGRAM_STYLE 0x00000040
165 #define NTLMSSP_NEGOTIATE_LM_SESSION_KEY 0x00000080
166 #define NTLMSSP_NEGOTIATE_NTLM 0x00000200
167 #define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED 0x00001000
168 #define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED 0x00002000
169 #define NTLMSSP_NEGOTIATE_LOCAL_CALL 0x00004000
170 #define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x00008000
171 #define NTLMSSP_NEGOTIATE_TARGET_TYPE_DOMAIN 0x00010000
172 #define NTLMSSP_NEGOTIATE_TARGET_TYPE_SERVER 0x00020000
173 #define NTLMSSP_NEGOTIATE_NTLM2 0x00080000
174 #define NTLMSSP_NEGOTIATE_TARGET_INFO 0x00800000
175 #define NTLMSSP_NEGOTIATE_128 0x20000000
176 #define NTLMSSP_NEGOTIATE_KEY_EXCHANGE 0x40000000
177 #define NTLMSSP_NEGOTIATE_56 0x80000000
180 /* schannel internal interface */
181 typedef struct schan_imp_session_opaque *schan_imp_session;
182 typedef struct schan_imp_certificate_credentials_opaque *schan_imp_certificate_credentials;
184 struct schan_transport;
186 extern int schan_pull(struct schan_transport *t, void *buff, size_t *buff_len) DECLSPEC_HIDDEN;
187 extern int schan_push(struct schan_transport *t, const void *buff, size_t *buff_len) DECLSPEC_HIDDEN;
189 extern schan_imp_session schan_session_for_transport(struct schan_transport* t) DECLSPEC_HIDDEN;
191 /* schannel implementation interface */
192 extern BOOL schan_imp_create_session(schan_imp_session *session, BOOL is_server,
193 schan_imp_certificate_credentials cred) DECLSPEC_HIDDEN;
194 extern void schan_imp_dispose_session(schan_imp_session session) DECLSPEC_HIDDEN;
195 extern void schan_imp_set_session_transport(schan_imp_session session,
196 struct schan_transport *t) DECLSPEC_HIDDEN;
197 extern SECURITY_STATUS schan_imp_handshake(schan_imp_session session) DECLSPEC_HIDDEN;
198 extern unsigned int schan_imp_get_session_cipher_block_size(schan_imp_session session) DECLSPEC_HIDDEN;
199 extern SECURITY_STATUS schan_imp_get_connection_info(schan_imp_session session,
200 SecPkgContext_ConnectionInfo *info) DECLSPEC_HIDDEN;
201 extern SECURITY_STATUS schan_imp_get_session_peer_certificate(schan_imp_session session,
202 PCCERT_CONTEXT *cert) DECLSPEC_HIDDEN;
203 extern SECURITY_STATUS schan_imp_send(schan_imp_session session, const void *buffer,
204 SIZE_T *length) DECLSPEC_HIDDEN;
205 extern SECURITY_STATUS schan_imp_recv(schan_imp_session session, void *buffer,
206 SIZE_T *length) DECLSPEC_HIDDEN;
207 extern BOOL schan_imp_allocate_certificate_credentials(schan_imp_certificate_credentials *c) DECLSPEC_HIDDEN;
208 extern void schan_imp_free_certificate_credentials(schan_imp_certificate_credentials c) DECLSPEC_HIDDEN;
209 extern BOOL schan_imp_init(void) DECLSPEC_HIDDEN;
210 extern void schan_imp_deinit(void) DECLSPEC_HIDDEN;
213 #endif /* ndef __SECUR32_PRIV_H__ */