Jacek Caban : secur32: Pass whole schan_credentials struct to schannel backend implementations.
Alexandre Julliard
julliard at winehq.org
Mon Mar 25 14:19:40 CDT 2013
Module: wine
Branch: master
Commit: b7a75b468ab57d4e03304e587f1f74b3f4167ae2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b7a75b468ab57d4e03304e587f1f74b3f4167ae2
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Mar 25 13:55:20 2013 +0100
secur32: Pass whole schan_credentials struct to schannel backend implementations.
---
dlls/secur32/schannel.c | 14 ++++----------
dlls/secur32/schannel_gnutls.c | 15 +++++++--------
dlls/secur32/schannel_macosx.c | 13 ++++++-------
dlls/secur32/secur32_priv.h | 14 +++++++++-----
4 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c
index bf64fcd..387eaad 100644
--- a/dlls/secur32/schannel.c
+++ b/dlls/secur32/schannel.c
@@ -50,12 +50,6 @@ struct schan_handle
enum schan_handle_type type;
};
-struct schan_credentials
-{
- ULONG credential_use;
- schan_imp_certificate_credentials credentials;
-};
-
struct schan_context
{
schan_imp_session session;
@@ -316,7 +310,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
if (handle == SCHAN_INVALID_HANDLE) goto fail;
creds->credential_use = SECPKG_CRED_OUTBOUND;
- if (!schan_imp_allocate_certificate_credentials(&creds->credentials))
+ if (!schan_imp_allocate_certificate_credentials(creds))
{
schan_free_handle(handle, SCHAN_HANDLE_CRED);
goto fail;
@@ -424,7 +418,7 @@ static SECURITY_STATUS SEC_ENTRY schan_FreeCredentialsHandle(
if (!creds) return SEC_E_INVALID_HANDLE;
if (creds->credential_use == SECPKG_CRED_OUTBOUND)
- schan_imp_free_certificate_credentials(creds->credentials);
+ schan_imp_free_certificate_credentials(creds);
HeapFree(GetProcessHeap(), 0, creds);
return SEC_E_OK;
@@ -705,7 +699,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
return SEC_E_INTERNAL_ERROR;
}
- if (!schan_imp_create_session(&ctx->session, FALSE, cred->credentials))
+ if (!schan_imp_create_session(&ctx->session, cred))
{
schan_free_handle(handle, SCHAN_HANDLE_CTX);
HeapFree(GetProcessHeap(), 0, ctx);
@@ -1329,7 +1323,7 @@ void SECUR32_deinitSchannelSP(void)
{
struct schan_credentials *cred;
cred = schan_free_handle(i, SCHAN_HANDLE_CRED);
- schan_imp_free_certificate_credentials(cred->credentials);
+ schan_imp_free_certificate_credentials(cred);
HeapFree(GetProcessHeap(), 0, cred);
}
}
diff --git a/dlls/secur32/schannel_gnutls.c b/dlls/secur32/schannel_gnutls.c
index b273e96..8975b2d 100644
--- a/dlls/secur32/schannel_gnutls.c
+++ b/dlls/secur32/schannel_gnutls.c
@@ -106,12 +106,11 @@ static ssize_t schan_push_adapter(gnutls_transport_ptr_t transport,
return buff_len;
}
-BOOL schan_imp_create_session(schan_imp_session *session, BOOL is_server,
- schan_imp_certificate_credentials cred)
+BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cred)
{
gnutls_session_t *s = (gnutls_session_t*)session;
- int err = pgnutls_init(s, is_server ? GNUTLS_SERVER : GNUTLS_CLIENT);
+ int err = pgnutls_init(s, cred->credential_use == SECPKG_CRED_INBOUND ? GNUTLS_SERVER : GNUTLS_CLIENT);
if (err != GNUTLS_E_SUCCESS)
{
pgnutls_perror(err);
@@ -129,7 +128,7 @@ BOOL schan_imp_create_session(schan_imp_session *session, BOOL is_server,
}
err = pgnutls_credentials_set(*s, GNUTLS_CRD_CERTIFICATE,
- (gnutls_certificate_credentials_t)cred);
+ (gnutls_certificate_credentials_t)cred->credentials);
if (err != GNUTLS_E_SUCCESS)
{
pgnutls_perror(err);
@@ -405,17 +404,17 @@ again:
return SEC_E_OK;
}
-BOOL schan_imp_allocate_certificate_credentials(schan_imp_certificate_credentials *c)
+BOOL schan_imp_allocate_certificate_credentials(schan_credentials *c)
{
- int ret = pgnutls_certificate_allocate_credentials((gnutls_certificate_credentials*)c);
+ int ret = pgnutls_certificate_allocate_credentials((gnutls_certificate_credentials*)&c->credentials);
if (ret != GNUTLS_E_SUCCESS)
pgnutls_perror(ret);
return (ret == GNUTLS_E_SUCCESS);
}
-void schan_imp_free_certificate_credentials(schan_imp_certificate_credentials c)
+void schan_imp_free_certificate_credentials(schan_credentials *c)
{
- pgnutls_certificate_free_credentials((gnutls_certificate_credentials_t)c);
+ pgnutls_certificate_free_credentials(c->credentials);
}
static void schan_gnutls_log(int level, const char *msg)
diff --git a/dlls/secur32/schannel_macosx.c b/dlls/secur32/schannel_macosx.c
index 05b0a5e..2acb6ca 100644
--- a/dlls/secur32/schannel_macosx.c
+++ b/dlls/secur32/schannel_macosx.c
@@ -631,19 +631,18 @@ static OSStatus schan_push_adapter(SSLConnectionRef transport, const void *buff,
}
-BOOL schan_imp_create_session(schan_imp_session *session, BOOL is_server,
- schan_imp_certificate_credentials cred)
+BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cred)
{
struct mac_session *s;
OSStatus status;
- TRACE("(%p, %d)\n", session, is_server);
+ TRACE("(%p)\n", session);
s = HeapAlloc(GetProcessHeap(), 0, sizeof(*s));
if (!s)
return FALSE;
- status = SSLNewContext(is_server, &s->context);
+ status = SSLNewContext(cred->credential_use == SECPKG_CRED_INBOUND, &s->context);
if (status != noErr)
{
ERR("Failed to create session context: %ld\n", (long)status);
@@ -966,14 +965,14 @@ SECURITY_STATUS schan_imp_recv(schan_imp_session session, void *buffer,
return SEC_E_OK;
}
-BOOL schan_imp_allocate_certificate_credentials(schan_imp_certificate_credentials *c)
+BOOL schan_imp_allocate_certificate_credentials(schan_credentials *c)
{
/* The certificate is never really used for anything. */
- *c = NULL;
+ c->credentials = NULL;
return TRUE;
}
-void schan_imp_free_certificate_credentials(schan_imp_certificate_credentials c)
+void schan_imp_free_certificate_credentials(schan_credentials *c)
{
}
diff --git a/dlls/secur32/secur32_priv.h b/dlls/secur32/secur32_priv.h
index 164a2eb..bc4b74b 100644
--- a/dlls/secur32/secur32_priv.h
+++ b/dlls/secur32/secur32_priv.h
@@ -209,7 +209,12 @@ SecPkgInfoA *ntlm_package_infoA;
/* schannel internal interface */
typedef struct schan_imp_session_opaque *schan_imp_session;
-typedef struct schan_imp_certificate_credentials_opaque *schan_imp_certificate_credentials;
+
+typedef struct schan_credentials
+{
+ ULONG credential_use;
+ void *credentials;
+} schan_credentials;
struct schan_transport;
@@ -237,8 +242,7 @@ extern int schan_push(struct schan_transport *t, const void *buff, size_t *buff_
extern schan_imp_session schan_session_for_transport(struct schan_transport* t) DECLSPEC_HIDDEN;
/* schannel implementation interface */
-extern BOOL schan_imp_create_session(schan_imp_session *session, BOOL is_server,
- schan_imp_certificate_credentials cred) DECLSPEC_HIDDEN;
+extern BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cred) DECLSPEC_HIDDEN;
extern void schan_imp_dispose_session(schan_imp_session session) DECLSPEC_HIDDEN;
extern void schan_imp_set_session_transport(schan_imp_session session,
struct schan_transport *t) DECLSPEC_HIDDEN;
@@ -253,8 +257,8 @@ extern SECURITY_STATUS schan_imp_send(schan_imp_session session, const void *buf
SIZE_T *length) DECLSPEC_HIDDEN;
extern SECURITY_STATUS schan_imp_recv(schan_imp_session session, void *buffer,
SIZE_T *length) DECLSPEC_HIDDEN;
-extern BOOL schan_imp_allocate_certificate_credentials(schan_imp_certificate_credentials *c) DECLSPEC_HIDDEN;
-extern void schan_imp_free_certificate_credentials(schan_imp_certificate_credentials c) DECLSPEC_HIDDEN;
+extern BOOL schan_imp_allocate_certificate_credentials(schan_credentials*) DECLSPEC_HIDDEN;
+extern void schan_imp_free_certificate_credentials(schan_credentials*) DECLSPEC_HIDDEN;
extern BOOL schan_imp_init(void) DECLSPEC_HIDDEN;
extern void schan_imp_deinit(void) DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list