dinput: Use dinput device as a base class for keyboard, mouse and joystick.
[wine] / dlls / secur32 / secur32_priv.h
1 /*
2  * secur32 private definitions.
3  *
4  * Copyright (C) 2004 Juan Lang
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #ifndef __SECUR32_PRIV_H__
22 #define __SECUR32_PRIV_H__
23
24 #include <sys/types.h>
25 #include "wine/list.h"
26
27 /* Memory allocation functions for memory accessible by callers of secur32.
28  * The details are implementation specific.
29  */
30 #define SECUR32_ALLOC(bytes) HeapAlloc(GetProcessHeap(), 0, (bytes))
31 #define SECUR32_FREE(p)      HeapFree(GetProcessHeap(), 0, (p))
32
33 typedef struct _SecureProvider
34 {
35     struct list             entry;
36     BOOL                    loaded;
37     PWSTR                   moduleName;
38     HMODULE                 lib;
39     SecurityFunctionTableA  fnTableA;
40     SecurityFunctionTableW  fnTableW;
41 } SecureProvider;
42
43 typedef struct _SecurePackage
44 {
45     struct list     entry;
46     SecPkgInfoW     infoW;
47     SecureProvider *provider;
48 } SecurePackage;
49
50 typedef enum _helper_mode {
51     NTLM_SERVER,
52     NTLM_CLIENT,
53     NUM_HELPER_MODES
54 } HelperMode;
55
56 typedef struct tag_arc4_info {
57     unsigned char x, y;
58     unsigned char state[256];
59 } arc4_info;
60
61 typedef struct _NegoHelper {
62     pid_t helper_pid;
63     HelperMode mode;
64     SEC_CHAR *password;
65     int pwlen;
66     int pipe_in;
67     int pipe_out;
68     int version;
69     char *com_buf;
70     int com_buf_size;
71     int com_buf_offset;
72     BYTE *session_key;
73     BOOL valid_session_key;
74     unsigned long neg_flags;
75     struct {
76         struct {
77             ULONG seq_num;
78             arc4_info *a4i;
79         } ntlm;
80     } crypt;
81 } NegoHelper, *PNegoHelper;
82
83 /* Allocates space for and initializes a new provider.  If fnTableA or fnTableW
84  * is non-NULL, assumes the provider is built-in (and is thus already loaded.)
85  * Otherwise moduleName must not be NULL.
86  * Returns a pointer to the stored provider entry, for use adding packages.
87  */
88 SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
89  const SecurityFunctionTableW *fnTableW, const PWSTR moduleName);
90
91 /* Allocates space for and adds toAdd packages with the given provider.
92  * provider must not be NULL, and either infoA or infoW may be NULL, but not
93  * both.
94  */
95 void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
96  const SecPkgInfoA *infoA, const SecPkgInfoW *infoW);
97
98 /* Tries to find the package named packageName.  If it finds it, implicitly
99  * loads the package if it isn't already loaded.
100  */
101 SecurePackage *SECUR32_findPackageW(PWSTR packageName);
102
103 /* Tries to find the package named packageName.  (Thunks to _findPackageW)
104  */
105 SecurePackage *SECUR32_findPackageA(PSTR packageName);
106
107 /* A few string helpers; will return NULL if str is NULL.  Free return with
108  * SECUR32_FREE */
109 PWSTR SECUR32_strdupW(PCWSTR str);
110 PWSTR SECUR32_AllocWideFromMultiByte(PCSTR str);
111 PSTR  SECUR32_AllocMultiByteFromWide(PCWSTR str);
112
113 /* Initialization functions for built-in providers */
114 void SECUR32_initSchannelSP(void);
115 void SECUR32_initNegotiateSP(void);
116 void SECUR32_initNTLMSP(void);
117
118 /* Functions from dispatcher.c used elsewhere in the code */
119 SECURITY_STATUS fork_helper(PNegoHelper *new_helper, const char *prog,
120         char * const argv[]);
121
122 SECURITY_STATUS run_helper(PNegoHelper helper, char *buffer,
123         unsigned int max_buflen, int *buflen);
124
125 void cleanup_helper(PNegoHelper helper);
126
127 void check_version(PNegoHelper helper);
128
129 /* Functions from base64_codec.c used elsewhere */
130 SECURITY_STATUS encodeBase64(PBYTE in_buf, int in_len, char* out_buf, 
131         int max_len, int *out_len);
132
133 SECURITY_STATUS decodeBase64(char *in_buf, int in_len, BYTE *out_buf,
134         int max_len, int *out_len);
135
136 /* Functions from util.c */
137 ULONG ComputeCrc32(const BYTE *pData, INT iLen);
138 SECURITY_STATUS SECUR32_CreateNTLMv1SessionKey(PBYTE password, int len, PBYTE session_key);
139 arc4_info *SECUR32_arc4Alloc(void);
140 void SECUR32_arc4Init(arc4_info *a4i, const BYTE *key, unsigned int keyLen);
141 void SECUR32_arc4Process(arc4_info *a4i, BYTE *inoutString, unsigned int length);
142
143 /* NTLMSSP flags indicating the negotiated features */
144 #define NTLMSSP_NEGOTIATE_UNICODE                   0x00000001
145 #define NTLMSSP_NEGOTIATE_OEM                       0x00000002
146 #define NTLMSSP_REQUEST_TARGET                      0x00000004
147 #define NTLMSSP_NEGOTIATE_SIGN                      0x00000010
148 #define NTLMSSP_NEGOTIATE_SEAL                      0x00000020
149 #define NTLMSSP_NEGOTIATE_DATAGRAM_STYLE            0x00000040
150 #define NTLMSSP_NEGOTIATE_LM_SESSION_KEY            0x00000080
151 #define NTLMSSP_NEGOTIATE_NTLM                      0x00000200
152 #define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED           0x00001000
153 #define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED      0x00002000
154 #define NTLMSSP_NEGOTIATE_LOCAL_CALL                0x00004000
155 #define NTLMSSP_NEGOTIATE_ALWAYS_SIGN               0x00008000
156 #define NTLMSSP_NEGOTIATE_TARGET_TYPE_DOMAIN        0x00010000
157 #define NTLMSSP_NEGOTIATE_TARGET_TYPE_SERVER        0x00020000
158 #define NTLMSSP_NEGOTIATE_NTLM2                     0x00080000
159 #define NTLMSSP_NEGOTIATE_TARGET_INFO               0x00800000
160 #define NTLMSSP_NEGOTIATE_128                       0x20000000
161 #define NTLMSSP_NEGOTIATE_KEY_EXCHANGE              0x40000000
162 #define NTLMSSP_NEGOTIATE_56                        0x80000000
163 #endif /* ndef __SECUR32_PRIV_H__ */