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