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