[SECUR32]
[reactos.git] / reactos / dll / win32 / schannel / schannel_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 __SCHANNEL_PRIV_H__
22 #define __SCHANNEL_PRIV_H__
23
24 typedef struct _SecureProvider
25 {
26 struct list entry;
27 BOOL loaded;
28 PWSTR moduleName;
29 HMODULE lib;
30 } SecureProvider;
31
32 typedef struct _SecurePackage
33 {
34 struct list entry;
35 SecPkgInfoW infoW;
36 SecureProvider *provider;
37 } SecurePackage;
38
39 /* Allocates space for and initializes a new provider. If fnTableA or fnTableW
40 * is non-NULL, assumes the provider is built-in, and if moduleName is non-NULL,
41 * means must load the LSA/user mode functions tables from external SSP/AP module.
42 * Otherwise moduleName must not be NULL.
43 * Returns a pointer to the stored provider entry, for use adding packages.
44 */
45 SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
46 const SecurityFunctionTableW *fnTableW, PCWSTR moduleName) DECLSPEC_HIDDEN;
47
48 /* Allocates space for and adds toAdd packages with the given provider.
49 * provider must not be NULL, and either infoA or infoW may be NULL, but not
50 * both.
51 */
52 void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
53 const SecPkgInfoA *infoA, const SecPkgInfoW *infoW) DECLSPEC_HIDDEN;
54
55 /* Initialization functions for built-in providers */
56 void SECUR32_initSchannelSP(void) DECLSPEC_HIDDEN;
57
58 /* schannel internal interface */
59 typedef struct schan_imp_session_opaque *schan_imp_session;
60
61 typedef struct schan_credentials
62 {
63 ULONG credential_use;
64 void *credentials;
65 DWORD enabled_protocols;
66 } schan_credentials;
67
68 struct schan_transport;
69
70 struct schan_buffers
71 {
72 SIZE_T offset;
73 SIZE_T limit;
74 const SecBufferDesc *desc;
75 int current_buffer_idx;
76 BOOL allow_buffer_resize;
77 int (*get_next_buffer)(const struct schan_transport *, struct schan_buffers *);
78 };
79
80 struct schan_transport
81 {
82 struct schan_context *ctx;
83 struct schan_buffers in;
84 struct schan_buffers out;
85 };
86
87 char *schan_get_buffer(const struct schan_transport *t, struct schan_buffers *s, SIZE_T *count) DECLSPEC_HIDDEN;
88 extern int schan_pull(struct schan_transport *t, void *buff, size_t *buff_len) DECLSPEC_HIDDEN;
89 extern int schan_push(struct schan_transport *t, const void *buff, size_t *buff_len) DECLSPEC_HIDDEN;
90
91 extern schan_imp_session schan_session_for_transport(struct schan_transport* t) DECLSPEC_HIDDEN;
92
93 /* schannel implementation interface */
94 extern BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cred) DECLSPEC_HIDDEN;
95 extern void schan_imp_dispose_session(schan_imp_session session) DECLSPEC_HIDDEN;
96 extern void schan_imp_set_session_transport(schan_imp_session session,
97 struct schan_transport *t) DECLSPEC_HIDDEN;
98 extern void schan_imp_set_session_target(schan_imp_session session, const char *target) DECLSPEC_HIDDEN;
99 extern SECURITY_STATUS schan_imp_handshake(schan_imp_session session) DECLSPEC_HIDDEN;
100 extern unsigned int schan_imp_get_session_cipher_block_size(schan_imp_session session) DECLSPEC_HIDDEN;
101 extern unsigned int schan_imp_get_max_message_size(schan_imp_session session) DECLSPEC_HIDDEN;
102 extern SECURITY_STATUS schan_imp_get_connection_info(schan_imp_session session,
103 SecPkgContext_ConnectionInfo *info) DECLSPEC_HIDDEN;
104 extern SECURITY_STATUS schan_imp_get_session_peer_certificate(schan_imp_session session, HCERTSTORE,
105 PCCERT_CONTEXT *cert) DECLSPEC_HIDDEN;
106 extern SECURITY_STATUS schan_imp_send(schan_imp_session session, const void *buffer,
107 SIZE_T *length) DECLSPEC_HIDDEN;
108 extern SECURITY_STATUS schan_imp_recv(schan_imp_session session, void *buffer,
109 SIZE_T *length) DECLSPEC_HIDDEN;
110 extern BOOL schan_imp_allocate_certificate_credentials(schan_credentials*) DECLSPEC_HIDDEN;
111 extern void schan_imp_free_certificate_credentials(schan_credentials*) DECLSPEC_HIDDEN;
112 extern DWORD schan_imp_enabled_protocols(void) DECLSPEC_HIDDEN;
113 extern BOOL schan_imp_init(void) DECLSPEC_HIDDEN;
114 extern void schan_imp_deinit(void) DECLSPEC_HIDDEN;
115
116 SECURITY_STATUS
117 WINAPI
118 schan_FreeContextBuffer (
119 PVOID pvoid
120 );
121 SECURITY_STATUS WINAPI schan_EnumerateSecurityPackagesA(PULONG pcPackages,
122 PSecPkgInfoA *ppPackageInfo);
123 SECURITY_STATUS WINAPI schan_EnumerateSecurityPackagesW(PULONG pcPackages,
124 PSecPkgInfoW *ppPackageInfo);
125 extern SecurityFunctionTableA schanTableA;
126 extern SecurityFunctionTableW schanTableW;
127
128 #endif /* ndef __SCHANNEL_PRIV_H__ */
129
130