Commit 6eddbf18 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

crypt32: Store properties directly in link contexts and get rid of Context_GetProperties.

parent 275ac93e
......@@ -64,6 +64,7 @@ context_t *Context_CreateLinkContext(unsigned int contextSize, context_t *linked
context->vtbl = linked->vtbl;
context->ref = 1;
context->linked = linked;
context->properties = linked->properties;
Context_AddRef(linked);
TRACE("returning %p\n", context);
......@@ -76,16 +77,6 @@ void Context_AddRef(context_t *context)
TRACE("(%p) ref=%d\n", context, context->ref);
}
CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context)
{
BASE_CONTEXT *ptr = BASE_CONTEXT_FROM_CONTEXT(context);
while (ptr && ptr->linked)
ptr = ptr->linked;
return ptr->properties;
}
BOOL Context_Release(context_t *context)
{
BOOL ret = TRUE;
......@@ -116,8 +107,8 @@ void Context_CopyProperties(const void *to, const void *from)
{
CONTEXT_PROPERTY_LIST *toProperties, *fromProperties;
toProperties = Context_GetProperties(to);
fromProperties = Context_GetProperties(from);
toProperties = context_from_ptr(to)->properties;
fromProperties = context_from_ptr(from)->properties;
assert(toProperties && fromProperties);
ContextPropertyList_Copy(toProperties, fromProperties);
}
......
......@@ -375,22 +375,15 @@ BOOL WINAPI CertFreeCRLContext(PCCRL_CONTEXT pCrlContext)
DWORD WINAPI CertEnumCRLContextProperties(PCCRL_CONTEXT pCRLContext,
DWORD dwPropId)
{
CONTEXT_PROPERTY_LIST *properties = Context_GetProperties(pCRLContext);
DWORD ret;
TRACE("(%p, %d)\n", pCRLContext, dwPropId);
if (properties)
ret = ContextPropertyList_EnumPropIDs(properties, dwPropId);
else
ret = 0;
return ret;
return ContextPropertyList_EnumPropIDs(crl_from_ptr(pCRLContext)->base.properties, dwPropId);
}
static BOOL CRLContext_SetProperty(PCCRL_CONTEXT context, DWORD dwPropId,
static BOOL CRLContext_SetProperty(crl_t *crl, DWORD dwPropId,
DWORD dwFlags, const void *pvData);
static BOOL CRLContext_GetHashProp(PCCRL_CONTEXT context, DWORD dwPropId,
static BOOL CRLContext_GetHashProp(crl_t *crl, DWORD dwPropId,
ALG_ID algID, const BYTE *toHash, DWORD toHashLen, void *pvData,
DWORD *pcbData)
{
......@@ -400,22 +393,21 @@ static BOOL CRLContext_GetHashProp(PCCRL_CONTEXT context, DWORD dwPropId,
{
CRYPT_DATA_BLOB blob = { *pcbData, pvData };
ret = CRLContext_SetProperty(context, dwPropId, 0, &blob);
ret = CRLContext_SetProperty(crl, dwPropId, 0, &blob);
}
return ret;
}
static BOOL CRLContext_GetProperty(PCCRL_CONTEXT context, DWORD dwPropId,
static BOOL CRLContext_GetProperty(crl_t *crl, DWORD dwPropId,
void *pvData, DWORD *pcbData)
{
CONTEXT_PROPERTY_LIST *properties = Context_GetProperties(context);
BOOL ret;
CRYPT_DATA_BLOB blob;
TRACE("(%p, %d, %p, %p)\n", context, dwPropId, pvData, pcbData);
TRACE("(%p, %d, %p, %p)\n", crl, dwPropId, pvData, pcbData);
if (properties)
ret = ContextPropertyList_FindProperty(properties, dwPropId, &blob);
if (crl->base.properties)
ret = ContextPropertyList_FindProperty(crl->base.properties, dwPropId, &blob);
else
ret = FALSE;
if (ret)
......@@ -440,13 +432,13 @@ static BOOL CRLContext_GetProperty(PCCRL_CONTEXT context, DWORD dwPropId,
switch (dwPropId)
{
case CERT_SHA1_HASH_PROP_ID:
ret = CRLContext_GetHashProp(context, dwPropId, CALG_SHA1,
context->pbCrlEncoded, context->cbCrlEncoded, pvData,
ret = CRLContext_GetHashProp(crl, dwPropId, CALG_SHA1,
crl->ctx.pbCrlEncoded, crl->ctx.cbCrlEncoded, pvData,
pcbData);
break;
case CERT_MD5_HASH_PROP_ID:
ret = CRLContext_GetHashProp(context, dwPropId, CALG_MD5,
context->pbCrlEncoded, context->cbCrlEncoded, pvData,
ret = CRLContext_GetHashProp(crl, dwPropId, CALG_MD5,
crl->ctx.pbCrlEncoded, crl->ctx.cbCrlEncoded, pvData,
pcbData);
break;
default:
......@@ -498,25 +490,23 @@ BOOL WINAPI CertGetCRLContextProperty(PCCRL_CONTEXT pCRLContext,
}
break;
default:
ret = CRLContext_GetProperty(pCRLContext, dwPropId, pvData,
pcbData);
ret = CRLContext_GetProperty(crl_from_ptr(pCRLContext), dwPropId, pvData, pcbData);
}
return ret;
}
static BOOL CRLContext_SetProperty(PCCRL_CONTEXT context, DWORD dwPropId,
static BOOL CRLContext_SetProperty(crl_t *crl, DWORD dwPropId,
DWORD dwFlags, const void *pvData)
{
CONTEXT_PROPERTY_LIST *properties = Context_GetProperties(context);
BOOL ret;
TRACE("(%p, %d, %08x, %p)\n", context, dwPropId, dwFlags, pvData);
TRACE("(%p, %d, %08x, %p)\n", crl, dwPropId, dwFlags, pvData);
if (!properties)
if (!crl->base.properties)
ret = FALSE;
else if (!pvData)
{
ContextPropertyList_RemoveProperty(properties, dwPropId);
ContextPropertyList_RemoveProperty(crl->base.properties, dwPropId);
ret = TRUE;
}
else
......@@ -543,12 +533,12 @@ static BOOL CRLContext_SetProperty(PCCRL_CONTEXT context, DWORD dwPropId,
{
PCRYPT_DATA_BLOB blob = (PCRYPT_DATA_BLOB)pvData;
ret = ContextPropertyList_SetProperty(properties, dwPropId,
ret = ContextPropertyList_SetProperty(crl->base.properties, dwPropId,
blob->pbData, blob->cbData);
break;
}
case CERT_DATE_STAMP_PROP_ID:
ret = ContextPropertyList_SetProperty(properties, dwPropId,
ret = ContextPropertyList_SetProperty(crl->base.properties, dwPropId,
pvData, sizeof(FILETIME));
break;
default:
......@@ -580,7 +570,7 @@ BOOL WINAPI CertSetCRLContextProperty(PCCRL_CONTEXT pCRLContext,
SetLastError(E_INVALIDARG);
return FALSE;
}
ret = CRLContext_SetProperty(pCRLContext, dwPropId, dwFlags, pvData);
ret = CRLContext_SetProperty(crl_from_ptr(pCRLContext), dwPropId, dwFlags, pvData);
TRACE("returning %d\n", ret);
return ret;
}
......
......@@ -402,11 +402,6 @@ context_t *Context_CreateLinkContext(unsigned contextSize, context_t *linked) DE
/* Copies properties from fromContext to toContext. */
void Context_CopyProperties(const void *to, const void *from) DECLSPEC_HIDDEN;
/* Returns context's properties, or the linked context's properties if context
* is a link context.
*/
CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context) DECLSPEC_HIDDEN;
void Context_AddRef(context_t*) DECLSPEC_HIDDEN;
/* Decrements context's ref count. If context is a link context, releases its
......
......@@ -508,22 +508,22 @@ BOOL WINAPI CertFreeCTLContext(PCCTL_CONTEXT pCTLContext)
DWORD WINAPI CertEnumCTLContextProperties(PCCTL_CONTEXT pCTLContext,
DWORD dwPropId)
{
CONTEXT_PROPERTY_LIST *properties = Context_GetProperties(pCTLContext);
ctl_t *ctl = ctl_from_ptr(pCTLContext);
DWORD ret;
TRACE("(%p, %d)\n", pCTLContext, dwPropId);
if (properties)
ret = ContextPropertyList_EnumPropIDs(properties, dwPropId);
if (ctl->base.properties)
ret = ContextPropertyList_EnumPropIDs(ctl->base.properties, dwPropId);
else
ret = 0;
return ret;
}
static BOOL CTLContext_SetProperty(PCCTL_CONTEXT context, DWORD dwPropId,
static BOOL CTLContext_SetProperty(ctl_t *ctl, DWORD dwPropId,
DWORD dwFlags, const void *pvData);
static BOOL CTLContext_GetHashProp(PCCTL_CONTEXT context, DWORD dwPropId,
static BOOL CTLContext_GetHashProp(ctl_t *ctl, DWORD dwPropId,
ALG_ID algID, const BYTE *toHash, DWORD toHashLen, void *pvData,
DWORD *pcbData)
{
......@@ -533,22 +533,21 @@ static BOOL CTLContext_GetHashProp(PCCTL_CONTEXT context, DWORD dwPropId,
{
CRYPT_DATA_BLOB blob = { *pcbData, pvData };
ret = CTLContext_SetProperty(context, dwPropId, 0, &blob);
ret = CTLContext_SetProperty(ctl, dwPropId, 0, &blob);
}
return ret;
}
static BOOL CTLContext_GetProperty(PCCTL_CONTEXT context, DWORD dwPropId,
static BOOL CTLContext_GetProperty(ctl_t *ctl, DWORD dwPropId,
void *pvData, DWORD *pcbData)
{
CONTEXT_PROPERTY_LIST *properties = Context_GetProperties(context);
BOOL ret;
CRYPT_DATA_BLOB blob;
TRACE("(%p, %d, %p, %p)\n", context, dwPropId, pvData, pcbData);
TRACE("(%p, %d, %p, %p)\n", ctl, dwPropId, pvData, pcbData);
if (properties)
ret = ContextPropertyList_FindProperty(properties, dwPropId, &blob);
if (ctl->base.properties)
ret = ContextPropertyList_FindProperty(ctl->base.properties, dwPropId, &blob);
else
ret = FALSE;
if (ret)
......@@ -573,12 +572,12 @@ static BOOL CTLContext_GetProperty(PCCTL_CONTEXT context, DWORD dwPropId,
switch (dwPropId)
{
case CERT_SHA1_HASH_PROP_ID:
ret = CTLContext_GetHashProp(context, dwPropId, CALG_SHA1,
context->pbCtlEncoded, context->cbCtlEncoded, pvData, pcbData);
ret = CTLContext_GetHashProp(ctl, dwPropId, CALG_SHA1,
ctl->ctx.pbCtlEncoded, ctl->ctx.cbCtlEncoded, pvData, pcbData);
break;
case CERT_MD5_HASH_PROP_ID:
ret = CTLContext_GetHashProp(context, dwPropId, CALG_MD5,
context->pbCtlEncoded, context->cbCtlEncoded, pvData, pcbData);
ret = CTLContext_GetHashProp(ctl, dwPropId, CALG_MD5,
ctl->ctx.pbCtlEncoded, ctl->ctx.cbCtlEncoded, pvData, pcbData);
break;
default:
SetLastError(CRYPT_E_NOT_FOUND);
......@@ -629,25 +628,24 @@ BOOL WINAPI CertGetCTLContextProperty(PCCTL_CONTEXT pCTLContext,
}
break;
default:
ret = CTLContext_GetProperty(pCTLContext, dwPropId, pvData,
ret = CTLContext_GetProperty(ctl_from_ptr(pCTLContext), dwPropId, pvData,
pcbData);
}
return ret;
}
static BOOL CTLContext_SetProperty(PCCTL_CONTEXT context, DWORD dwPropId,
static BOOL CTLContext_SetProperty(ctl_t *ctl, DWORD dwPropId,
DWORD dwFlags, const void *pvData)
{
CONTEXT_PROPERTY_LIST *properties = Context_GetProperties(context);
BOOL ret;
TRACE("(%p, %d, %08x, %p)\n", context, dwPropId, dwFlags, pvData);
TRACE("(%p, %d, %08x, %p)\n", ctl, dwPropId, dwFlags, pvData);
if (!properties)
if (!ctl->base.properties)
ret = FALSE;
else if (!pvData)
{
ContextPropertyList_RemoveProperty(properties, dwPropId);
ContextPropertyList_RemoveProperty(ctl->base.properties, dwPropId);
ret = TRUE;
}
else
......@@ -674,12 +672,12 @@ static BOOL CTLContext_SetProperty(PCCTL_CONTEXT context, DWORD dwPropId,
{
PCRYPT_DATA_BLOB blob = (PCRYPT_DATA_BLOB)pvData;
ret = ContextPropertyList_SetProperty(properties, dwPropId,
ret = ContextPropertyList_SetProperty(ctl->base.properties, dwPropId,
blob->pbData, blob->cbData);
break;
}
case CERT_DATE_STAMP_PROP_ID:
ret = ContextPropertyList_SetProperty(properties, dwPropId,
ret = ContextPropertyList_SetProperty(ctl->base.properties, dwPropId,
pvData, sizeof(FILETIME));
break;
default:
......@@ -711,7 +709,7 @@ BOOL WINAPI CertSetCTLContextProperty(PCCTL_CONTEXT pCTLContext,
SetLastError(E_INVALIDARG);
return FALSE;
}
ret = CTLContext_SetProperty(pCTLContext, dwPropId, dwFlags, pvData);
ret = CTLContext_SetProperty(ctl_from_ptr(pCTLContext), dwPropId, dwFlags, pvData);
TRACE("returning %d\n", ret);
return ret;
}
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