Commit b605d822 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

secur32: Reduce indentation level in schan_QueryContextAttributesA/W().

parent 472150bf
......@@ -1150,13 +1150,12 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
struct schan_context *ctx;
SECURITY_STATUS status;
TRACE("context_handle %p, attribute %#lx, buffer %p\n",
context_handle, attribute, buffer);
TRACE("context_handle %p, attribute %#lx, buffer %p\n", context_handle, attribute, buffer);
if (!context_handle || !(ctx = schan_get_object(context_handle->dwLower, SCHAN_HANDLE_CTX)))
return SEC_E_INVALID_HANDLE;
switch(attribute)
switch (attribute)
{
case SECPKG_ATTR_STREAM_SIZES:
{
......@@ -1205,10 +1204,7 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
{
PCCERT_CONTEXT *cert = buffer;
status = ensure_remote_cert(ctx);
if(status != SEC_E_OK)
return status;
if ((status = ensure_remote_cert(ctx)) != SEC_E_OK) return status;
*cert = CertDuplicateCertificateContext(ctx->cert);
return SEC_E_OK;
}
......@@ -1220,42 +1216,36 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
}
case SECPKG_ATTR_ENDPOINT_BINDINGS:
{
static const char prefix[] = "tls-server-end-point:";
SecPkgContext_Bindings *bindings = buffer;
CCRYPT_OID_INFO *info;
ALG_ID hash_alg = CALG_SHA_256;
BYTE hash[1024];
DWORD hash_size;
char *p;
BOOL r;
static const char prefix[] = "tls-server-end-point:";
BOOL ret;
status = ensure_remote_cert(ctx);
if(status != SEC_E_OK)
return status;
if ((status = ensure_remote_cert(ctx)) != SEC_E_OK) return status;
/* RFC 5929 */
info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, ctx->cert->pCertInfo->SignatureAlgorithm.pszObjId, 0);
if(info && info->u.Algid != CALG_SHA1 && info->u.Algid != CALG_MD5)
hash_alg = info->u.Algid;
if (info && info->u.Algid != CALG_SHA1 && info->u.Algid != CALG_MD5) hash_alg = info->u.Algid;
hash_size = sizeof(hash);
r = CryptHashCertificate(0, hash_alg, 0, ctx->cert->pbCertEncoded, ctx->cert->cbCertEncoded, hash, &hash_size);
if(!r)
return GetLastError();
ret = CryptHashCertificate(0, hash_alg, 0, ctx->cert->pbCertEncoded, ctx->cert->cbCertEncoded, hash, &hash_size);
if (!ret) return GetLastError();
bindings->BindingsLength = sizeof(*bindings->Bindings) + sizeof(prefix)-1 + hash_size;
bindings->BindingsLength = sizeof(*bindings->Bindings) + sizeof(prefix) - 1 + hash_size;
/* freed with FreeContextBuffer */
bindings->Bindings = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, bindings->BindingsLength);
if(!bindings->Bindings)
return SEC_E_INSUFFICIENT_MEMORY;
if (!bindings->Bindings) return SEC_E_INSUFFICIENT_MEMORY;
bindings->Bindings->cbApplicationDataLength = sizeof(prefix)-1 + hash_size;
bindings->Bindings->cbApplicationDataLength = sizeof(prefix) - 1 + hash_size;
bindings->Bindings->dwApplicationDataOffset = sizeof(*bindings->Bindings);
p = (char*)(bindings->Bindings+1);
memcpy(p, prefix, sizeof(prefix)-1);
p += sizeof(prefix)-1;
p = (char *)(bindings->Bindings + 1);
memcpy(p, prefix, sizeof(prefix) - 1);
p += sizeof(prefix) - 1;
memcpy(p, hash, hash_size);
return SEC_E_OK;
}
......@@ -1270,18 +1260,17 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
if (GNUTLS_CALL( get_unique_channel_binding, &params ) != SEC_E_BUFFER_TOO_SMALL)
return SEC_E_INTERNAL_ERROR;
bindings->BindingsLength = sizeof(*bindings->Bindings) + sizeof(prefix)-1 + size;
bindings->BindingsLength = sizeof(*bindings->Bindings) + sizeof(prefix) - 1 + size;
/* freed with FreeContextBuffer */
bindings->Bindings = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, bindings->BindingsLength);
if(!bindings->Bindings)
return SEC_E_INSUFFICIENT_MEMORY;
if (!bindings->Bindings) return SEC_E_INSUFFICIENT_MEMORY;
bindings->Bindings->cbApplicationDataLength = sizeof(prefix)-1 + size;
bindings->Bindings->cbApplicationDataLength = sizeof(prefix) - 1 + size;
bindings->Bindings->dwApplicationDataOffset = sizeof(*bindings->Bindings);
p = (char*)(bindings->Bindings+1);
memcpy(p, prefix, sizeof(prefix)-1);
p += sizeof(prefix)-1;
p = (char *)(bindings->Bindings + 1);
memcpy(p, prefix, sizeof(prefix) - 1);
p += sizeof(prefix) - 1;
params.buffer = p;
return GNUTLS_CALL( get_unique_channel_binding, &params );
}
......@@ -1297,7 +1286,6 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
struct get_cipher_info_params params = { ctx->session, info };
return GNUTLS_CALL( get_cipher_info, &params );
}
default:
FIXME("Unhandled attribute %#lx\n", attribute);
return SEC_E_UNSUPPORTED_FUNCTION;
......@@ -1307,13 +1295,10 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesA(
PCtxtHandle context_handle, ULONG attribute, PVOID buffer)
{
TRACE("context_handle %p, attribute %#lx, buffer %p\n",
context_handle, attribute, buffer);
TRACE("context_handle %p, attribute %#lx, buffer %p\n", context_handle, attribute, buffer);
switch(attribute)
{
case SECPKG_ATTR_STREAM_SIZES:
return schan_QueryContextAttributesW(context_handle, attribute, buffer);
case SECPKG_ATTR_KEY_INFO:
{
SECURITY_STATUS status = schan_QueryContextAttributesW(context_handle, attribute, buffer);
......@@ -1325,16 +1310,12 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesA(
}
return status;
}
case SECPKG_ATTR_STREAM_SIZES:
case SECPKG_ATTR_REMOTE_CERT_CONTEXT:
return schan_QueryContextAttributesW(context_handle, attribute, buffer);
case SECPKG_ATTR_CONNECTION_INFO:
return schan_QueryContextAttributesW(context_handle, attribute, buffer);
case SECPKG_ATTR_ENDPOINT_BINDINGS:
return schan_QueryContextAttributesW(context_handle, attribute, buffer);
case SECPKG_ATTR_UNIQUE_BINDINGS:
return schan_QueryContextAttributesW(context_handle, attribute, buffer);
case SECPKG_ATTR_APPLICATION_PROTOCOL:
return schan_QueryContextAttributesW(context_handle, attribute, buffer);
case SECPKG_ATTR_CIPHER_INFO:
return schan_QueryContextAttributesW(context_handle, attribute, buffer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment