Commit 4120fb99 authored by Alexandre Julliard's avatar Alexandre Julliard

crypt32: Use wide-character string literals.

parent 03bf2369
...@@ -38,30 +38,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(crypt); ...@@ -38,30 +38,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(crypt);
#define X509_HEADER "-----BEGIN X509 CRL-----" #define X509_HEADER "-----BEGIN X509 CRL-----"
#define X509_TRAILER "-----END X509 CRL-----" #define X509_TRAILER "-----END X509 CRL-----"
static const WCHAR CERT_HEADER_W[] = { static const WCHAR CERT_HEADER_W[] = L"-----BEGIN CERTIFICATE-----";
'-','-','-','-','-','B','E','G','I','N',' ','C','E','R','T','I','F','I','C', static const WCHAR CERT_HEADER_START_W[] = L"-----BEGIN ";
'A','T','E','-','-','-','-','-',0 }; static const WCHAR CERT_DELIMITER_W[] = L"-----";
static const WCHAR CERT_HEADER_START_W[] = { static const WCHAR CERT_TRAILER_W[] = L"-----END CERTIFICATE-----";
'-','-','-','-','-','B','E','G','I','N',' ',0 }; static const WCHAR CERT_TRAILER_START_W[] = L"-----END ";
static const WCHAR CERT_DELIMITER_W[] = { static const WCHAR CERT_REQUEST_HEADER_W[] = L"-----BEGIN NEW CERTIFICATE REQUEST-----";
'-','-','-','-','-',0 }; static const WCHAR CERT_REQUEST_TRAILER_W[] = L"-----END NEW CERTIFICATE REQUEST-----";
static const WCHAR CERT_TRAILER_W[] = { static const WCHAR X509_HEADER_W[] = L"-----BEGIN X509 CRL-----";
'-','-','-','-','-','E','N','D',' ','C','E','R','T','I','F','I','C','A','T', static const WCHAR X509_TRAILER_W[] = L"-----END X509 CRL-----";
'E','-','-','-','-','-',0 };
static const WCHAR CERT_TRAILER_START_W[] = {
'-','-','-','-','-','E','N','D',' ',0 };
static const WCHAR CERT_REQUEST_HEADER_W[] = {
'-','-','-','-','-','B','E','G','I','N',' ','N','E','W',' ','C','E','R','T',
'I','F','I','C','A','T','E',' ','R','E','Q','U','E','S','T','-','-','-','-','-',0 };
static const WCHAR CERT_REQUEST_TRAILER_W[] = {
'-','-','-','-','-','E','N','D',' ','N','E','W',' ','C','E','R','T','I','F',
'I','C','A','T','E',' ','R','E','Q','U','E','S','T','-','-','-','-','-',0 };
static const WCHAR X509_HEADER_W[] = {
'-','-','-','-','-','B','E','G','I','N',' ','X','5','0','9',' ','C','R','L',
'-','-','-','-','-',0 };
static const WCHAR X509_TRAILER_W[] = {
'-','-','-','-','-','E','N','D',' ','X','5','0','9',' ','C','R','L','-','-',
'-','-','-',0 };
static const char b64[] = static const char b64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
...@@ -402,17 +387,16 @@ static LONG encodeBase64W(const BYTE *in_buf, int in_len, LPCWSTR sep, ...@@ -402,17 +387,16 @@ static LONG encodeBase64W(const BYTE *in_buf, int in_len, LPCWSTR sep,
static BOOL BinaryToBase64W(const BYTE *pbBinary, static BOOL BinaryToBase64W(const BYTE *pbBinary,
DWORD cbBinary, DWORD dwFlags, LPWSTR pszString, DWORD *pcchString) DWORD cbBinary, DWORD dwFlags, LPWSTR pszString, DWORD *pcchString)
{ {
static const WCHAR crlf[] = { '\r','\n',0 }, lf[] = { '\n',0 }, empty[] = {0};
BOOL ret = TRUE; BOOL ret = TRUE;
LPCWSTR header = NULL, trailer = NULL, sep; LPCWSTR header = NULL, trailer = NULL, sep;
DWORD charsNeeded; DWORD charsNeeded;
if (dwFlags & CRYPT_STRING_NOCR) if (dwFlags & CRYPT_STRING_NOCR)
sep = lf; sep = L"\n";
else if (dwFlags & CRYPT_STRING_NOCRLF) else if (dwFlags & CRYPT_STRING_NOCRLF)
sep = empty; sep = L"";
else else
sep = crlf; sep = L"\r\n";
switch (dwFlags & 0x0fffffff) switch (dwFlags & 0x0fffffff)
{ {
case CRYPT_STRING_BASE64: case CRYPT_STRING_BASE64:
...@@ -478,7 +462,7 @@ static BOOL BinaryToBase64W(const BYTE *pbBinary, ...@@ -478,7 +462,7 @@ static BOOL BinaryToBase64W(const BYTE *pbBinary,
static BOOL BinaryToHexW(const BYTE *bin, DWORD nbin, DWORD flags, LPWSTR str, DWORD *nstr) static BOOL BinaryToHexW(const BYTE *bin, DWORD nbin, DWORD flags, LPWSTR str, DWORD *nstr)
{ {
static const WCHAR hex[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; static const WCHAR hex[] = L"0123456789abcdef";
DWORD needed; DWORD needed;
if (flags & CRYPT_STRING_NOCRLF) if (flags & CRYPT_STRING_NOCRLF)
......
...@@ -984,11 +984,10 @@ BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert, ...@@ -984,11 +984,10 @@ BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert,
if (!ret) if (!ret)
{ {
static const WCHAR myW[] = { 'M','y',0 };
HCERTSTORE hstore; HCERTSTORE hstore;
hstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, hstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0,
CERT_SYSTEM_STORE_CURRENT_USER, myW); CERT_SYSTEM_STORE_CURRENT_USER, L"My");
if (hstore) if (hstore)
{ {
cert_in_store = CertFindCertificateInStore(hstore, pCert->dwCertEncodingType, 0, cert_in_store = CertFindCertificateInStore(hstore, pCert->dwCertEncodingType, 0,
...@@ -3670,7 +3669,7 @@ typedef RPC_STATUS (RPC_ENTRY *RpcStringFreeFunc)(unsigned char **); ...@@ -3670,7 +3669,7 @@ typedef RPC_STATUS (RPC_ENTRY *RpcStringFreeFunc)(unsigned char **);
static HCRYPTPROV CRYPT_CreateKeyProv(void) static HCRYPTPROV CRYPT_CreateKeyProv(void)
{ {
HCRYPTPROV hProv = 0; HCRYPTPROV hProv = 0;
HMODULE rpcrt = LoadLibraryA("rpcrt4"); HMODULE rpcrt = LoadLibraryW(L"rpcrt4");
if (rpcrt) if (rpcrt)
{ {
......
...@@ -68,8 +68,6 @@ static inline void CRYPT_CloseStores(DWORD cStores, HCERTSTORE *stores) ...@@ -68,8 +68,6 @@ static inline void CRYPT_CloseStores(DWORD cStores, HCERTSTORE *stores)
CertCloseStore(stores[i], 0); CertCloseStore(stores[i], 0);
} }
static const WCHAR rootW[] = { 'R','o','o','t',0 };
/* Finds cert in store by comparing the cert's hashes. */ /* Finds cert in store by comparing the cert's hashes. */
static PCCERT_CONTEXT CRYPT_FindCertInStore(HCERTSTORE store, static PCCERT_CONTEXT CRYPT_FindCertInStore(HCERTSTORE store,
PCCERT_CONTEXT cert) PCCERT_CONTEXT cert)
...@@ -94,7 +92,7 @@ static BOOL CRYPT_CheckRestrictedRoot(HCERTSTORE store) ...@@ -94,7 +92,7 @@ static BOOL CRYPT_CheckRestrictedRoot(HCERTSTORE store)
if (store) if (store)
{ {
HCERTSTORE rootStore = CertOpenSystemStoreW(0, rootW); HCERTSTORE rootStore = CertOpenSystemStoreW(0, L"Root");
PCCERT_CONTEXT cert = NULL, check; PCCERT_CONTEXT cert = NULL, check;
do { do {
...@@ -119,17 +117,13 @@ HCERTCHAINENGINE CRYPT_CreateChainEngine(HCERTSTORE root, DWORD system_store, co ...@@ -119,17 +117,13 @@ HCERTCHAINENGINE CRYPT_CreateChainEngine(HCERTSTORE root, DWORD system_store, co
CertificateChainEngine *engine; CertificateChainEngine *engine;
HCERTSTORE worldStores[4]; HCERTSTORE worldStores[4];
static const WCHAR caW[] = { 'C','A',0 };
static const WCHAR myW[] = { 'M','y',0 };
static const WCHAR trustW[] = { 'T','r','u','s','t',0 };
if(!root) { if(!root) {
if(config->cbSize >= sizeof(CERT_CHAIN_ENGINE_CONFIG) && config->hExclusiveRoot) if(config->cbSize >= sizeof(CERT_CHAIN_ENGINE_CONFIG) && config->hExclusiveRoot)
root = CertDuplicateStore(config->hExclusiveRoot); root = CertDuplicateStore(config->hExclusiveRoot);
else if (config->hRestrictedRoot) else if (config->hRestrictedRoot)
root = CertDuplicateStore(config->hRestrictedRoot); root = CertDuplicateStore(config->hRestrictedRoot);
else else
root = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, rootW); root = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, L"Root");
if(!root) if(!root)
return NULL; return NULL;
} }
...@@ -144,9 +138,9 @@ HCERTCHAINENGINE CRYPT_CreateChainEngine(HCERTSTORE root, DWORD system_store, co ...@@ -144,9 +138,9 @@ HCERTCHAINENGINE CRYPT_CreateChainEngine(HCERTSTORE root, DWORD system_store, co
engine->hRoot = root; engine->hRoot = root;
engine->hWorld = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); engine->hWorld = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
worldStores[0] = CertDuplicateStore(engine->hRoot); worldStores[0] = CertDuplicateStore(engine->hRoot);
worldStores[1] = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, caW); worldStores[1] = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, L"CA");
worldStores[2] = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, myW); worldStores[2] = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, L"My");
worldStores[3] = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, trustW); worldStores[3] = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, L"Trust");
CRYPT_AddStoresToCollection(engine->hWorld, ARRAY_SIZE(worldStores), worldStores); CRYPT_AddStoresToCollection(engine->hWorld, ARRAY_SIZE(worldStores), worldStores);
CRYPT_AddStoresToCollection(engine->hWorld, config->cAdditionalStore, config->rghAdditionalStore); CRYPT_AddStoresToCollection(engine->hWorld, config->cAdditionalStore, config->rghAdditionalStore);
......
...@@ -353,14 +353,12 @@ WINECRYPT_CERTSTORE *CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv, ...@@ -353,14 +353,12 @@ WINECRYPT_CERTSTORE *CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv,
} }
else else
{ {
static const WCHAR spc[] = { 's','p','c',0 };
static const WCHAR p7c[] = { 'p','7','c',0 };
LPCWSTR ext = wcsrchr(fileName, '.'); LPCWSTR ext = wcsrchr(fileName, '.');
if (ext) if (ext)
{ {
ext++; ext++;
if (!lstrcmpiW(ext, spc) || !lstrcmpiW(ext, p7c)) if (!lstrcmpiW(ext, L"spc") || !lstrcmpiW(ext, L"p7c"))
type = CERT_STORE_SAVE_AS_PKCS7; type = CERT_STORE_SAVE_AS_PKCS7;
} }
if (!type) if (!type)
......
...@@ -255,12 +255,6 @@ HCRYPTPROV WINAPI DECLSPEC_HOTPATCH I_CryptGetDefaultCryptProv(ALG_ID algid) ...@@ -255,12 +255,6 @@ HCRYPTPROV WINAPI DECLSPEC_HOTPATCH I_CryptGetDefaultCryptProv(ALG_ID algid)
BOOL WINAPI I_CryptReadTrustedPublisherDWORDValueFromRegistry(LPCWSTR name, BOOL WINAPI I_CryptReadTrustedPublisherDWORDValueFromRegistry(LPCWSTR name,
DWORD *value) DWORD *value)
{ {
static const WCHAR safer[] = {
'S','o','f','t','w','a','r','e','\\','P','o','l','i','c','i','e','s','\\',
'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m',
'C','e','r','t','i','f','i','c','a','t','e','s','\\',
'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r','\\',
'S','a','f','e','r',0 };
HKEY key; HKEY key;
LONG rc; LONG rc;
BOOL ret = FALSE; BOOL ret = FALSE;
...@@ -268,7 +262,7 @@ BOOL WINAPI I_CryptReadTrustedPublisherDWORDValueFromRegistry(LPCWSTR name, ...@@ -268,7 +262,7 @@ BOOL WINAPI I_CryptReadTrustedPublisherDWORDValueFromRegistry(LPCWSTR name,
TRACE("(%s, %p)\n", debugstr_w(name), value); TRACE("(%s, %p)\n", debugstr_w(name), value);
*value = 0; *value = 0;
rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, safer, &key); rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, L"Software\\Policies\\Microsoft\\SystemCertificates\\TrustedPublisher\\Safer", &key);
if (rc == ERROR_SUCCESS) if (rc == ERROR_SUCCESS)
{ {
DWORD size = sizeof(DWORD); DWORD size = sizeof(DWORD);
......
...@@ -858,8 +858,6 @@ static BOOL WINAPI CRYPT_FormatHexString(DWORD dwCertEncodingType, ...@@ -858,8 +858,6 @@ static BOOL WINAPI CRYPT_FormatHexString(DWORD dwCertEncodingType,
} }
else else
{ {
static const WCHAR fmt[] = { '%','0','2','x',' ',0 };
static const WCHAR endFmt[] = { '%','0','2','x',0 };
DWORD i; DWORD i;
LPWSTR ptr = pbFormat; LPWSTR ptr = pbFormat;
...@@ -869,9 +867,9 @@ static BOOL WINAPI CRYPT_FormatHexString(DWORD dwCertEncodingType, ...@@ -869,9 +867,9 @@ static BOOL WINAPI CRYPT_FormatHexString(DWORD dwCertEncodingType,
for (i = 0; i < cbEncoded; i++) for (i = 0; i < cbEncoded; i++)
{ {
if (i < cbEncoded - 1) if (i < cbEncoded - 1)
ptr += swprintf(ptr, 4, fmt, pbEncoded[i]); ptr += swprintf(ptr, 4, L"%02x ", pbEncoded[i]);
else else
ptr += swprintf(ptr, 3, endFmt, pbEncoded[i]); ptr += swprintf(ptr, 3, L"%02x", pbEncoded[i]);
} }
} }
else else
...@@ -883,7 +881,7 @@ static BOOL WINAPI CRYPT_FormatHexString(DWORD dwCertEncodingType, ...@@ -883,7 +881,7 @@ static BOOL WINAPI CRYPT_FormatHexString(DWORD dwCertEncodingType,
#define MAX_STRING_RESOURCE_LEN 128 #define MAX_STRING_RESOURCE_LEN 128
static const WCHAR commaSpace[] = { ',',' ',0 }; static const WCHAR commaSpace[] = L", ";
struct BitToString struct BitToString
{ {
...@@ -1063,7 +1061,7 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType, ...@@ -1063,7 +1061,7 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType,
return ret; return ret;
} }
static const WCHAR crlf[] = { '\r','\n',0 }; static const WCHAR crlf[] = L"\r\n";
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];
...@@ -1087,7 +1085,6 @@ static BOOL WINAPI CRYPT_FormatBasicConstraints2(DWORD dwCertEncodingType, ...@@ -1087,7 +1085,6 @@ static BOOL WINAPI CRYPT_FormatBasicConstraints2(DWORD dwCertEncodingType,
if ((ret = CryptDecodeObjectEx(dwCertEncodingType, X509_BASIC_CONSTRAINTS2, if ((ret = CryptDecodeObjectEx(dwCertEncodingType, X509_BASIC_CONSTRAINTS2,
pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size))) pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size)))
{ {
static const WCHAR pathFmt[] = { '%','d',0 };
static BOOL stringsLoaded = FALSE; static BOOL stringsLoaded = FALSE;
DWORD bytesNeeded = sizeof(WCHAR); /* space for the NULL terminator */ DWORD bytesNeeded = sizeof(WCHAR); /* space for the NULL terminator */
WCHAR pathLength[MAX_STRING_RESOURCE_LEN]; WCHAR pathLength[MAX_STRING_RESOURCE_LEN];
...@@ -1122,7 +1119,7 @@ static BOOL WINAPI CRYPT_FormatBasicConstraints2(DWORD dwCertEncodingType, ...@@ -1122,7 +1119,7 @@ static BOOL WINAPI CRYPT_FormatBasicConstraints2(DWORD dwCertEncodingType,
bytesNeeded += sepLen; bytesNeeded += sepLen;
bytesNeeded += lstrlenW(pathLengthHeader) * sizeof(WCHAR); bytesNeeded += lstrlenW(pathLengthHeader) * sizeof(WCHAR);
if (info->fPathLenConstraint) if (info->fPathLenConstraint)
swprintf(pathLength, ARRAY_SIZE(pathLength), pathFmt, info->dwPathLenConstraint); swprintf(pathLength, ARRAY_SIZE(pathLength), L"%d", info->dwPathLenConstraint);
else else
LoadStringW(hInstance, IDS_PATH_LENGTH_NONE, pathLength, ARRAY_SIZE(pathLength)); LoadStringW(hInstance, IDS_PATH_LENGTH_NONE, pathLength, ARRAY_SIZE(pathLength));
bytesNeeded += lstrlenW(pathLength) * sizeof(WCHAR); bytesNeeded += lstrlenW(pathLength) * sizeof(WCHAR);
...@@ -1201,8 +1198,8 @@ static BOOL CRYPT_FormatCertSerialNumber(const CRYPT_DATA_BLOB *serialNum, LPWST ...@@ -1201,8 +1198,8 @@ static BOOL CRYPT_FormatCertSerialNumber(const CRYPT_DATA_BLOB *serialNum, LPWST
str, pcbStr); str, pcbStr);
} }
static const WCHAR indent[] = { ' ',' ',' ',' ',' ',0 }; static const WCHAR indent[] = L" ";
static const WCHAR colonCrlf[] = { ':','\r','\n',0 }; static const WCHAR colonCrlf[] = L":\r\n";
static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel, static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
const CERT_ALT_NAME_ENTRY *entry, LPWSTR str, DWORD *pcbStr) const CERT_ALT_NAME_ENTRY *entry, LPWSTR str, DWORD *pcbStr)
...@@ -1253,12 +1250,6 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel, ...@@ -1253,12 +1250,6 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
break; break;
case CERT_ALT_NAME_IP_ADDRESS: case CERT_ALT_NAME_IP_ADDRESS:
{ {
static const WCHAR ipAddrWithMaskFmt[] = { '%','d','.','%','d','.',
'%','d','.','%','d','/','%','d','.','%','d','.','%','d','.','%','d',0
};
static const WCHAR ipAddrFmt[] = { '%','d','.','%','d','.','%','d',
'.','%','d',0 };
LoadStringW(hInstance, IDS_ALT_NAME_IP_ADDRESS, buf, ARRAY_SIZE(buf)); LoadStringW(hInstance, IDS_ALT_NAME_IP_ADDRESS, buf, ARRAY_SIZE(buf));
if (entry->u.IPAddress.cbData == 8) if (entry->u.IPAddress.cbData == 8)
{ {
...@@ -1266,7 +1257,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel, ...@@ -1266,7 +1257,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
{ {
LoadStringW(hInstance, IDS_ALT_NAME_MASK, mask, ARRAY_SIZE(mask)); LoadStringW(hInstance, IDS_ALT_NAME_MASK, mask, ARRAY_SIZE(mask));
bytesNeeded += lstrlenW(mask) * sizeof(WCHAR); bytesNeeded += lstrlenW(mask) * sizeof(WCHAR);
swprintf(ipAddrBuf, ARRAY_SIZE(ipAddrBuf), ipAddrFmt, swprintf(ipAddrBuf, ARRAY_SIZE(ipAddrBuf), L"%d.%d.%d.%d",
entry->u.IPAddress.pbData[0], entry->u.IPAddress.pbData[0],
entry->u.IPAddress.pbData[1], entry->u.IPAddress.pbData[1],
entry->u.IPAddress.pbData[2], entry->u.IPAddress.pbData[2],
...@@ -1274,7 +1265,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel, ...@@ -1274,7 +1265,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
bytesNeeded += lstrlenW(ipAddrBuf) * sizeof(WCHAR); bytesNeeded += lstrlenW(ipAddrBuf) * sizeof(WCHAR);
/* indent again, for the mask line */ /* indent again, for the mask line */
bytesNeeded += indentLevel * lstrlenW(indent) * sizeof(WCHAR); bytesNeeded += indentLevel * lstrlenW(indent) * sizeof(WCHAR);
swprintf(maskBuf, ARRAY_SIZE(maskBuf), ipAddrFmt, swprintf(maskBuf, ARRAY_SIZE(maskBuf), L"%d.%d.%d.%d",
entry->u.IPAddress.pbData[4], entry->u.IPAddress.pbData[4],
entry->u.IPAddress.pbData[5], entry->u.IPAddress.pbData[5],
entry->u.IPAddress.pbData[6], entry->u.IPAddress.pbData[6],
...@@ -1284,7 +1275,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel, ...@@ -1284,7 +1275,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
} }
else else
{ {
swprintf(ipAddrBuf, ARRAY_SIZE(ipAddrBuf), ipAddrWithMaskFmt, swprintf(ipAddrBuf, ARRAY_SIZE(ipAddrBuf), L"%d.%d.%d.%d/%d.%d.%d.%d",
entry->u.IPAddress.pbData[0], entry->u.IPAddress.pbData[0],
entry->u.IPAddress.pbData[1], entry->u.IPAddress.pbData[1],
entry->u.IPAddress.pbData[2], entry->u.IPAddress.pbData[2],
...@@ -1445,7 +1436,7 @@ static BOOL CRYPT_FormatAltNameInfo(DWORD dwFormatStrType, DWORD indentLevel, ...@@ -1445,7 +1436,7 @@ static BOOL CRYPT_FormatAltNameInfo(DWORD dwFormatStrType, DWORD indentLevel,
return ret; return ret;
} }
static const WCHAR colonSep[] = { ':',' ',0 }; static const WCHAR colonSep[] = L": ";
static BOOL WINAPI CRYPT_FormatAltName(DWORD dwCertEncodingType, static BOOL WINAPI CRYPT_FormatAltName(DWORD dwCertEncodingType,
DWORD dwFormatType, DWORD dwFormatStrType, void *pFormatStruct, DWORD dwFormatType, DWORD dwFormatStrType, void *pFormatStruct,
...@@ -1695,8 +1686,7 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType, ...@@ -1695,8 +1686,7 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType,
} }
else else
{ {
static const WCHAR numFmt[] = { '%','d',0 }; static const WCHAR equal[] = L"=";
static const WCHAR equal[] = { '=',0 };
static BOOL stringsLoaded = FALSE; static BOOL stringsLoaded = FALSE;
DWORD i; DWORD i;
LPCWSTR headingSep, accessMethodSep, locationSep; LPCWSTR headingSep, accessMethodSep, locationSep;
...@@ -1729,7 +1719,7 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType, ...@@ -1729,7 +1719,7 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType,
{ {
/* Heading */ /* Heading */
bytesNeeded += sizeof(WCHAR); /* left bracket */ bytesNeeded += sizeof(WCHAR); /* left bracket */
swprintf(accessDescrNum, ARRAY_SIZE(accessDescrNum), numFmt, i + 1); swprintf(accessDescrNum, ARRAY_SIZE(accessDescrNum), L"%d", i + 1);
bytesNeeded += lstrlenW(accessDescrNum) * sizeof(WCHAR); bytesNeeded += lstrlenW(accessDescrNum) * sizeof(WCHAR);
bytesNeeded += sizeof(WCHAR); /* right bracket */ bytesNeeded += sizeof(WCHAR); /* right bracket */
bytesNeeded += lstrlenW(aia) * sizeof(WCHAR); bytesNeeded += lstrlenW(aia) * sizeof(WCHAR);
...@@ -1786,7 +1776,7 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType, ...@@ -1786,7 +1776,7 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType,
LPCSTR oidPtr; LPCSTR oidPtr;
*str++ = '['; *str++ = '[';
swprintf(accessDescrNum, ARRAY_SIZE(accessDescrNum), numFmt, i + 1); swprintf(accessDescrNum, ARRAY_SIZE(accessDescrNum), L"%d", i + 1);
lstrcpyW(str, accessDescrNum); lstrcpyW(str, accessDescrNum);
str += lstrlenW(accessDescrNum); str += lstrlenW(accessDescrNum);
*str++ = ']'; *str++ = ']';
...@@ -1887,8 +1877,7 @@ static struct reason_map_entry reason_map[] = { ...@@ -1887,8 +1877,7 @@ static struct reason_map_entry reason_map[] = {
static BOOL CRYPT_FormatReason(DWORD dwFormatStrType, static BOOL CRYPT_FormatReason(DWORD dwFormatStrType,
const CRYPT_BIT_BLOB *reasonFlags, LPWSTR str, DWORD *pcbStr) const CRYPT_BIT_BLOB *reasonFlags, LPWSTR str, DWORD *pcbStr)
{ {
static const WCHAR sep[] = { ',',' ',0 }; static const WCHAR sep[] = L", ";
static const WCHAR bitsFmt[] = { ' ','(','%','0','2','x',')',0 };
static BOOL stringsLoaded = FALSE; static BOOL stringsLoaded = FALSE;
unsigned int i, numReasons = 0; unsigned int i, numReasons = 0;
BOOL ret = TRUE; BOOL ret = TRUE;
...@@ -1914,7 +1903,7 @@ static BOOL CRYPT_FormatReason(DWORD dwFormatStrType, ...@@ -1914,7 +1903,7 @@ static BOOL CRYPT_FormatReason(DWORD dwFormatStrType,
bytesNeeded += lstrlenW(sep) * sizeof(WCHAR); bytesNeeded += lstrlenW(sep) * sizeof(WCHAR);
} }
} }
swprintf(bits, ARRAY_SIZE(bits), bitsFmt, reasonFlags->pbData[0]); swprintf(bits, ARRAY_SIZE(bits), L" (%02x)", reasonFlags->pbData[0]);
bytesNeeded += lstrlenW(bits); bytesNeeded += lstrlenW(bits);
if (!str) if (!str)
*pcbStr = bytesNeeded; *pcbStr = bytesNeeded;
...@@ -1969,8 +1958,7 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType, ...@@ -1969,8 +1958,7 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType,
if ((ret = CryptDecodeObjectEx(dwCertEncodingType, X509_CRL_DIST_POINTS, if ((ret = CryptDecodeObjectEx(dwCertEncodingType, X509_CRL_DIST_POINTS,
pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size))) pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size)))
{ {
static const WCHAR numFmt[] = { '%','d',0 }; static const WCHAR colon[] = L":";
static const WCHAR colon[] = { ':',0 };
static BOOL stringsLoaded = FALSE; static BOOL stringsLoaded = FALSE;
DWORD bytesNeeded = sizeof(WCHAR); /* space for NULL terminator */ DWORD bytesNeeded = sizeof(WCHAR); /* space for NULL terminator */
BOOL haveAnEntry = FALSE; BOOL haveAnEntry = FALSE;
...@@ -2048,7 +2036,7 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType, ...@@ -2048,7 +2036,7 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType,
if (haveAnEntry) if (haveAnEntry)
{ {
bytesNeeded += sizeof(WCHAR); /* left bracket */ bytesNeeded += sizeof(WCHAR); /* left bracket */
swprintf(distPointNum, ARRAY_SIZE(distPointNum), numFmt, i + 1); swprintf(distPointNum, ARRAY_SIZE(distPointNum), L"%d", i + 1);
bytesNeeded += lstrlenW(distPointNum) * sizeof(WCHAR); bytesNeeded += lstrlenW(distPointNum) * sizeof(WCHAR);
bytesNeeded += sizeof(WCHAR); /* right bracket */ bytesNeeded += sizeof(WCHAR); /* right bracket */
bytesNeeded += lstrlenW(crlDistPoint) * sizeof(WCHAR); bytesNeeded += lstrlenW(crlDistPoint) * sizeof(WCHAR);
...@@ -2097,7 +2085,7 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType, ...@@ -2097,7 +2085,7 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType,
CRL_DIST_POINT *distPoint = &info->rgDistPoint[i]; CRL_DIST_POINT *distPoint = &info->rgDistPoint[i];
*str++ = '['; *str++ = '[';
swprintf(distPointNum, ARRAY_SIZE(distPointNum), numFmt, i + 1); swprintf(distPointNum, ARRAY_SIZE(distPointNum), L"%d", i + 1);
lstrcpyW(str, distPointNum); lstrcpyW(str, distPointNum);
str += lstrlenW(distPointNum); str += lstrlenW(distPointNum);
*str++ = ']'; *str++ = ']';
......
...@@ -826,7 +826,6 @@ BOOL WINAPI CryptProtectData(DATA_BLOB* pDataIn, ...@@ -826,7 +826,6 @@ BOOL WINAPI CryptProtectData(DATA_BLOB* pDataIn,
DWORD dwFlags, DWORD dwFlags,
DATA_BLOB* pDataOut) DATA_BLOB* pDataOut)
{ {
static const WCHAR empty_str[1];
BOOL rc = FALSE; BOOL rc = FALSE;
HCRYPTPROV hProv; HCRYPTPROV hProv;
struct protect_data_t protect_data; struct protect_data_t protect_data;
...@@ -852,7 +851,7 @@ BOOL WINAPI CryptProtectData(DATA_BLOB* pDataIn, ...@@ -852,7 +851,7 @@ BOOL WINAPI CryptProtectData(DATA_BLOB* pDataIn,
/* Windows appears to create an empty szDataDescr instead of maintaining /* Windows appears to create an empty szDataDescr instead of maintaining
* a NULL */ * a NULL */
if (!szDataDescr) if (!szDataDescr)
szDataDescr = empty_str; szDataDescr = L"";
/* get crypt context */ /* get crypt context */
if (!CryptAcquireContextW(&hProv,NULL,MS_ENHANCED_PROV_W,CRYPT32_PROTECTDATA_PROV,CRYPT_VERIFYCONTEXT)) if (!CryptAcquireContextW(&hProv,NULL,MS_ENHANCED_PROV_W,CRYPT32_PROTECTDATA_PROV,CRYPT_VERIFYCONTEXT))
......
...@@ -47,22 +47,15 @@ typedef struct _WINE_REGSTOREINFO ...@@ -47,22 +47,15 @@ typedef struct _WINE_REGSTOREINFO
static void CRYPT_HashToStr(const BYTE *hash, LPWSTR asciiHash) static void CRYPT_HashToStr(const BYTE *hash, LPWSTR asciiHash)
{ {
static const WCHAR fmt[] = { '%','0','2','X',0 };
DWORD i; DWORD i;
assert(hash); assert(hash);
assert(asciiHash); assert(asciiHash);
for (i = 0; i < 20; i++) for (i = 0; i < 20; i++)
wsprintfW(asciiHash + i * 2, fmt, hash[i]); wsprintfW(asciiHash + i * 2, L"%02X", hash[i]);
} }
static const WCHAR CertsW[] = { 'C','e','r','t','i','f','i','c','a','t','e','s',
0 };
static const WCHAR CRLsW[] = { 'C','R','L','s',0 };
static const WCHAR CTLsW[] = { 'C','T','L','s',0 };
static const WCHAR BlobW[] = { 'B','l','o','b',0 };
static void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType, static void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType,
HCERTSTORE store) HCERTSTORE store)
{ {
...@@ -85,12 +78,12 @@ static void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType, ...@@ -85,12 +78,12 @@ static void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType,
LPBYTE buf = NULL; LPBYTE buf = NULL;
size = 0; size = 0;
rc = RegQueryValueExW(subKey, BlobW, NULL, NULL, NULL, &size); rc = RegQueryValueExW(subKey, L"Blob", NULL, NULL, NULL, &size);
if (!rc) if (!rc)
buf = CryptMemAlloc(size); buf = CryptMemAlloc(size);
if (buf) if (buf)
{ {
rc = RegQueryValueExW(subKey, BlobW, NULL, NULL, buf, rc = RegQueryValueExW(subKey, L"Blob", NULL, NULL, buf,
&size); &size);
if (!rc) if (!rc)
{ {
...@@ -158,7 +151,7 @@ static void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType, ...@@ -158,7 +151,7 @@ static void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType,
static void CRYPT_RegReadFromReg(HKEY key, HCERTSTORE store) static void CRYPT_RegReadFromReg(HKEY key, HCERTSTORE store)
{ {
static const WCHAR * const subKeys[] = { CertsW, CRLsW, CTLsW }; static const WCHAR * const subKeys[] = { L"Certificates", L"CRLs", L"CTLs" };
static const DWORD contextFlags[] = { CERT_STORE_CERTIFICATE_CONTEXT_FLAG, static const DWORD contextFlags[] = { CERT_STORE_CERTIFICATE_CONTEXT_FLAG,
CERT_STORE_CRL_CONTEXT_FLAG, CERT_STORE_CTL_CONTEXT_FLAG }; CERT_STORE_CRL_CONTEXT_FLAG, CERT_STORE_CTL_CONTEXT_FLAG };
DWORD i; DWORD i;
...@@ -192,7 +185,7 @@ static BOOL CRYPT_WriteSerializedToReg(HKEY key, DWORD flags, const BYTE *hash, ...@@ -192,7 +185,7 @@ static BOOL CRYPT_WriteSerializedToReg(HKEY key, DWORD flags, const BYTE *hash,
&subKey, NULL); &subKey, NULL);
if (!rc) if (!rc)
{ {
rc = RegSetValueExW(subKey, BlobW, 0, REG_BINARY, buf, len); rc = RegSetValueExW(subKey, L"Blob", 0, REG_BINARY, buf, len);
RegCloseKey(subKey); RegCloseKey(subKey);
} }
if (!rc) if (!rc)
...@@ -247,7 +240,7 @@ BOOL CRYPT_SerializeContextsToReg(HKEY key, DWORD flags, ...@@ -247,7 +240,7 @@ BOOL CRYPT_SerializeContextsToReg(HKEY key, DWORD flags,
static BOOL CRYPT_RegWriteToReg(WINE_REGSTOREINFO *store) static BOOL CRYPT_RegWriteToReg(WINE_REGSTOREINFO *store)
{ {
static const WCHAR * const subKeys[] = { CertsW, CRLsW, CTLsW }; static const WCHAR * const subKeys[] = { L"Certificates", L"CRLs", L"CTLs" };
const WINE_CONTEXT_INTERFACE * const interfaces[] = { pCertInterface, const WINE_CONTEXT_INTERFACE * const interfaces[] = { pCertInterface,
pCRLInterface, pCTLInterface }; pCRLInterface, pCTLInterface };
struct list *listToDelete[] = { &store->certsToDelete, &store->crlsToDelete, struct list *listToDelete[] = { &store->certsToDelete, &store->crlsToDelete,
...@@ -518,12 +511,12 @@ WINECRYPT_CERTSTORE *CRYPT_RegOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags, ...@@ -518,12 +511,12 @@ WINECRYPT_CERTSTORE *CRYPT_RegOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags,
if (dwFlags & CERT_STORE_DELETE_FLAG) if (dwFlags & CERT_STORE_DELETE_FLAG)
{ {
DWORD rc = RegDeleteTreeW((HKEY)pvPara, CertsW); DWORD rc = RegDeleteTreeW((HKEY)pvPara, L"Certificates");
if (rc == ERROR_SUCCESS || rc == ERROR_NO_MORE_ITEMS) if (rc == ERROR_SUCCESS || rc == ERROR_NO_MORE_ITEMS)
rc = RegDeleteTreeW((HKEY)pvPara, CRLsW); rc = RegDeleteTreeW((HKEY)pvPara, L"CRLs");
if (rc == ERROR_SUCCESS || rc == ERROR_NO_MORE_ITEMS) if (rc == ERROR_SUCCESS || rc == ERROR_NO_MORE_ITEMS)
rc = RegDeleteTreeW((HKEY)pvPara, CTLsW); rc = RegDeleteTreeW((HKEY)pvPara, L"CTLs");
if (rc == ERROR_NO_MORE_ITEMS) if (rc == ERROR_NO_MORE_ITEMS)
rc = ERROR_SUCCESS; rc = ERROR_SUCCESS;
SetLastError(rc); SetLastError(rc);
......
...@@ -653,13 +653,6 @@ static HCERTSTORE create_root_store(void) ...@@ -653,13 +653,6 @@ static HCERTSTORE create_root_store(void)
return memStore; return memStore;
} }
static const WCHAR certs_root_pathW[] =
{'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
'S','y','s','t','e','m','C','e','r','t','i','f','i','c','a','t','e','s','\\',
'R','o','o','t','\\', 'C','e','r','t','i','f','i','c','a','t','e','s', 0};
static const WCHAR semaphoreW[] =
{'c','r','y','p','t','3','2','_','r','o','o','t','_','s','e','m','a','p','h','o','r','e',0};
void CRYPT_ImportSystemRootCertsToReg(void) void CRYPT_ImportSystemRootCertsToReg(void)
{ {
HCERTSTORE store = NULL; HCERTSTORE store = NULL;
...@@ -672,7 +665,7 @@ void CRYPT_ImportSystemRootCertsToReg(void) ...@@ -672,7 +665,7 @@ void CRYPT_ImportSystemRootCertsToReg(void)
if (root_certs_imported) if (root_certs_imported)
return; return;
hsem = CreateSemaphoreW( NULL, 0, 1, semaphoreW); hsem = CreateSemaphoreW( NULL, 0, 1, L"crypt32_root_semaphore");
if (!hsem) if (!hsem)
{ {
ERR("Failed to create semaphore\n"); ERR("Failed to create semaphore\n");
...@@ -685,7 +678,7 @@ void CRYPT_ImportSystemRootCertsToReg(void) ...@@ -685,7 +678,7 @@ void CRYPT_ImportSystemRootCertsToReg(void)
{ {
if ((store = create_root_store())) if ((store = create_root_store()))
{ {
rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, certs_root_pathW, 0, NULL, 0, rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\SystemCertificates\\Root\\Certificates", 0, NULL, 0,
KEY_ALL_ACCESS, NULL, &key, 0); KEY_ALL_ACCESS, NULL, &key, 0);
if (!rc) if (!rc)
{ {
......
...@@ -35,32 +35,6 @@ ...@@ -35,32 +35,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(crypt); WINE_DEFAULT_DEBUG_CHANNEL(crypt);
static const WCHAR szOID[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'C','r','y','p','t','o','g','r','a','p','h','y','\\',
'O','I','D','\\',
'E','n','c','o','d','i','n','g','T','y','p','e',' ','0','\\',
'C','r','y','p','t','S','I','P','D','l','l', 0 };
static const WCHAR szPutSigned[] = {
'P','u','t','S','i','g','n','e','d','D','a','t','a','M','s','g','\\',0};
static const WCHAR szGetSigned[] = {
'G','e','t','S','i','g','n','e','d','D','a','t','a','M','s','g','\\',0};
static const WCHAR szRemoveSigned[] = {
'R','e','m','o','v','e','S','i','g','n','e','d','D','a','t','a','M','s','g','\\',0};
static const WCHAR szCreate[] = {
'C','r','e','a','t','e','I','n','d','i','r','e','c','t','D','a','t','a','\\',0};
static const WCHAR szVerify[] = {
'V','e','r','i','f','y','I','n','d','i','r','e','c','t','D','a','t','a','\\',0};
static const WCHAR szIsMyFile[] = {
'I','s','M','y','F','i','l','e','T','y','p','e','\\',0};
static const WCHAR szIsMyFile2[] = {
'I','s','M','y','F','i','l','e','T','y','p','e','2','\\',0};
static const WCHAR szDllName[] = { 'D','l','l',0 };
static const WCHAR szFuncName[] = { 'F','u','n','c','N','a','m','e',0 };
/* convert a guid to a wide character string */ /* convert a guid to a wide character string */
static void CRYPT_guid2wstr( const GUID *guid, LPWSTR wstr ) static void CRYPT_guid2wstr( const GUID *guid, LPWSTR wstr )
{ {
...@@ -84,7 +58,7 @@ static LONG CRYPT_SIPDeleteFunction( const GUID *guid, LPCWSTR szKey ) ...@@ -84,7 +58,7 @@ static LONG CRYPT_SIPDeleteFunction( const GUID *guid, LPCWSTR szKey )
LONG r = ERROR_SUCCESS; LONG r = ERROR_SUCCESS;
/* max length of szFullKey depends on our code only, so we won't overrun */ /* max length of szFullKey depends on our code only, so we won't overrun */
lstrcpyW( szFullKey, szOID ); lstrcpyW( szFullKey, L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptSIPDll" );
lstrcatW( szFullKey, szKey ); lstrcatW( szFullKey, szKey );
CRYPT_guid2wstr( guid, &szFullKey[ lstrlenW( szFullKey ) ] ); CRYPT_guid2wstr( guid, &szFullKey[ lstrlenW( szFullKey ) ] );
...@@ -127,13 +101,13 @@ BOOL WINAPI CryptSIPRemoveProvider(GUID *pgProv) ...@@ -127,13 +101,13 @@ BOOL WINAPI CryptSIPRemoveProvider(GUID *pgProv)
r = CRYPT_SIPDeleteFunction( pgProv, key); \ r = CRYPT_SIPDeleteFunction( pgProv, key); \
if (r != ERROR_SUCCESS) remove_error = r if (r != ERROR_SUCCESS) remove_error = r
CRYPT_SIPREMOVEPROV( szPutSigned); CRYPT_SIPREMOVEPROV( L"PutSignedDataMsg\\" );
CRYPT_SIPREMOVEPROV( szGetSigned); CRYPT_SIPREMOVEPROV( L"GetSignedDataMsg\\" );
CRYPT_SIPREMOVEPROV( szRemoveSigned); CRYPT_SIPREMOVEPROV( L"RemoveSignedDataMsg\\" );
CRYPT_SIPREMOVEPROV( szCreate); CRYPT_SIPREMOVEPROV( L"CreateIndirectData\\" );
CRYPT_SIPREMOVEPROV( szVerify); CRYPT_SIPREMOVEPROV( L"VerifyIndirectData\\" );
CRYPT_SIPREMOVEPROV( szIsMyFile); CRYPT_SIPREMOVEPROV( L"IsMyFileType\\" );
CRYPT_SIPREMOVEPROV( szIsMyFile2); CRYPT_SIPREMOVEPROV( L"IsMyFileType2\\" );
#undef CRYPT_SIPREMOVEPROV #undef CRYPT_SIPREMOVEPROV
...@@ -163,7 +137,7 @@ static LONG CRYPT_SIPWriteFunction( const GUID *guid, LPCWSTR szKey, ...@@ -163,7 +137,7 @@ static LONG CRYPT_SIPWriteFunction( const GUID *guid, LPCWSTR szKey,
return ERROR_SUCCESS; return ERROR_SUCCESS;
/* max length of szFullKey depends on our code only, so we won't overrun */ /* max length of szFullKey depends on our code only, so we won't overrun */
lstrcpyW( szFullKey, szOID ); lstrcpyW( szFullKey, L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptSIPDll" );
lstrcatW( szFullKey, szKey ); lstrcatW( szFullKey, szKey );
CRYPT_guid2wstr( guid, &szFullKey[ lstrlenW( szFullKey ) ] ); CRYPT_guid2wstr( guid, &szFullKey[ lstrlenW( szFullKey ) ] );
...@@ -173,10 +147,10 @@ static LONG CRYPT_SIPWriteFunction( const GUID *guid, LPCWSTR szKey, ...@@ -173,10 +147,10 @@ static LONG CRYPT_SIPWriteFunction( const GUID *guid, LPCWSTR szKey,
if( r != ERROR_SUCCESS ) goto error_close_key; if( r != ERROR_SUCCESS ) goto error_close_key;
/* write the values */ /* write the values */
r = RegSetValueExW( hKey, szFuncName, 0, REG_SZ, (const BYTE*) szFunction, r = RegSetValueExW( hKey, L"FuncName", 0, REG_SZ, (const BYTE*) szFunction,
( lstrlenW( szFunction ) + 1 ) * sizeof (WCHAR) ); ( lstrlenW( szFunction ) + 1 ) * sizeof (WCHAR) );
if( r != ERROR_SUCCESS ) goto error_close_key; if( r != ERROR_SUCCESS ) goto error_close_key;
r = RegSetValueExW( hKey, szDllName, 0, REG_SZ, (const BYTE*) szDll, r = RegSetValueExW( hKey, L"Dll", 0, REG_SZ, (const BYTE*) szDll,
( lstrlenW( szDll ) + 1) * sizeof (WCHAR) ); ( lstrlenW( szDll ) + 1) * sizeof (WCHAR) );
error_close_key: error_close_key:
...@@ -234,13 +208,13 @@ BOOL WINAPI CryptSIPAddProvider(SIP_ADD_NEWPROVIDER *psNewProv) ...@@ -234,13 +208,13 @@ BOOL WINAPI CryptSIPAddProvider(SIP_ADD_NEWPROVIDER *psNewProv)
psNewProv->pwszDLLFileName, psNewProv->field); \ psNewProv->pwszDLLFileName, psNewProv->field); \
if (r != ERROR_SUCCESS) goto end_function if (r != ERROR_SUCCESS) goto end_function
CRYPT_SIPADDPROV( szPutSigned, pwszPutFuncName ); CRYPT_SIPADDPROV( L"PutSignedDataMsg\\", pwszPutFuncName );
CRYPT_SIPADDPROV( szGetSigned, pwszGetFuncName ); CRYPT_SIPADDPROV( L"GetSignedDataMsg\\", pwszGetFuncName );
CRYPT_SIPADDPROV( szRemoveSigned, pwszRemoveFuncName ); CRYPT_SIPADDPROV( L"RemoveSignedDataMsg\\", pwszRemoveFuncName );
CRYPT_SIPADDPROV( szCreate, pwszCreateFuncName ); CRYPT_SIPADDPROV( L"CreateIndirectData\\", pwszCreateFuncName );
CRYPT_SIPADDPROV( szVerify, pwszVerifyFuncName ); CRYPT_SIPADDPROV( L"VerifyIndirectData\\", pwszVerifyFuncName );
CRYPT_SIPADDPROV( szIsMyFile, pwszIsFunctionName ); CRYPT_SIPADDPROV( L"IsMyFileType\\", pwszIsFunctionName );
CRYPT_SIPADDPROV( szIsMyFile2, pwszIsFunctionNameFmt2 ); CRYPT_SIPADDPROV( L"IsMyFileType2\\", pwszIsFunctionNameFmt2 );
#undef CRYPT_SIPADDPROV #undef CRYPT_SIPADDPROV
...@@ -266,7 +240,7 @@ static void *CRYPT_LoadSIPFuncFromKey(HKEY key, HMODULE *pLib) ...@@ -266,7 +240,7 @@ static void *CRYPT_LoadSIPFuncFromKey(HKEY key, HMODULE *pLib)
/* Read the DLL entry */ /* Read the DLL entry */
size = sizeof(dllName); size = sizeof(dllName);
r = RegQueryValueExW(key, szDllName, NULL, NULL, (LPBYTE)dllName, &size); r = RegQueryValueExW(key, L"Dll", NULL, NULL, (LPBYTE)dllName, &size);
if (r) goto end; if (r) goto end;
/* Read the Function entry */ /* Read the Function entry */
...@@ -320,7 +294,6 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid ...@@ -320,7 +294,6 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid
static const WORD dosHdr = IMAGE_DOS_SIGNATURE; static const WORD dosHdr = IMAGE_DOS_SIGNATURE;
static const BYTE cabHdr[] = { 'M','S','C','F' }; static const BYTE cabHdr[] = { 'M','S','C','F' };
BYTE hdr[SIP_MAX_MAGIC_NUMBER]; BYTE hdr[SIP_MAX_MAGIC_NUMBER];
WCHAR szFullKey[ 0x100 ];
LONG r = ERROR_SUCCESS; LONG r = ERROR_SUCCESS;
HKEY key; HKEY key;
...@@ -431,10 +404,7 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid ...@@ -431,10 +404,7 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid
} }
/* Check for supported functions using CryptSIPDllIsMyFileType */ /* Check for supported functions using CryptSIPDllIsMyFileType */
/* max length of szFullKey depends on our code only, so we won't overrun */ r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptSIPDllIsMyFileType\\", 0, KEY_READ, &key);
lstrcpyW(szFullKey, szOID);
lstrcatW(szFullKey, szIsMyFile);
r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szFullKey, 0, KEY_READ, &key);
if (r == ERROR_SUCCESS) if (r == ERROR_SUCCESS)
{ {
DWORD index = 0, size; DWORD index = 0, size;
...@@ -470,9 +440,7 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid ...@@ -470,9 +440,7 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid
/* Check for supported functions using CryptSIPDllIsMyFileType2 */ /* Check for supported functions using CryptSIPDllIsMyFileType2 */
if (!bRet) if (!bRet)
{ {
lstrcpyW(szFullKey, szOID); r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptSIPDllIsMyFileType2\\", 0, KEY_READ, &key);
lstrcatW(szFullKey, szIsMyFile2);
r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szFullKey, 0, KEY_READ, &key);
if (r == ERROR_SUCCESS) if (r == ERROR_SUCCESS)
{ {
DWORD index = 0, size; DWORD index = 0, size;
...@@ -526,7 +494,7 @@ static LONG CRYPT_OpenSIPFunctionKey(const GUID *guid, LPCWSTR function, ...@@ -526,7 +494,7 @@ static LONG CRYPT_OpenSIPFunctionKey(const GUID *guid, LPCWSTR function,
{ {
WCHAR szFullKey[ 0x100 ]; WCHAR szFullKey[ 0x100 ];
lstrcpyW(szFullKey, szOID); lstrcpyW(szFullKey, L"Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptSIPDll");
lstrcatW(szFullKey, function); lstrcatW(szFullKey, function);
CRYPT_guid2wstr(guid, &szFullKey[lstrlenW(szFullKey)]); CRYPT_guid2wstr(guid, &szFullKey[lstrlenW(szFullKey)]);
return RegOpenKeyExW(HKEY_LOCAL_MACHINE, szFullKey, 0, KEY_READ, key); return RegOpenKeyExW(HKEY_LOCAL_MACHINE, szFullKey, 0, KEY_READ, key);
...@@ -628,25 +596,25 @@ static BOOL CRYPT_LoadSIP(const GUID *pgSubject) ...@@ -628,25 +596,25 @@ static BOOL CRYPT_LoadSIP(const GUID *pgSubject)
SIP_DISPATCH_INFO sip = { 0 }; SIP_DISPATCH_INFO sip = { 0 };
HMODULE lib = NULL, temp = NULL; HMODULE lib = NULL, temp = NULL;
sip.pfGet = CRYPT_LoadSIPFunc(pgSubject, szGetSigned, &lib); sip.pfGet = CRYPT_LoadSIPFunc(pgSubject, L"GetSignedDataMsg\\", &lib);
if (!sip.pfGet) if (!sip.pfGet)
goto error; goto error;
sip.pfPut = CRYPT_LoadSIPFunc(pgSubject, szPutSigned, &temp); sip.pfPut = CRYPT_LoadSIPFunc(pgSubject, L"PutSignedDataMsg\\", &temp);
if (!sip.pfPut || temp != lib) if (!sip.pfPut || temp != lib)
goto error; goto error;
FreeLibrary(temp); FreeLibrary(temp);
temp = NULL; temp = NULL;
sip.pfCreate = CRYPT_LoadSIPFunc(pgSubject, szCreate, &temp); sip.pfCreate = CRYPT_LoadSIPFunc(pgSubject, L"CreateIndirectData\\", &temp);
if (!sip.pfCreate || temp != lib) if (!sip.pfCreate || temp != lib)
goto error; goto error;
FreeLibrary(temp); FreeLibrary(temp);
temp = NULL; temp = NULL;
sip.pfVerify = CRYPT_LoadSIPFunc(pgSubject, szVerify, &temp); sip.pfVerify = CRYPT_LoadSIPFunc(pgSubject, L"VerifyIndirectData\\", &temp);
if (!sip.pfVerify || temp != lib) if (!sip.pfVerify || temp != lib)
goto error; goto error;
FreeLibrary(temp); FreeLibrary(temp);
temp = NULL; temp = NULL;
sip.pfRemove = CRYPT_LoadSIPFunc(pgSubject, szRemoveSigned, &temp); sip.pfRemove = CRYPT_LoadSIPFunc(pgSubject, L"RemoveSignedDataMsg\\", &temp);
if (!sip.pfRemove || temp != lib) if (!sip.pfRemove || temp != lib)
goto error; goto error;
FreeLibrary(temp); FreeLibrary(temp);
......
...@@ -402,12 +402,9 @@ static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv, ...@@ -402,12 +402,9 @@ static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv,
return (WINECRYPT_CERTSTORE*)store; return (WINECRYPT_CERTSTORE*)store;
} }
static const WCHAR rootW[] = { 'R','o','o','t',0 };
static WINECRYPT_CERTSTORE *CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv, static WINECRYPT_CERTSTORE *CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv,
DWORD dwFlags, const void *pvPara) DWORD dwFlags, const void *pvPara)
{ {
static const WCHAR fmt[] = { '%','s','\\','%','s',0 };
LPCWSTR storeName = pvPara; LPCWSTR storeName = pvPara;
LPWSTR storePath; LPWSTR storePath;
WINECRYPT_CERTSTORE *store = NULL; WINECRYPT_CERTSTORE *store = NULL;
...@@ -429,7 +426,7 @@ static WINECRYPT_CERTSTORE *CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv, ...@@ -429,7 +426,7 @@ static WINECRYPT_CERTSTORE *CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv,
root = HKEY_LOCAL_MACHINE; root = HKEY_LOCAL_MACHINE;
base = CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH; base = CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH;
/* If the HKLM\Root certs are requested, expressing system certs into the registry */ /* If the HKLM\Root certs are requested, expressing system certs into the registry */
if (!lstrcmpiW(storeName, rootW)) if (!lstrcmpiW(storeName, L"Root"))
CRYPT_ImportSystemRootCertsToReg(); CRYPT_ImportSystemRootCertsToReg();
break; break;
case CERT_SYSTEM_STORE_CURRENT_USER: case CERT_SYSTEM_STORE_CURRENT_USER:
...@@ -482,7 +479,7 @@ static WINECRYPT_CERTSTORE *CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv, ...@@ -482,7 +479,7 @@ static WINECRYPT_CERTSTORE *CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv,
REGSAM sam = dwFlags & CERT_STORE_READONLY_FLAG ? KEY_READ : REGSAM sam = dwFlags & CERT_STORE_READONLY_FLAG ? KEY_READ :
KEY_ALL_ACCESS; KEY_ALL_ACCESS;
wsprintfW(storePath, fmt, base, storeName); wsprintfW(storePath, L"%s\\%s", base, storeName);
if (dwFlags & CERT_STORE_OPEN_EXISTING_FLAG) if (dwFlags & CERT_STORE_OPEN_EXISTING_FLAG)
rc = RegOpenKeyExW(root, storePath, 0, sam, &key); rc = RegOpenKeyExW(root, storePath, 0, sam, &key);
else else
...@@ -1352,7 +1349,7 @@ BOOL WINAPI CertEnumSystemStore(DWORD dwFlags, void *pvSystemStoreLocationPara, ...@@ -1352,7 +1349,7 @@ BOOL WINAPI CertEnumSystemStore(DWORD dwFlags, void *pvSystemStoreLocationPara,
*/ */
if (ret && (dwFlags & CERT_SYSTEM_STORE_LOCATION_MASK) == if (ret && (dwFlags & CERT_SYSTEM_STORE_LOCATION_MASK) ==
CERT_SYSTEM_STORE_LOCAL_MACHINE) CERT_SYSTEM_STORE_LOCAL_MACHINE)
ret = pfnEnum(rootW, dwFlags, &info, NULL, pvArg); ret = pfnEnum(L"Root", dwFlags, &info, NULL, pvArg);
return ret; return ret;
} }
......
...@@ -570,18 +570,13 @@ static DWORD CRYPT_AddPrefixW(LPCWSTR prefix, LPWSTR psz, DWORD csz) ...@@ -570,18 +570,13 @@ static DWORD CRYPT_AddPrefixW(LPCWSTR prefix, LPWSTR psz, DWORD csz)
return chars; return chars;
} }
static const WCHAR indent[] = { ' ',' ',' ',' ',' ',0 }; static const WCHAR indent[] = L" ";
DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indentLevel, DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indentLevel,
const CERT_NAME_BLOB *pName, DWORD dwStrType, LPWSTR psz, DWORD csz) const CERT_NAME_BLOB *pName, DWORD dwStrType, LPWSTR psz, DWORD csz)
{ {
static const DWORD unsupportedFlags = CERT_NAME_STR_NO_QUOTING_FLAG | static const DWORD unsupportedFlags = CERT_NAME_STR_NO_QUOTING_FLAG |
CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG; CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG;
static const WCHAR commaSep[] = { ',',' ',0 };
static const WCHAR semiSep[] = { ';',' ',0 };
static const WCHAR crlfSep[] = { '\r','\n',0 };
static const WCHAR plusSep[] = { ' ','+',' ',0 };
static const WCHAR spaceSep[] = { ' ',0 };
DWORD ret = 0, bytes = 0; DWORD ret = 0, bytes = 0;
BOOL bRet; BOOL bRet;
CERT_NAME_INFO *info; CERT_NAME_INFO *info;
...@@ -601,16 +596,16 @@ DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indentLevel, ...@@ -601,16 +596,16 @@ DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indentLevel,
if(reverse && info->cRDN > 1) rdn += (info->cRDN - 1); if(reverse && info->cRDN > 1) rdn += (info->cRDN - 1);
if (dwStrType & CERT_NAME_STR_SEMICOLON_FLAG) if (dwStrType & CERT_NAME_STR_SEMICOLON_FLAG)
sep = semiSep; sep = L"; ";
else if (dwStrType & CERT_NAME_STR_CRLF_FLAG) else if (dwStrType & CERT_NAME_STR_CRLF_FLAG)
sep = crlfSep; sep = L"\r\n";
else else
sep = commaSep; sep = L", ";
sepLen = lstrlenW(sep); sepLen = lstrlenW(sep);
if (dwStrType & CERT_NAME_STR_NO_PLUS_FLAG) if (dwStrType & CERT_NAME_STR_NO_PLUS_FLAG)
rdnSep = spaceSep; rdnSep = L" ";
else else
rdnSep = plusSep; rdnSep = L" + ";
rdnSepLen = lstrlenW(rdnSep); rdnSepLen = lstrlenW(rdnSep);
for (i = 0; (!psz || ret < csz) && i < info->cRDN; i++) for (i = 0; (!psz || ret < csz) && i < info->cRDN; i++)
{ {
...@@ -1069,25 +1064,20 @@ BOOL WINAPI CertStrToNameW(DWORD dwCertEncodingType, LPCWSTR pszX500, ...@@ -1069,25 +1064,20 @@ BOOL WINAPI CertStrToNameW(DWORD dwCertEncodingType, LPCWSTR pszX500,
} }
else else
{ {
static const WCHAR commaSep[] = { ',',0 };
static const WCHAR semiSep[] = { ';',0 };
static const WCHAR crlfSep[] = { '\r','\n',0 };
static const WCHAR allSepsWithoutPlus[] = { ',',';','\r','\n',0 };
static const WCHAR allSeps[] = { '+',',',';','\r','\n',0 };
LPCWSTR sep; LPCWSTR sep;
WCHAR sep_used; WCHAR sep_used;
str++; str++;
if (dwStrType & CERT_NAME_STR_COMMA_FLAG) if (dwStrType & CERT_NAME_STR_COMMA_FLAG)
sep = commaSep; sep = L",";
else if (dwStrType & CERT_NAME_STR_SEMICOLON_FLAG) else if (dwStrType & CERT_NAME_STR_SEMICOLON_FLAG)
sep = semiSep; sep = L";";
else if (dwStrType & CERT_NAME_STR_CRLF_FLAG) else if (dwStrType & CERT_NAME_STR_CRLF_FLAG)
sep = crlfSep; sep = L"\r\n";
else if (dwStrType & CERT_NAME_STR_NO_PLUS_FLAG) else if (dwStrType & CERT_NAME_STR_NO_PLUS_FLAG)
sep = allSepsWithoutPlus; sep = L",;\r\n";
else else
sep = allSeps; sep = L"+,;\r\n";
ret = CRYPT_GetNextValueW(str, dwStrType, sep, &sep_used, &token, ret = CRYPT_GetNextValueW(str, dwStrType, sep, &sep_used, &token,
ppszError); ppszError);
if (ret) if (ret)
......
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