Commit 5e6490a8 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

cryptnet: Add support for base64 encoded certificates, CRLs and CTLs in CryptRetrieveObjectByUrl.

parent 7eddb864
...@@ -1184,10 +1184,27 @@ static BOOL WINAPI CRYPT_CreateBlob(LPCSTR pszObjectOid, ...@@ -1184,10 +1184,27 @@ static BOOL WINAPI CRYPT_CreateBlob(LPCSTR pszObjectOid,
typedef BOOL (WINAPI *AddContextToStore)(HCERTSTORE hCertStore, typedef BOOL (WINAPI *AddContextToStore)(HCERTSTORE hCertStore,
const void *pContext, DWORD dwAddDisposition, const void **ppStoreContext); const void *pContext, DWORD dwAddDisposition, const void **ppStoreContext);
static BOOL decode_base64_blob( const CRYPT_DATA_BLOB *in, CRYPT_DATA_BLOB *out )
{
BOOL ret;
DWORD len = in->cbData;
while (len && !in->pbData[len - 1]) len--;
if (!CryptStringToBinaryA( (char *)in->pbData, len, CRYPT_STRING_BASE64_ANY,
NULL, &out->cbData, NULL, NULL )) return FALSE;
if (!(out->pbData = CryptMemAlloc( out->cbData ))) return FALSE;
ret = CryptStringToBinaryA( (char *)in->pbData, len, CRYPT_STRING_BASE64_ANY,
out->pbData, &out->cbData, NULL, NULL );
if (!ret) CryptMemFree( out->pbData );
return ret;
}
static BOOL CRYPT_CreateContext(const CRYPT_BLOB_ARRAY *pObject, static BOOL CRYPT_CreateContext(const CRYPT_BLOB_ARRAY *pObject,
DWORD dwExpectedContentTypeFlags, AddContextToStore addFunc, void **ppvContext) DWORD dwExpectedContentTypeFlags, AddContextToStore addFunc, void **ppvContext)
{ {
BOOL ret = TRUE; BOOL ret = TRUE;
CRYPT_DATA_BLOB blob;
if (!pObject->cBlob) if (!pObject->cBlob)
{ {
...@@ -1197,9 +1214,20 @@ static BOOL CRYPT_CreateContext(const CRYPT_BLOB_ARRAY *pObject, ...@@ -1197,9 +1214,20 @@ static BOOL CRYPT_CreateContext(const CRYPT_BLOB_ARRAY *pObject,
} }
else if (pObject->cBlob == 1) else if (pObject->cBlob == 1)
{ {
if (!CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &pObject->rgBlob[0], if (decode_base64_blob(&pObject->rgBlob[0], &blob))
dwExpectedContentTypeFlags, CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, {
NULL, NULL, NULL, NULL, (const void **)ppvContext)) ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
dwExpectedContentTypeFlags, CERT_QUERY_FORMAT_FLAG_BINARY, 0,
NULL, NULL, NULL, NULL, NULL, (const void **)ppvContext);
CryptMemFree(blob.pbData);
}
else
{
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &pObject->rgBlob[0],
dwExpectedContentTypeFlags, CERT_QUERY_FORMAT_FLAG_BINARY, 0,
NULL, NULL, NULL, NULL, NULL, (const void **)ppvContext);
}
if (!ret)
{ {
SetLastError(CRYPT_E_NO_MATCH); SetLastError(CRYPT_E_NO_MATCH);
ret = FALSE; ret = FALSE;
...@@ -1217,10 +1245,21 @@ static BOOL CRYPT_CreateContext(const CRYPT_BLOB_ARRAY *pObject, ...@@ -1217,10 +1245,21 @@ static BOOL CRYPT_CreateContext(const CRYPT_BLOB_ARRAY *pObject,
for (i = 0; i < pObject->cBlob; i++) for (i = 0; i < pObject->cBlob; i++)
{ {
if (CryptQueryObject(CERT_QUERY_OBJECT_BLOB, if (decode_base64_blob(&pObject->rgBlob[i], &blob))
&pObject->rgBlob[i], dwExpectedContentTypeFlags, {
CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL, NULL, NULL, ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
NULL, &context)) dwExpectedContentTypeFlags, CERT_QUERY_FORMAT_FLAG_BINARY,
0, NULL, NULL, NULL, NULL, NULL, &context);
CryptMemFree(blob.pbData);
}
else
{
ret = CryptQueryObject(CERT_QUERY_OBJECT_BLOB,
&pObject->rgBlob[i], dwExpectedContentTypeFlags,
CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL, NULL, NULL,
NULL, &context);
}
if (ret)
{ {
if (!addFunc(store, context, CERT_STORE_ADD_ALWAYS, NULL)) if (!addFunc(store, context, CERT_STORE_ADD_ALWAYS, NULL))
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