Commit 9d4ab487 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Formatted bits are always in a single line, regardless of dwFormatStrType.

parent 57fde4e8
...@@ -604,7 +604,6 @@ static BOOL WINAPI CRYPT_FormatHexString(DWORD dwCertEncodingType, ...@@ -604,7 +604,6 @@ static BOOL WINAPI CRYPT_FormatHexString(DWORD dwCertEncodingType,
#define MAX_STRING_RESOURCE_LEN 128 #define MAX_STRING_RESOURCE_LEN 128
static const WCHAR crlf[] = { '\r','\n',0 };
static const WCHAR commaSpace[] = { ',',' ',0 }; static const WCHAR commaSpace[] = { ',',' ',0 };
struct BitToString struct BitToString
...@@ -614,30 +613,18 @@ struct BitToString ...@@ -614,30 +613,18 @@ struct BitToString
WCHAR str[MAX_STRING_RESOURCE_LEN]; WCHAR str[MAX_STRING_RESOURCE_LEN];
}; };
static BOOL CRYPT_FormatBits(DWORD dwFormatStrType, BYTE bits, static BOOL CRYPT_FormatBits(BYTE bits, const struct BitToString *map,
const struct BitToString *map, DWORD mapEntries, void *pbFormat, DWORD mapEntries, void *pbFormat, DWORD *pcbFormat, BOOL *first)
DWORD *pcbFormat, BOOL *first)
{ {
LPCWSTR sep; DWORD bytesNeeded = sizeof(WCHAR);
DWORD sepLen, bytesNeeded = sizeof(WCHAR);
int i; int i;
BOOL ret = TRUE, localFirst = *first; BOOL ret = TRUE, localFirst = *first;
if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
{
sep = crlf;
sepLen = strlenW(crlf) * sizeof(WCHAR);
}
else
{
sep = commaSpace;
sepLen = strlenW(commaSpace) * sizeof(WCHAR);
}
for (i = 0; i < mapEntries; i++) for (i = 0; i < mapEntries; i++)
if (bits & map[i].bit) if (bits & map[i].bit)
{ {
if (!localFirst) if (!localFirst)
bytesNeeded += sepLen; bytesNeeded += strlenW(commaSpace) * sizeof(WCHAR);
localFirst = FALSE; localFirst = FALSE;
bytesNeeded += strlenW(map[i].str) * sizeof(WCHAR); bytesNeeded += strlenW(map[i].str) * sizeof(WCHAR);
} }
...@@ -664,8 +651,8 @@ static BOOL CRYPT_FormatBits(DWORD dwFormatStrType, BYTE bits, ...@@ -664,8 +651,8 @@ static BOOL CRYPT_FormatBits(DWORD dwFormatStrType, BYTE bits,
{ {
if (!localFirst) if (!localFirst)
{ {
strcpyW(str, sep); strcpyW(str, commaSpace);
str += sepLen / sizeof(WCHAR); str += strlenW(commaSpace);
} }
localFirst = FALSE; localFirst = FALSE;
strcpyW(str, map[i].str); strcpyW(str, map[i].str);
...@@ -753,15 +740,13 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType, ...@@ -753,15 +740,13 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType,
keyUsageByte1Map[i].str, MAX_STRING_RESOURCE_LEN); keyUsageByte1Map[i].str, MAX_STRING_RESOURCE_LEN);
stringsLoaded = TRUE; stringsLoaded = TRUE;
} }
CRYPT_FormatBits(dwFormatStrType, bits->pbData[0], CRYPT_FormatBits(bits->pbData[0], keyUsageByte0Map,
keyUsageByte0Map,
sizeof(keyUsageByte0Map) / sizeof(keyUsageByte0Map[0]), sizeof(keyUsageByte0Map) / sizeof(keyUsageByte0Map[0]),
NULL, &bitStringLen, &first); NULL, &bitStringLen, &first);
bytesNeeded += bitStringLen; bytesNeeded += bitStringLen;
if (bits->cbData == 2) if (bits->cbData == 2)
{ {
CRYPT_FormatBits(dwFormatStrType, bits->pbData[1], CRYPT_FormatBits(bits->pbData[1], keyUsageByte1Map,
keyUsageByte1Map,
sizeof(keyUsageByte1Map) / sizeof(keyUsageByte1Map[0]), sizeof(keyUsageByte1Map) / sizeof(keyUsageByte1Map[0]),
NULL, &bitStringLen, &first); NULL, &bitStringLen, &first);
bytesNeeded += bitStringLen; bytesNeeded += bitStringLen;
...@@ -784,16 +769,14 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType, ...@@ -784,16 +769,14 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType,
bitStringLen = bytesNeeded; bitStringLen = bytesNeeded;
first = TRUE; first = TRUE;
CRYPT_FormatBits(dwFormatStrType, bits->pbData[0], CRYPT_FormatBits(bits->pbData[0], keyUsageByte0Map,
keyUsageByte0Map,
sizeof(keyUsageByte0Map) / sizeof(keyUsageByte0Map[0]), sizeof(keyUsageByte0Map) / sizeof(keyUsageByte0Map[0]),
str, &bitStringLen, &first); str, &bitStringLen, &first);
str += bitStringLen / sizeof(WCHAR) - 1; str += bitStringLen / sizeof(WCHAR) - 1;
if (bits->cbData == 2) if (bits->cbData == 2)
{ {
bitStringLen = bytesNeeded; bitStringLen = bytesNeeded;
CRYPT_FormatBits(dwFormatStrType, bits->pbData[1], CRYPT_FormatBits(bits->pbData[1], keyUsageByte1Map,
keyUsageByte1Map,
sizeof(keyUsageByte1Map) / sizeof(keyUsageByte1Map[0]), sizeof(keyUsageByte1Map) / sizeof(keyUsageByte1Map[0]),
str, &bitStringLen, &first); str, &bitStringLen, &first);
str += bitStringLen / sizeof(WCHAR) - 1; str += bitStringLen / sizeof(WCHAR) - 1;
...@@ -812,6 +795,8 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType, ...@@ -812,6 +795,8 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType,
return ret; return ret;
} }
static const WCHAR crlf[] = { '\r','\n',0 };
static WCHAR subjectTypeHeader[MAX_STRING_RESOURCE_LEN]; static WCHAR subjectTypeHeader[MAX_STRING_RESOURCE_LEN];
static WCHAR subjectTypeCA[MAX_STRING_RESOURCE_LEN]; static WCHAR subjectTypeCA[MAX_STRING_RESOURCE_LEN];
static WCHAR subjectTypeEndCert[MAX_STRING_RESOURCE_LEN]; static WCHAR subjectTypeEndCert[MAX_STRING_RESOURCE_LEN];
...@@ -2123,8 +2108,7 @@ static BOOL WINAPI CRYPT_FormatNetscapeCertType(DWORD dwCertEncodingType, ...@@ -2123,8 +2108,7 @@ static BOOL WINAPI CRYPT_FormatNetscapeCertType(DWORD dwCertEncodingType,
netscapeCertTypeMap[i].str, MAX_STRING_RESOURCE_LEN); netscapeCertTypeMap[i].str, MAX_STRING_RESOURCE_LEN);
stringsLoaded = TRUE; stringsLoaded = TRUE;
} }
CRYPT_FormatBits(dwFormatStrType, bits->pbData[0], CRYPT_FormatBits(bits->pbData[0], netscapeCertTypeMap,
netscapeCertTypeMap,
sizeof(netscapeCertTypeMap) / sizeof(netscapeCertTypeMap[0]), sizeof(netscapeCertTypeMap) / sizeof(netscapeCertTypeMap[0]),
NULL, &bitStringLen, &first); NULL, &bitStringLen, &first);
bytesNeeded += bitStringLen; bytesNeeded += bitStringLen;
...@@ -2146,8 +2130,7 @@ static BOOL WINAPI CRYPT_FormatNetscapeCertType(DWORD dwCertEncodingType, ...@@ -2146,8 +2130,7 @@ static BOOL WINAPI CRYPT_FormatNetscapeCertType(DWORD dwCertEncodingType,
bitStringLen = bytesNeeded; bitStringLen = bytesNeeded;
first = TRUE; first = TRUE;
CRYPT_FormatBits(dwFormatStrType, bits->pbData[0], CRYPT_FormatBits(bits->pbData[0], netscapeCertTypeMap,
netscapeCertTypeMap,
sizeof(netscapeCertTypeMap) / sizeof(netscapeCertTypeMap[0]), sizeof(netscapeCertTypeMap) / sizeof(netscapeCertTypeMap[0]),
str, &bitStringLen, &first); str, &bitStringLen, &first);
str += bitStringLen / sizeof(WCHAR) - 1; str += bitStringLen / sizeof(WCHAR) - 1;
......
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