Commit 49165c25 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

crypt32: Store CERT_KEY_CONTEXT in a platform independent way.

parent 53d95670
......@@ -428,6 +428,13 @@ static BOOL CertContext_CopyParam(void *pvData, DWORD *pcbData, const void *pb,
return ret;
}
void CRYPT_ConvertKeyContext(const struct store_CERT_KEY_CONTEXT *src, CERT_KEY_CONTEXT *dst)
{
dst->cbSize = sizeof(*dst);
dst->hCryptProv = src->hCryptProv;
dst->dwKeySpec = src->dwKeySpec;
}
static BOOL CertContext_GetProperty(cert_t *cert, DWORD dwPropId,
void *pvData, DWORD *pcbData)
{
......@@ -441,7 +448,16 @@ static BOOL CertContext_GetProperty(cert_t *cert, DWORD dwPropId,
else
ret = FALSE;
if (ret)
{
CERT_KEY_CONTEXT ctx;
if (dwPropId == CERT_KEY_CONTEXT_PROP_ID)
{
CRYPT_ConvertKeyContext((const struct store_CERT_KEY_CONTEXT *)blob.pbData, &ctx);
blob.pbData = (BYTE *)&ctx;
blob.cbData = ctx.cbSize;
}
ret = CertContext_CopyParam(pvData, pcbData, blob.pbData, blob.cbData);
}
else
{
/* Implicit properties */
......@@ -732,6 +748,19 @@ static BOOL CertContext_SetKeyProvInfoProperty(CONTEXT_PROPERTY_LIST *properties
return ret;
}
static BOOL CertContext_SetKeyContextProperty(CONTEXT_PROPERTY_LIST *properties,
const CERT_KEY_CONTEXT *keyContext)
{
struct store_CERT_KEY_CONTEXT ctx;
ctx.cbSize = sizeof(ctx);
ctx.hCryptProv = keyContext->hCryptProv;
ctx.dwKeySpec = keyContext->dwKeySpec;
return ContextPropertyList_SetProperty(properties, CERT_KEY_CONTEXT_PROP_ID,
(const BYTE *)&ctx, ctx.cbSize);
}
static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId,
DWORD dwFlags, const void *pvData)
{
......@@ -790,7 +819,6 @@ static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId,
}
break;
case CERT_KEY_CONTEXT_PROP_ID:
{
if (pvData)
{
const CERT_KEY_CONTEXT *keyContext = pvData;
......@@ -801,8 +829,7 @@ static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId,
ret = FALSE;
}
else
ret = ContextPropertyList_SetProperty(cert->base.properties, dwPropId,
(const BYTE *)keyContext, keyContext->cbSize);
ret = CertContext_SetKeyContextProperty(cert->base.properties, pvData);
}
else
{
......@@ -810,7 +837,6 @@ static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId,
ret = TRUE;
}
break;
}
case CERT_KEY_PROV_INFO_PROP_ID:
if (pvData)
ret = CertContext_SetKeyProvInfoProperty(cert->base.properties, pvData);
......
......@@ -378,6 +378,14 @@ BOOL CRYPT_ReadSerializedStoreFromBlob(const CRYPT_DATA_BLOB *blob,
*/
void CRYPT_FixKeyProvInfoPointers(PCRYPT_KEY_PROV_INFO info) DECLSPEC_HIDDEN;
struct store_CERT_KEY_CONTEXT
{
DWORD cbSize;
DWORD64 hCryptProv;
DWORD dwKeySpec;
};
void CRYPT_ConvertKeyContext(const struct store_CERT_KEY_CONTEXT *src, CERT_KEY_CONTEXT *dst) DECLSPEC_HIDDEN;
/**
* String functions
*/
......
......@@ -280,6 +280,13 @@ static BOOL CRYPT_ReadContextProp(
hdr->propID, 0, pbElement);
break;
}
case CERT_KEY_CONTEXT_PROP_ID:
{
CERT_KEY_CONTEXT ctx;
CRYPT_ConvertKeyContext((struct store_CERT_KEY_CONTEXT *)pbElement, &ctx);
ret = contextInterface->setProp(context, hdr->propID, 0, &ctx);
break;
}
default:
ret = FALSE;
}
......
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