crypt32: Add a function to format a CERT_NAME_BLOB as an indented string, and implement CertNameToStrW on top of it.
This commit is contained in:
parent
3b81c62b5c
commit
e9352b90f8
|
@ -286,6 +286,13 @@ BOOL CRYPT_ReadSerializedStoreFromFile(HANDLE file, HCERTSTORE store);
|
|||
*/
|
||||
void CRYPT_FixKeyProvInfoPointers(PCRYPT_KEY_PROV_INFO info);
|
||||
|
||||
/**
|
||||
* String functions
|
||||
*/
|
||||
|
||||
DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indent,
|
||||
PCERT_NAME_BLOB pName, DWORD dwStrType, LPWSTR psz, DWORD csz);
|
||||
|
||||
/**
|
||||
* Context functions
|
||||
*/
|
||||
|
|
|
@ -338,8 +338,10 @@ static DWORD CRYPT_AddPrefixW(LPCWSTR prefix, LPWSTR psz, DWORD csz)
|
|||
return chars;
|
||||
}
|
||||
|
||||
DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
|
||||
DWORD dwStrType, LPWSTR psz, DWORD csz)
|
||||
static const WCHAR indent[] = { ' ',' ',' ',' ',' ',0 };
|
||||
|
||||
DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indentLevel,
|
||||
PCERT_NAME_BLOB pName, DWORD dwStrType, LPWSTR psz, DWORD csz)
|
||||
{
|
||||
static const DWORD unsupportedFlags = CERT_NAME_STR_NO_QUOTING_FLAG |
|
||||
CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG;
|
||||
|
@ -352,8 +354,6 @@ DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
|
|||
BOOL bRet;
|
||||
CERT_NAME_INFO *info;
|
||||
|
||||
TRACE("(%d, %p, %08x, %p, %d)\n", dwCertEncodingType, pName, dwStrType,
|
||||
psz, csz);
|
||||
if (dwStrType & unsupportedFlags)
|
||||
FIXME("unsupported flags: %08x\n", dwStrType & unsupportedFlags);
|
||||
|
||||
|
@ -402,6 +402,22 @@ DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
|
|||
else
|
||||
prefixA = rdn->rgRDNAttr[j].pszObjId;
|
||||
}
|
||||
if (dwStrType & CERT_NAME_STR_CRLF_FLAG)
|
||||
{
|
||||
DWORD k;
|
||||
|
||||
for (k = 0; k < indentLevel; k++)
|
||||
{
|
||||
if (psz)
|
||||
{
|
||||
chars = min(strlenW(indent), csz - ret - 1);
|
||||
memcpy(psz + ret, indent, chars * sizeof(WCHAR));
|
||||
}
|
||||
else
|
||||
chars = strlenW(indent);
|
||||
ret += chars;
|
||||
}
|
||||
}
|
||||
if (prefixW)
|
||||
{
|
||||
/* - 1 is needed to account for the NULL terminator. */
|
||||
|
@ -448,6 +464,19 @@ DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
|
|||
}
|
||||
else
|
||||
ret++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
|
||||
DWORD dwStrType, LPWSTR psz, DWORD csz)
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
TRACE("(%d, %p, %08x, %p, %d)\n", dwCertEncodingType, pName, dwStrType,
|
||||
psz, csz);
|
||||
|
||||
ret = cert_name_to_str_with_indent(dwCertEncodingType, 0, pName, dwStrType,
|
||||
psz, csz);
|
||||
TRACE("Returning %s\n", debugstr_w(psz));
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue