crypt32: Support user properties for certificates.
This commit is contained in:
parent
9af7faca7c
commit
3d38e85964
3 changed files with 39 additions and 0 deletions
|
@ -714,6 +714,19 @@ static BOOL CertContext_SetProperty(cert_t *cert, DWORD dwPropId,
|
|||
|
||||
if (!cert->base.properties)
|
||||
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
|
||||
{
|
||||
switch (dwPropId)
|
||||
|
|
|
@ -405,6 +405,12 @@ static BOOL CRYPT_ReadContextProp(
|
|||
SetLastError(ERROR_FILE_NOT_FOUND);
|
||||
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 &&
|
||||
hdr->propID != CERT_CRL_PROP_ID && hdr->propID != CERT_CTL_PROP_ID)
|
||||
{
|
||||
|
|
|
@ -369,6 +369,7 @@ static void testCertProperties(void)
|
|||
BYTE hash[20] = { 0 }, hashProperty[20];
|
||||
CRYPT_DATA_BLOB blob;
|
||||
CERT_KEY_CONTEXT keyContext;
|
||||
unsigned int value;
|
||||
|
||||
ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n", GetLastError());
|
||||
|
||||
|
@ -566,6 +567,25 @@ static void testCertProperties(void)
|
|||
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);
|
||||
|
||||
context = CertCreateCertificateContext(X509_ASN_ENCODING,
|
||||
|
|
Loading…
Add table
Reference in a new issue