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

This commit is contained in:
Jacek Caban 2013-10-17 11:07:24 +02:00 committed by Alexandre Julliard
parent 275ac93e8d
commit 6eddbf18ca
5 changed files with 93 additions and 121 deletions

View File

@ -38,7 +38,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(crypt);
* CertGetCertificateContextProperty, and are particular to the store in which * CertGetCertificateContextProperty, and are particular to the store in which
* the property exists (which is separate from the context.) * the property exists (which is separate from the context.)
*/ */
static BOOL CertContext_GetProperty(void *context, DWORD dwPropId, static BOOL CertContext_GetProperty(cert_t *cert, DWORD dwPropId,
void *pvData, DWORD *pcbData); void *pvData, DWORD *pcbData);
/* Internal version of CertSetCertificateContextProperty that sets properties /* Internal version of CertSetCertificateContextProperty that sets properties
@ -46,7 +46,7 @@ static BOOL CertContext_GetProperty(void *context, DWORD dwPropId,
* type.) Doesn't handle special cases, since they're handled by * type.) Doesn't handle special cases, since they're handled by
* CertSetCertificateContextProperty anyway. * CertSetCertificateContextProperty anyway.
*/ */
static BOOL CertContext_SetProperty(void *context, DWORD dwPropId, static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId,
DWORD dwFlags, const void *pvData); DWORD dwFlags, const void *pvData);
BOOL WINAPI CertAddEncodedCertificateToStore(HCERTSTORE hCertStore, BOOL WINAPI CertAddEncodedCertificateToStore(HCERTSTORE hCertStore,
@ -380,19 +380,19 @@ BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
DWORD WINAPI CertEnumCertificateContextProperties(PCCERT_CONTEXT pCertContext, DWORD WINAPI CertEnumCertificateContextProperties(PCCERT_CONTEXT pCertContext,
DWORD dwPropId) DWORD dwPropId)
{ {
CONTEXT_PROPERTY_LIST *properties = Context_GetProperties(pCertContext); cert_t *cert = cert_from_ptr(pCertContext);
DWORD ret; DWORD ret;
TRACE("(%p, %d)\n", pCertContext, dwPropId); TRACE("(%p, %d)\n", pCertContext, dwPropId);
if (properties) if (cert->base.properties)
ret = ContextPropertyList_EnumPropIDs(properties, dwPropId); ret = ContextPropertyList_EnumPropIDs(cert->base.properties, dwPropId);
else else
ret = 0; ret = 0;
return ret; return ret;
} }
static BOOL CertContext_GetHashProp(void *context, DWORD dwPropId, static BOOL CertContext_GetHashProp(cert_t *cert, 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)
{ {
@ -402,7 +402,7 @@ static BOOL CertContext_GetHashProp(void *context, DWORD dwPropId,
{ {
CRYPT_DATA_BLOB blob = { *pcbData, pvData }; CRYPT_DATA_BLOB blob = { *pcbData, pvData };
ret = CertContext_SetProperty(context, dwPropId, 0, &blob); ret = CertContext_SetProperty(cert, dwPropId, 0, &blob);
} }
return ret; return ret;
} }
@ -428,18 +428,16 @@ static BOOL CertContext_CopyParam(void *pvData, DWORD *pcbData, const void *pb,
return ret; return ret;
} }
static BOOL CertContext_GetProperty(void *context, DWORD dwPropId, static BOOL CertContext_GetProperty(cert_t *cert, DWORD dwPropId,
void *pvData, DWORD *pcbData) void *pvData, DWORD *pcbData)
{ {
PCCERT_CONTEXT pCertContext = context;
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", cert, dwPropId, pvData, pcbData);
if (properties) if (cert->base.properties)
ret = ContextPropertyList_FindProperty(properties, dwPropId, &blob); ret = ContextPropertyList_FindProperty(cert->base.properties, dwPropId, &blob);
else else
ret = FALSE; ret = FALSE;
if (ret) if (ret)
@ -450,49 +448,49 @@ static BOOL CertContext_GetProperty(void *context, DWORD dwPropId,
switch (dwPropId) switch (dwPropId)
{ {
case CERT_SHA1_HASH_PROP_ID: case CERT_SHA1_HASH_PROP_ID:
ret = CertContext_GetHashProp(context, dwPropId, CALG_SHA1, ret = CertContext_GetHashProp(cert, dwPropId, CALG_SHA1,
pCertContext->pbCertEncoded, pCertContext->cbCertEncoded, pvData, cert->ctx.pbCertEncoded, cert->ctx.cbCertEncoded, pvData,
pcbData); pcbData);
break; break;
case CERT_MD5_HASH_PROP_ID: case CERT_MD5_HASH_PROP_ID:
ret = CertContext_GetHashProp(context, dwPropId, CALG_MD5, ret = CertContext_GetHashProp(cert, dwPropId, CALG_MD5,
pCertContext->pbCertEncoded, pCertContext->cbCertEncoded, pvData, cert->ctx.pbCertEncoded, cert->ctx.cbCertEncoded, pvData,
pcbData); pcbData);
break; break;
case CERT_SUBJECT_NAME_MD5_HASH_PROP_ID: case CERT_SUBJECT_NAME_MD5_HASH_PROP_ID:
ret = CertContext_GetHashProp(context, dwPropId, CALG_MD5, ret = CertContext_GetHashProp(cert, dwPropId, CALG_MD5,
pCertContext->pCertInfo->Subject.pbData, cert->ctx.pCertInfo->Subject.pbData,
pCertContext->pCertInfo->Subject.cbData, cert->ctx.pCertInfo->Subject.cbData,
pvData, pcbData); pvData, pcbData);
break; break;
case CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID: case CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID:
ret = CertContext_GetHashProp(context, dwPropId, CALG_MD5, ret = CertContext_GetHashProp(cert, dwPropId, CALG_MD5,
pCertContext->pCertInfo->SubjectPublicKeyInfo.PublicKey.pbData, cert->ctx.pCertInfo->SubjectPublicKeyInfo.PublicKey.pbData,
pCertContext->pCertInfo->SubjectPublicKeyInfo.PublicKey.cbData, cert->ctx.pCertInfo->SubjectPublicKeyInfo.PublicKey.cbData,
pvData, pcbData); pvData, pcbData);
break; break;
case CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID: case CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID:
ret = CertContext_GetHashProp(context, dwPropId, CALG_MD5, ret = CertContext_GetHashProp(cert, dwPropId, CALG_MD5,
pCertContext->pCertInfo->SerialNumber.pbData, cert->ctx.pCertInfo->SerialNumber.pbData,
pCertContext->pCertInfo->SerialNumber.cbData, cert->ctx.pCertInfo->SerialNumber.cbData,
pvData, pcbData); pvData, pcbData);
break; break;
case CERT_SIGNATURE_HASH_PROP_ID: case CERT_SIGNATURE_HASH_PROP_ID:
ret = CryptHashToBeSigned(0, pCertContext->dwCertEncodingType, ret = CryptHashToBeSigned(0, cert->ctx.dwCertEncodingType,
pCertContext->pbCertEncoded, pCertContext->cbCertEncoded, pvData, cert->ctx.pbCertEncoded, cert->ctx.cbCertEncoded, pvData,
pcbData); pcbData);
if (ret && pvData) if (ret && pvData)
{ {
CRYPT_DATA_BLOB blob = { *pcbData, pvData }; CRYPT_DATA_BLOB blob = { *pcbData, pvData };
ret = CertContext_SetProperty(context, dwPropId, 0, &blob); ret = CertContext_SetProperty(cert, dwPropId, 0, &blob);
} }
break; break;
case CERT_KEY_IDENTIFIER_PROP_ID: case CERT_KEY_IDENTIFIER_PROP_ID:
{ {
PCERT_EXTENSION ext = CertFindExtension( PCERT_EXTENSION ext = CertFindExtension(
szOID_SUBJECT_KEY_IDENTIFIER, pCertContext->pCertInfo->cExtension, szOID_SUBJECT_KEY_IDENTIFIER, cert->ctx.pCertInfo->cExtension,
pCertContext->pCertInfo->rgExtension); cert->ctx.pCertInfo->rgExtension);
if (ext) if (ext)
{ {
@ -507,7 +505,7 @@ static BOOL CertContext_GetProperty(void *context, DWORD dwPropId,
{ {
ret = CertContext_CopyParam(pvData, pcbData, value.pbData, ret = CertContext_CopyParam(pvData, pcbData, value.pbData,
value.cbData); value.cbData);
CertContext_SetProperty(context, dwPropId, 0, &value); CertContext_SetProperty(cert, dwPropId, 0, &value);
} }
} }
else else
@ -548,6 +546,7 @@ void CRYPT_FixKeyProvInfoPointers(PCRYPT_KEY_PROV_INFO info)
BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext, BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext,
DWORD dwPropId, void *pvData, DWORD *pcbData) DWORD dwPropId, void *pvData, DWORD *pcbData)
{ {
cert_t *cert = cert_from_ptr(pCertContext);
BOOL ret; BOOL ret;
TRACE("(%p, %d, %p, %p)\n", pCertContext, dwPropId, pvData, pcbData); TRACE("(%p, %d, %p, %p)\n", pCertContext, dwPropId, pvData, pcbData);
@ -577,7 +576,7 @@ BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext,
CERT_KEY_CONTEXT keyContext; CERT_KEY_CONTEXT keyContext;
DWORD size = sizeof(keyContext); DWORD size = sizeof(keyContext);
ret = CertContext_GetProperty((void *)pCertContext, ret = CertContext_GetProperty(cert,
CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size); CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size);
if (ret) if (ret)
ret = CertContext_CopyParam(pvData, pcbData, &keyContext.hCryptProv, ret = CertContext_CopyParam(pvData, pcbData, &keyContext.hCryptProv,
@ -585,13 +584,13 @@ BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext,
break; break;
} }
case CERT_KEY_PROV_INFO_PROP_ID: case CERT_KEY_PROV_INFO_PROP_ID:
ret = CertContext_GetProperty((void *)pCertContext, dwPropId, pvData, ret = CertContext_GetProperty(cert, dwPropId, pvData,
pcbData); pcbData);
if (ret && pvData) if (ret && pvData)
CRYPT_FixKeyProvInfoPointers(pvData); CRYPT_FixKeyProvInfoPointers(pvData);
break; break;
default: default:
ret = CertContext_GetProperty((void *)pCertContext, dwPropId, pvData, ret = CertContext_GetProperty(cert, dwPropId, pvData,
pcbData); pcbData);
} }
@ -679,15 +678,14 @@ static BOOL CertContext_SetKeyProvInfoProperty(CONTEXT_PROPERTY_LIST *properties
return ret; return ret;
} }
static BOOL CertContext_SetProperty(void *context, DWORD dwPropId, static BOOL CertContext_SetProperty(cert_t *cert, 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", cert, dwPropId, dwFlags, pvData);
if (!properties) if (!cert->base.properties)
ret = FALSE; ret = FALSE;
else else
{ {
@ -716,23 +714,23 @@ static BOOL CertContext_SetProperty(void *context, DWORD dwPropId,
{ {
const CRYPT_DATA_BLOB *blob = pvData; const CRYPT_DATA_BLOB *blob = pvData;
ret = ContextPropertyList_SetProperty(properties, dwPropId, ret = ContextPropertyList_SetProperty(cert->base.properties, dwPropId,
blob->pbData, blob->cbData); blob->pbData, blob->cbData);
} }
else else
{ {
ContextPropertyList_RemoveProperty(properties, dwPropId); ContextPropertyList_RemoveProperty(cert->base.properties, dwPropId);
ret = TRUE; ret = TRUE;
} }
break; break;
} }
case CERT_DATE_STAMP_PROP_ID: case CERT_DATE_STAMP_PROP_ID:
if (pvData) if (pvData)
ret = ContextPropertyList_SetProperty(properties, dwPropId, ret = ContextPropertyList_SetProperty(cert->base.properties, dwPropId,
pvData, sizeof(FILETIME)); pvData, sizeof(FILETIME));
else else
{ {
ContextPropertyList_RemoveProperty(properties, dwPropId); ContextPropertyList_RemoveProperty(cert->base.properties, dwPropId);
ret = TRUE; ret = TRUE;
} }
break; break;
@ -748,22 +746,22 @@ static BOOL CertContext_SetProperty(void *context, DWORD dwPropId,
ret = FALSE; ret = FALSE;
} }
else else
ret = ContextPropertyList_SetProperty(properties, dwPropId, ret = ContextPropertyList_SetProperty(cert->base.properties, dwPropId,
(const BYTE *)keyContext, keyContext->cbSize); (const BYTE *)keyContext, keyContext->cbSize);
} }
else else
{ {
ContextPropertyList_RemoveProperty(properties, dwPropId); ContextPropertyList_RemoveProperty(cert->base.properties, dwPropId);
ret = TRUE; ret = TRUE;
} }
break; break;
} }
case CERT_KEY_PROV_INFO_PROP_ID: case CERT_KEY_PROV_INFO_PROP_ID:
if (pvData) if (pvData)
ret = CertContext_SetKeyProvInfoProperty(properties, pvData); ret = CertContext_SetKeyProvInfoProperty(cert->base.properties, pvData);
else else
{ {
ContextPropertyList_RemoveProperty(properties, dwPropId); ContextPropertyList_RemoveProperty(cert->base.properties, dwPropId);
ret = TRUE; ret = TRUE;
} }
break; break;
@ -772,7 +770,7 @@ static BOOL CertContext_SetProperty(void *context, DWORD dwPropId,
CERT_KEY_CONTEXT keyContext; CERT_KEY_CONTEXT keyContext;
DWORD size = sizeof(keyContext); DWORD size = sizeof(keyContext);
ret = CertContext_GetProperty(context, CERT_KEY_CONTEXT_PROP_ID, ret = CertContext_GetProperty(cert, CERT_KEY_CONTEXT_PROP_ID,
&keyContext, &size); &keyContext, &size);
if (ret) if (ret)
{ {
@ -787,7 +785,7 @@ static BOOL CertContext_SetProperty(void *context, DWORD dwPropId,
keyContext.hCryptProv = 0; keyContext.hCryptProv = 0;
keyContext.dwKeySpec = AT_SIGNATURE; keyContext.dwKeySpec = AT_SIGNATURE;
} }
ret = CertContext_SetProperty(context, CERT_KEY_CONTEXT_PROP_ID, ret = CertContext_SetProperty(cert, CERT_KEY_CONTEXT_PROP_ID,
0, &keyContext); 0, &keyContext);
break; break;
} }
@ -820,7 +818,7 @@ BOOL WINAPI CertSetCertificateContextProperty(PCCERT_CONTEXT pCertContext,
SetLastError(E_INVALIDARG); SetLastError(E_INVALIDARG);
return FALSE; return FALSE;
} }
ret = CertContext_SetProperty((void *)pCertContext, dwPropId, dwFlags, ret = CertContext_SetProperty(cert_from_ptr(pCertContext), dwPropId, dwFlags,
pvData); pvData);
TRACE("returning %d\n", ret); TRACE("returning %d\n", ret);
return ret; return ret;

View File

@ -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)
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)
{ {
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);
} }

View File

@ -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,
{ {
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,
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,
} }
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,
{ {
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,
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;
} }

View File

@ -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

View File

@ -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,
{ {
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,
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,
} }
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,
{ {
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,
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;
} }