xref: /reactos/dll/win32/secur32/wine/ntlm.h (revision 98aabbcf)
1 
2 #ifndef __WINE_NTLM_H__
3 #define __WINE_NTLM_H__
4 
5 #include <sys/types.h>
6 #define CP_UNIXCP CP_ACP
7 
8 void SECUR32_initNTLMSP(void) DECLSPEC_HIDDEN;
9 
10 typedef enum _helper_mode {
11     NTLM_SERVER,
12     NTLM_CLIENT,
13     NUM_HELPER_MODES
14 } HelperMode;
15 
16 typedef struct tag_arc4_info {
17     unsigned char x, y;
18     unsigned char state[256];
19 } arc4_info;
20 
21 typedef struct _NegoHelper {
22 #ifndef __REACTOS__
23     pid_t helper_pid;
24 #else
25     HANDLE helper_pid;
26 #endif
27     HelperMode mode;
28     int pipe_in;
29     int pipe_out;
30     int major;
31     int minor;
32     int micro;
33     char *com_buf;
34     int com_buf_size;
35     int com_buf_offset;
36     BYTE *session_key;
37     ULONG neg_flags;
38     struct {
39         struct {
40             ULONG seq_num;
41             arc4_info *a4i;
42         } ntlm;
43         struct {
44             BYTE *send_sign_key;
45             BYTE *send_seal_key;
46             BYTE *recv_sign_key;
47             BYTE *recv_seal_key;
48             ULONG send_seq_no;
49             ULONG recv_seq_no;
50             arc4_info *send_a4i;
51             arc4_info *recv_a4i;
52         } ntlm2;
53     } crypt;
54 } NegoHelper, *PNegoHelper;
55 
56 typedef struct _NtlmCredentials
57 {
58     HelperMode mode;
59 
60     /* these are all in the Unix codepage */
61     char *username_arg;
62     char *domain_arg;
63     char *password; /* not nul-terminated */
64     int pwlen;
65     int no_cached_credentials; /* don't try to use cached Samba credentials */
66 } NtlmCredentials, *PNtlmCredentials;
67 
68 typedef enum _sign_direction {
69     NTLM_SEND,
70     NTLM_RECV
71 } SignDirection;
72 
73 SECURITY_STATUS SECUR32_CreateNTLM1SessionKey(PBYTE password, int len, PBYTE session_key) DECLSPEC_HIDDEN;
74 SECURITY_STATUS SECUR32_CreateNTLM2SubKeys(PNegoHelper helper) DECLSPEC_HIDDEN;
75 
76 /* NTLMSSP flags indicating the negotiated features */
77 #define NTLMSSP_NEGOTIATE_UNICODE                   0x00000001
78 #define NTLMSSP_NEGOTIATE_OEM                       0x00000002
79 #define NTLMSSP_REQUEST_TARGET                      0x00000004
80 #define NTLMSSP_NEGOTIATE_SIGN                      0x00000010
81 #define NTLMSSP_NEGOTIATE_SEAL                      0x00000020
82 #define NTLMSSP_NEGOTIATE_DATAGRAM_STYLE            0x00000040
83 #define NTLMSSP_NEGOTIATE_LM_SESSION_KEY            0x00000080
84 #define NTLMSSP_NEGOTIATE_NTLM                      0x00000200
85 #define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED           0x00001000
86 #define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED      0x00002000
87 #define NTLMSSP_NEGOTIATE_LOCAL_CALL                0x00004000
88 #define NTLMSSP_NEGOTIATE_ALWAYS_SIGN               0x00008000
89 #define NTLMSSP_NEGOTIATE_TARGET_TYPE_DOMAIN        0x00010000
90 #define NTLMSSP_NEGOTIATE_TARGET_TYPE_SERVER        0x00020000
91 #define NTLMSSP_NEGOTIATE_NTLM2                     0x00080000
92 #define NTLMSSP_NEGOTIATE_TARGET_INFO               0x00800000
93 #define NTLMSSP_NEGOTIATE_128                       0x20000000
94 #define NTLMSSP_NEGOTIATE_KEY_EXCHANGE              0x40000000
95 #define NTLMSSP_NEGOTIATE_56                        0x80000000
96 
97 SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW(SEC_WCHAR *, SEC_WCHAR *,
98     ULONG, PLUID, PVOID, SEC_GET_KEY_FN, PVOID, PCredHandle, PTimeStamp) DECLSPEC_HIDDEN;
99 SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(PCredHandle, PCtxtHandle,
100     SEC_WCHAR *, ULONG fContextReq, ULONG, ULONG, PSecBufferDesc, ULONG, PCtxtHandle,
101     PSecBufferDesc, ULONG *, PTimeStamp) DECLSPEC_HIDDEN;
102 SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(PCredHandle, PCtxtHandle, PSecBufferDesc,
103     ULONG, ULONG, PCtxtHandle, PSecBufferDesc, ULONG *, PTimeStamp) DECLSPEC_HIDDEN;
104 SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesA(PCtxtHandle, ULONG, void *) DECLSPEC_HIDDEN;
105 SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW(PCtxtHandle, ULONG, void *) DECLSPEC_HIDDEN;
106 SECURITY_STATUS SEC_ENTRY ntlm_EncryptMessage(PCtxtHandle, ULONG, PSecBufferDesc, ULONG) DECLSPEC_HIDDEN;
107 SECURITY_STATUS SEC_ENTRY ntlm_DecryptMessage(PCtxtHandle, PSecBufferDesc, ULONG, PULONG) DECLSPEC_HIDDEN;
108 SECURITY_STATUS SEC_ENTRY ntlm_FreeCredentialsHandle(PCredHandle) DECLSPEC_HIDDEN;
109 SECURITY_STATUS SEC_ENTRY ntlm_DeleteSecurityContext(PCtxtHandle) DECLSPEC_HIDDEN;
110 SECURITY_STATUS SEC_ENTRY ntlm_MakeSignature(PCtxtHandle, ULONG, PSecBufferDesc, ULONG) DECLSPEC_HIDDEN;
111 SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle, PSecBufferDesc, ULONG, PULONG) DECLSPEC_HIDDEN;
112 
113 extern SecPkgInfoW *ntlm_package_infoW DECLSPEC_HIDDEN;
114 extern SecPkgInfoA *ntlm_package_infoA DECLSPEC_HIDDEN;
115 
116 #endif /* __WINE_NTLM_H__ */
117