Commit 3d38e859 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

crypt32: Support user properties for certificates.

parent 9af7faca
...@@ -714,6 +714,19 @@ static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId, ...@@ -714,6 +714,19 @@ static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId,
if (!cert->base.properties) if (!cert->base.properties)
ret = FALSE; ret = FALSE;
else if (dwPropId >= CERT_FIRST_USER_PROP_ID && dwPropId <= CERT_LAST_USER_PROP_ID)
{
if (pvData)
{
const CRYPT_DATA_BLOB *blob = pvData;
ret = ContextPropertyList_SetProperty(cert->base.properties, dwPropId, blob->pbData, blob->cbData);
}
else
{
ContextPropertyList_RemoveProperty(cert->base.properties, dwPropId);
ret = TRUE;
}
}
else else
{ {
switch (dwPropId) switch (dwPropId)
......
...@@ -405,6 +405,12 @@ static BOOL CRYPT_ReadContextProp( ...@@ -405,6 +405,12 @@ static BOOL CRYPT_ReadContextProp(
SetLastError(ERROR_FILE_NOT_FOUND); SetLastError(ERROR_FILE_NOT_FOUND);
ret = FALSE; ret = FALSE;
} }
else if (hdr->propID >= CERT_FIRST_USER_PROP_ID && hdr->propID <= CERT_LAST_USER_PROP_ID)
{
CRYPT_DATA_BLOB blob = { hdr->cb, (LPBYTE)pbElement };
ret = contextInterface->setProp(context, hdr->propID, 0, &blob);
}
else if (hdr->propID != CERT_CERT_PROP_ID && else if (hdr->propID != CERT_CERT_PROP_ID &&
hdr->propID != CERT_CRL_PROP_ID && hdr->propID != CERT_CTL_PROP_ID) hdr->propID != CERT_CRL_PROP_ID && hdr->propID != CERT_CTL_PROP_ID)
{ {
......
...@@ -369,6 +369,7 @@ static void testCertProperties(void) ...@@ -369,6 +369,7 @@ static void testCertProperties(void)
BYTE hash[20] = { 0 }, hashProperty[20]; BYTE hash[20] = { 0 }, hashProperty[20];
CRYPT_DATA_BLOB blob; CRYPT_DATA_BLOB blob;
CERT_KEY_CONTEXT keyContext; CERT_KEY_CONTEXT keyContext;
unsigned int value;
ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError()); ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError());
...@@ -566,6 +567,25 @@ static void testCertProperties(void) ...@@ -566,6 +567,25 @@ static void testCertProperties(void)
free(buf); free(buf);
} }
} }
ret = CertGetCertificateContextProperty(context, CERT_LAST_USER_PROP_ID, NULL, &size);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "got ret %d, error %#lx.\n", ret, GetLastError());
blob.cbData = sizeof(value);
blob.pbData = (BYTE *)&value;
value = 1;
ret = CertSetCertificateContextProperty(context, CERT_LAST_USER_PROP_ID, 0, &blob);
ok(ret, "got error %#lx.\n", GetLastError());
value = 0xdeadbeef;
size = 0xdeadbeef;
ret = CertGetCertificateContextProperty(context, CERT_LAST_USER_PROP_ID, NULL, &size);
ok(ret, "got error %#lx.\n", GetLastError());
ok(size == sizeof(value), "got size %lu.\n", size);
ret = CertGetCertificateContextProperty(context, CERT_LAST_USER_PROP_ID, &value, &size);
ok(ret, "got error %#lx.\n", GetLastError());
ok(size == sizeof(value), "got size %lu.\n", size);
ok(value == 1, "got value %u.\n", value);
CertFreeCertificateContext(context); CertFreeCertificateContext(context);
context = CertCreateCertificateContext(X509_ASN_ENCODING, context = CertCreateCertificateContext(X509_ASN_ENCODING,
......
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