Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
4120fb99
Commit
4120fb99
authored
Nov 09, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Use wide-character string literals.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
03bf2369
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
94 additions
and
197 deletions
+94
-197
base64.c
dlls/crypt32/base64.c
+13
-29
cert.c
dlls/crypt32/cert.c
+2
-3
chain.c
dlls/crypt32/chain.c
+5
-11
filestore.c
dlls/crypt32/filestore.c
+1
-3
main.c
dlls/crypt32/main.c
+1
-7
object.c
dlls/crypt32/object.c
+19
-31
oid.c
dlls/crypt32/oid.c
+0
-0
protectdata.c
dlls/crypt32/protectdata.c
+1
-2
regstore.c
dlls/crypt32/regstore.c
+9
-16
rootstore.c
dlls/crypt32/rootstore.c
+2
-9
sip.c
dlls/crypt32/sip.c
+27
-59
store.c
dlls/crypt32/store.c
+3
-6
str.c
dlls/crypt32/str.c
+11
-21
No files found.
dlls/crypt32/base64.c
View file @
4120fb99
...
...
@@ -38,30 +38,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(crypt);
#define X509_HEADER "-----BEGIN X509 CRL-----"
#define X509_TRAILER "-----END X509 CRL-----"
static
const
WCHAR
CERT_HEADER_W
[]
=
{
'-'
,
'-'
,
'-'
,
'-'
,
'-'
,
'B'
,
'E'
,
'G'
,
'I'
,
'N'
,
' '
,
'C'
,
'E'
,
'R'
,
'T'
,
'I'
,
'F'
,
'I'
,
'C'
,
'A'
,
'T'
,
'E'
,
'-'
,
'-'
,
'-'
,
'-'
,
'-'
,
0
};
static
const
WCHAR
CERT_HEADER_START_W
[]
=
{
'-'
,
'-'
,
'-'
,
'-'
,
'-'
,
'B'
,
'E'
,
'G'
,
'I'
,
'N'
,
' '
,
0
};
static
const
WCHAR
CERT_DELIMITER_W
[]
=
{
'-'
,
'-'
,
'-'
,
'-'
,
'-'
,
0
};
static
const
WCHAR
CERT_TRAILER_W
[]
=
{
'-'
,
'-'
,
'-'
,
'-'
,
'-'
,
'E'
,
'N'
,
'D'
,
' '
,
'C'
,
'E'
,
'R'
,
'T'
,
'I'
,
'F'
,
'I'
,
'C'
,
'A'
,
'T'
,
'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
WCHAR
CERT_HEADER_W
[]
=
L"-----BEGIN CERTIFICATE-----"
;
static
const
WCHAR
CERT_HEADER_START_W
[]
=
L"-----BEGIN "
;
static
const
WCHAR
CERT_DELIMITER_W
[]
=
L"-----"
;
static
const
WCHAR
CERT_TRAILER_W
[]
=
L"-----END CERTIFICATE-----"
;
static
const
WCHAR
CERT_TRAILER_START_W
[]
=
L"-----END "
;
static
const
WCHAR
CERT_REQUEST_HEADER_W
[]
=
L"-----BEGIN NEW CERTIFICATE REQUEST-----"
;
static
const
WCHAR
CERT_REQUEST_TRAILER_W
[]
=
L"-----END NEW CERTIFICATE REQUEST-----"
;
static
const
WCHAR
X509_HEADER_W
[]
=
L"-----BEGIN X509 CRL-----"
;
static
const
WCHAR
X509_TRAILER_W
[]
=
L"-----END X509 CRL-----"
;
static
const
char
b64
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
...
...
@@ -402,17 +387,16 @@ static LONG encodeBase64W(const BYTE *in_buf, int in_len, LPCWSTR sep,
static
BOOL
BinaryToBase64W
(
const
BYTE
*
pbBinary
,
DWORD
cbBinary
,
DWORD
dwFlags
,
LPWSTR
pszString
,
DWORD
*
pcchString
)
{
static
const
WCHAR
crlf
[]
=
{
'\r'
,
'\n'
,
0
},
lf
[]
=
{
'\n'
,
0
},
empty
[]
=
{
0
};
BOOL
ret
=
TRUE
;
LPCWSTR
header
=
NULL
,
trailer
=
NULL
,
sep
;
DWORD
charsNeeded
;
if
(
dwFlags
&
CRYPT_STRING_NOCR
)
sep
=
lf
;
sep
=
L"
\n
"
;
else
if
(
dwFlags
&
CRYPT_STRING_NOCRLF
)
sep
=
empty
;
sep
=
L""
;
else
sep
=
crlf
;
sep
=
L"
\r\n
"
;
switch
(
dwFlags
&
0x0fffffff
)
{
case
CRYPT_STRING_BASE64
:
...
...
@@ -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
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
;
if
(
flags
&
CRYPT_STRING_NOCRLF
)
...
...
dlls/crypt32/cert.c
View file @
4120fb99
...
...
@@ -984,11 +984,10 @@ BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert,
if
(
!
ret
)
{
static
const
WCHAR
myW
[]
=
{
'M'
,
'y'
,
0
};
HCERTSTORE
hstore
;
hstore
=
CertOpenStore
(
CERT_STORE_PROV_SYSTEM_W
,
0
,
0
,
CERT_SYSTEM_STORE_CURRENT_USER
,
myW
);
CERT_SYSTEM_STORE_CURRENT_USER
,
L"My"
);
if
(
hstore
)
{
cert_in_store
=
CertFindCertificateInStore
(
hstore
,
pCert
->
dwCertEncodingType
,
0
,
...
...
@@ -3670,7 +3669,7 @@ typedef RPC_STATUS (RPC_ENTRY *RpcStringFreeFunc)(unsigned char **);
static
HCRYPTPROV
CRYPT_CreateKeyProv
(
void
)
{
HCRYPTPROV
hProv
=
0
;
HMODULE
rpcrt
=
LoadLibrary
A
(
"rpcrt4"
);
HMODULE
rpcrt
=
LoadLibrary
W
(
L
"rpcrt4"
);
if
(
rpcrt
)
{
...
...
dlls/crypt32/chain.c
View file @
4120fb99
...
...
@@ -68,8 +68,6 @@ static inline void CRYPT_CloseStores(DWORD cStores, HCERTSTORE *stores)
CertCloseStore
(
stores
[
i
],
0
);
}
static
const
WCHAR
rootW
[]
=
{
'R'
,
'o'
,
'o'
,
't'
,
0
};
/* Finds cert in store by comparing the cert's hashes. */
static
PCCERT_CONTEXT
CRYPT_FindCertInStore
(
HCERTSTORE
store
,
PCCERT_CONTEXT
cert
)
...
...
@@ -94,7 +92,7 @@ static BOOL CRYPT_CheckRestrictedRoot(HCERTSTORE store)
if
(
store
)
{
HCERTSTORE
rootStore
=
CertOpenSystemStoreW
(
0
,
rootW
);
HCERTSTORE
rootStore
=
CertOpenSystemStoreW
(
0
,
L"Root"
);
PCCERT_CONTEXT
cert
=
NULL
,
check
;
do
{
...
...
@@ -119,17 +117,13 @@ HCERTCHAINENGINE CRYPT_CreateChainEngine(HCERTSTORE root, DWORD system_store, co
CertificateChainEngine
*
engine
;
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
(
config
->
cbSize
>=
sizeof
(
CERT_CHAIN_ENGINE_CONFIG
)
&&
config
->
hExclusiveRoot
)
root
=
CertDuplicateStore
(
config
->
hExclusiveRoot
);
else
if
(
config
->
hRestrictedRoot
)
root
=
CertDuplicateStore
(
config
->
hRestrictedRoot
);
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
)
return
NULL
;
}
...
...
@@ -144,9 +138,9 @@ HCERTCHAINENGINE CRYPT_CreateChainEngine(HCERTSTORE root, DWORD system_store, co
engine
->
hRoot
=
root
;
engine
->
hWorld
=
CertOpenStore
(
CERT_STORE_PROV_COLLECTION
,
0
,
0
,
CERT_STORE_CREATE_NEW_FLAG
,
NULL
);
worldStores
[
0
]
=
CertDuplicateStore
(
engine
->
hRoot
);
worldStores
[
1
]
=
CertOpenStore
(
CERT_STORE_PROV_SYSTEM_W
,
0
,
0
,
system_store
,
caW
);
worldStores
[
2
]
=
CertOpenStore
(
CERT_STORE_PROV_SYSTEM_W
,
0
,
0
,
system_store
,
myW
);
worldStores
[
3
]
=
CertOpenStore
(
CERT_STORE_PROV_SYSTEM_W
,
0
,
0
,
system_store
,
trustW
);
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
,
L"My"
);
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
,
config
->
cAdditionalStore
,
config
->
rghAdditionalStore
);
...
...
dlls/crypt32/filestore.c
View file @
4120fb99
...
...
@@ -353,14 +353,12 @@ WINECRYPT_CERTSTORE *CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv,
}
else
{
static
const
WCHAR
spc
[]
=
{
's'
,
'p'
,
'c'
,
0
};
static
const
WCHAR
p7c
[]
=
{
'p'
,
'7'
,
'c'
,
0
};
LPCWSTR
ext
=
wcsrchr
(
fileName
,
'.'
);
if
(
ext
)
{
ext
++
;
if
(
!
lstrcmpiW
(
ext
,
spc
)
||
!
lstrcmpiW
(
ext
,
p7c
))
if
(
!
lstrcmpiW
(
ext
,
L"spc"
)
||
!
lstrcmpiW
(
ext
,
L"p7c"
))
type
=
CERT_STORE_SAVE_AS_PKCS7
;
}
if
(
!
type
)
...
...
dlls/crypt32/main.c
View file @
4120fb99
...
...
@@ -255,12 +255,6 @@ HCRYPTPROV WINAPI DECLSPEC_HOTPATCH I_CryptGetDefaultCryptProv(ALG_ID algid)
BOOL
WINAPI
I_CryptReadTrustedPublisherDWORDValueFromRegistry
(
LPCWSTR
name
,
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
;
LONG
rc
;
BOOL
ret
=
FALSE
;
...
...
@@ -268,7 +262,7 @@ BOOL WINAPI I_CryptReadTrustedPublisherDWORDValueFromRegistry(LPCWSTR name,
TRACE
(
"(%s, %p)
\n
"
,
debugstr_w
(
name
),
value
);
*
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
)
{
DWORD
size
=
sizeof
(
DWORD
);
...
...
dlls/crypt32/object.c
View file @
4120fb99
...
...
@@ -858,8 +858,6 @@ static BOOL WINAPI CRYPT_FormatHexString(DWORD dwCertEncodingType,
}
else
{
static
const
WCHAR
fmt
[]
=
{
'%'
,
'0'
,
'2'
,
'x'
,
' '
,
0
};
static
const
WCHAR
endFmt
[]
=
{
'%'
,
'0'
,
'2'
,
'x'
,
0
};
DWORD
i
;
LPWSTR
ptr
=
pbFormat
;
...
...
@@ -869,9 +867,9 @@ static BOOL WINAPI CRYPT_FormatHexString(DWORD dwCertEncodingType,
for
(
i
=
0
;
i
<
cbEncoded
;
i
++
)
{
if
(
i
<
cbEncoded
-
1
)
ptr
+=
swprintf
(
ptr
,
4
,
fmt
,
pbEncoded
[
i
]);
ptr
+=
swprintf
(
ptr
,
4
,
L"%02x "
,
pbEncoded
[
i
]);
else
ptr
+=
swprintf
(
ptr
,
3
,
endFmt
,
pbEncoded
[
i
]);
ptr
+=
swprintf
(
ptr
,
3
,
L"%02x"
,
pbEncoded
[
i
]);
}
}
else
...
...
@@ -883,7 +881,7 @@ static BOOL WINAPI CRYPT_FormatHexString(DWORD dwCertEncodingType,
#define MAX_STRING_RESOURCE_LEN 128
static
const
WCHAR
commaSpace
[]
=
{
','
,
' '
,
0
}
;
static
const
WCHAR
commaSpace
[]
=
L", "
;
struct
BitToString
{
...
...
@@ -1063,7 +1061,7 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType,
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
subjectTypeCA
[
MAX_STRING_RESOURCE_LEN
];
...
...
@@ -1087,7 +1085,6 @@ static BOOL WINAPI CRYPT_FormatBasicConstraints2(DWORD dwCertEncodingType,
if
((
ret
=
CryptDecodeObjectEx
(
dwCertEncodingType
,
X509_BASIC_CONSTRAINTS2
,
pbEncoded
,
cbEncoded
,
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
&
info
,
&
size
)))
{
static
const
WCHAR
pathFmt
[]
=
{
'%'
,
'd'
,
0
};
static
BOOL
stringsLoaded
=
FALSE
;
DWORD
bytesNeeded
=
sizeof
(
WCHAR
);
/* space for the NULL terminator */
WCHAR
pathLength
[
MAX_STRING_RESOURCE_LEN
];
...
...
@@ -1122,7 +1119,7 @@ static BOOL WINAPI CRYPT_FormatBasicConstraints2(DWORD dwCertEncodingType,
bytesNeeded
+=
sepLen
;
bytesNeeded
+=
lstrlenW
(
pathLengthHeader
)
*
sizeof
(
WCHAR
);
if
(
info
->
fPathLenConstraint
)
swprintf
(
pathLength
,
ARRAY_SIZE
(
pathLength
),
pathFmt
,
info
->
dwPathLenConstraint
);
swprintf
(
pathLength
,
ARRAY_SIZE
(
pathLength
),
L"%d"
,
info
->
dwPathLenConstraint
);
else
LoadStringW
(
hInstance
,
IDS_PATH_LENGTH_NONE
,
pathLength
,
ARRAY_SIZE
(
pathLength
));
bytesNeeded
+=
lstrlenW
(
pathLength
)
*
sizeof
(
WCHAR
);
...
...
@@ -1201,8 +1198,8 @@ static BOOL CRYPT_FormatCertSerialNumber(const CRYPT_DATA_BLOB *serialNum, LPWST
str
,
pcbStr
);
}
static
const
WCHAR
indent
[]
=
{
' '
,
' '
,
' '
,
' '
,
' '
,
0
}
;
static
const
WCHAR
colonCrlf
[]
=
{
':'
,
'\r'
,
'\n'
,
0
}
;
static
const
WCHAR
indent
[]
=
L" "
;
static
const
WCHAR
colonCrlf
[]
=
L":
\r\n
"
;
static
BOOL
CRYPT_FormatAltNameEntry
(
DWORD
dwFormatStrType
,
DWORD
indentLevel
,
const
CERT_ALT_NAME_ENTRY
*
entry
,
LPWSTR
str
,
DWORD
*
pcbStr
)
...
...
@@ -1253,12 +1250,6 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
break
;
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
));
if
(
entry
->
u
.
IPAddress
.
cbData
==
8
)
{
...
...
@@ -1266,7 +1257,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
{
LoadStringW
(
hInstance
,
IDS_ALT_NAME_MASK
,
mask
,
ARRAY_SIZE
(
mask
));
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
[
1
],
entry
->
u
.
IPAddress
.
pbData
[
2
],
...
...
@@ -1274,7 +1265,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
bytesNeeded
+=
lstrlenW
(
ipAddrBuf
)
*
sizeof
(
WCHAR
);
/* indent again, for the mask line */
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
[
5
],
entry
->
u
.
IPAddress
.
pbData
[
6
],
...
...
@@ -1284,7 +1275,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
}
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
[
1
],
entry
->
u
.
IPAddress
.
pbData
[
2
],
...
...
@@ -1445,7 +1436,7 @@ static BOOL CRYPT_FormatAltNameInfo(DWORD dwFormatStrType, DWORD indentLevel,
return
ret
;
}
static
const
WCHAR
colonSep
[]
=
{
':'
,
' '
,
0
}
;
static
const
WCHAR
colonSep
[]
=
L": "
;
static
BOOL
WINAPI
CRYPT_FormatAltName
(
DWORD
dwCertEncodingType
,
DWORD
dwFormatType
,
DWORD
dwFormatStrType
,
void
*
pFormatStruct
,
...
...
@@ -1695,8 +1686,7 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType,
}
else
{
static
const
WCHAR
numFmt
[]
=
{
'%'
,
'd'
,
0
};
static
const
WCHAR
equal
[]
=
{
'='
,
0
};
static
const
WCHAR
equal
[]
=
L"="
;
static
BOOL
stringsLoaded
=
FALSE
;
DWORD
i
;
LPCWSTR
headingSep
,
accessMethodSep
,
locationSep
;
...
...
@@ -1729,7 +1719,7 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType,
{
/* Heading */
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
+=
sizeof
(
WCHAR
);
/* right bracket */
bytesNeeded
+=
lstrlenW
(
aia
)
*
sizeof
(
WCHAR
);
...
...
@@ -1786,7 +1776,7 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType,
LPCSTR
oidPtr
;
*
str
++
=
'['
;
swprintf
(
accessDescrNum
,
ARRAY_SIZE
(
accessDescrNum
),
numFmt
,
i
+
1
);
swprintf
(
accessDescrNum
,
ARRAY_SIZE
(
accessDescrNum
),
L"%d"
,
i
+
1
);
lstrcpyW
(
str
,
accessDescrNum
);
str
+=
lstrlenW
(
accessDescrNum
);
*
str
++
=
']'
;
...
...
@@ -1887,8 +1877,7 @@ static struct reason_map_entry reason_map[] = {
static
BOOL
CRYPT_FormatReason
(
DWORD
dwFormatStrType
,
const
CRYPT_BIT_BLOB
*
reasonFlags
,
LPWSTR
str
,
DWORD
*
pcbStr
)
{
static
const
WCHAR
sep
[]
=
{
','
,
' '
,
0
};
static
const
WCHAR
bitsFmt
[]
=
{
' '
,
'('
,
'%'
,
'0'
,
'2'
,
'x'
,
')'
,
0
};
static
const
WCHAR
sep
[]
=
L", "
;
static
BOOL
stringsLoaded
=
FALSE
;
unsigned
int
i
,
numReasons
=
0
;
BOOL
ret
=
TRUE
;
...
...
@@ -1914,7 +1903,7 @@ static BOOL CRYPT_FormatReason(DWORD dwFormatStrType,
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
);
if
(
!
str
)
*
pcbStr
=
bytesNeeded
;
...
...
@@ -1969,8 +1958,7 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType,
if
((
ret
=
CryptDecodeObjectEx
(
dwCertEncodingType
,
X509_CRL_DIST_POINTS
,
pbEncoded
,
cbEncoded
,
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
&
info
,
&
size
)))
{
static
const
WCHAR
numFmt
[]
=
{
'%'
,
'd'
,
0
};
static
const
WCHAR
colon
[]
=
{
':'
,
0
};
static
const
WCHAR
colon
[]
=
L":"
;
static
BOOL
stringsLoaded
=
FALSE
;
DWORD
bytesNeeded
=
sizeof
(
WCHAR
);
/* space for NULL terminator */
BOOL
haveAnEntry
=
FALSE
;
...
...
@@ -2048,7 +2036,7 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType,
if
(
haveAnEntry
)
{
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
+=
sizeof
(
WCHAR
);
/* right bracket */
bytesNeeded
+=
lstrlenW
(
crlDistPoint
)
*
sizeof
(
WCHAR
);
...
...
@@ -2097,7 +2085,7 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType,
CRL_DIST_POINT
*
distPoint
=
&
info
->
rgDistPoint
[
i
];
*
str
++
=
'['
;
swprintf
(
distPointNum
,
ARRAY_SIZE
(
distPointNum
),
numFmt
,
i
+
1
);
swprintf
(
distPointNum
,
ARRAY_SIZE
(
distPointNum
),
L"%d"
,
i
+
1
);
lstrcpyW
(
str
,
distPointNum
);
str
+=
lstrlenW
(
distPointNum
);
*
str
++
=
']'
;
...
...
dlls/crypt32/oid.c
View file @
4120fb99
This diff is collapsed.
Click to expand it.
dlls/crypt32/protectdata.c
View file @
4120fb99
...
...
@@ -826,7 +826,6 @@ BOOL WINAPI CryptProtectData(DATA_BLOB* pDataIn,
DWORD
dwFlags
,
DATA_BLOB
*
pDataOut
)
{
static
const
WCHAR
empty_str
[
1
];
BOOL
rc
=
FALSE
;
HCRYPTPROV
hProv
;
struct
protect_data_t
protect_data
;
...
...
@@ -852,7 +851,7 @@ BOOL WINAPI CryptProtectData(DATA_BLOB* pDataIn,
/* Windows appears to create an empty szDataDescr instead of maintaining
* a NULL */
if
(
!
szDataDescr
)
szDataDescr
=
empty_str
;
szDataDescr
=
L""
;
/* get crypt context */
if
(
!
CryptAcquireContextW
(
&
hProv
,
NULL
,
MS_ENHANCED_PROV_W
,
CRYPT32_PROTECTDATA_PROV
,
CRYPT_VERIFYCONTEXT
))
...
...
dlls/crypt32/regstore.c
View file @
4120fb99
...
...
@@ -47,22 +47,15 @@ typedef struct _WINE_REGSTOREINFO
static
void
CRYPT_HashToStr
(
const
BYTE
*
hash
,
LPWSTR
asciiHash
)
{
static
const
WCHAR
fmt
[]
=
{
'%'
,
'0'
,
'2'
,
'X'
,
0
};
DWORD
i
;
assert
(
hash
);
assert
(
asciiHash
);
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
,
HCERTSTORE
store
)
{
...
...
@@ -85,12 +78,12 @@ static void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType,
LPBYTE
buf
=
NULL
;
size
=
0
;
rc
=
RegQueryValueExW
(
subKey
,
BlobW
,
NULL
,
NULL
,
NULL
,
&
size
);
rc
=
RegQueryValueExW
(
subKey
,
L"Blob"
,
NULL
,
NULL
,
NULL
,
&
size
);
if
(
!
rc
)
buf
=
CryptMemAlloc
(
size
);
if
(
buf
)
{
rc
=
RegQueryValueExW
(
subKey
,
BlobW
,
NULL
,
NULL
,
buf
,
rc
=
RegQueryValueExW
(
subKey
,
L"Blob"
,
NULL
,
NULL
,
buf
,
&
size
);
if
(
!
rc
)
{
...
...
@@ -158,7 +151,7 @@ static void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType,
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
,
CERT_STORE_CRL_CONTEXT_FLAG
,
CERT_STORE_CTL_CONTEXT_FLAG
};
DWORD
i
;
...
...
@@ -192,7 +185,7 @@ static BOOL CRYPT_WriteSerializedToReg(HKEY key, DWORD flags, const BYTE *hash,
&
subKey
,
NULL
);
if
(
!
rc
)
{
rc
=
RegSetValueExW
(
subKey
,
BlobW
,
0
,
REG_BINARY
,
buf
,
len
);
rc
=
RegSetValueExW
(
subKey
,
L"Blob"
,
0
,
REG_BINARY
,
buf
,
len
);
RegCloseKey
(
subKey
);
}
if
(
!
rc
)
...
...
@@ -247,7 +240,7 @@ BOOL CRYPT_SerializeContextsToReg(HKEY key, DWORD flags,
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
,
pCRLInterface
,
pCTLInterface
};
struct
list
*
listToDelete
[]
=
{
&
store
->
certsToDelete
,
&
store
->
crlsToDelete
,
...
...
@@ -518,12 +511,12 @@ WINECRYPT_CERTSTORE *CRYPT_RegOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags,
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
)
rc
=
RegDeleteTreeW
((
HKEY
)
pvPara
,
CRLsW
);
rc
=
RegDeleteTreeW
((
HKEY
)
pvPara
,
L"CRLs"
);
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
)
rc
=
ERROR_SUCCESS
;
SetLastError
(
rc
);
...
...
dlls/crypt32/rootstore.c
View file @
4120fb99
...
...
@@ -653,13 +653,6 @@ static HCERTSTORE create_root_store(void)
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
)
{
HCERTSTORE
store
=
NULL
;
...
...
@@ -672,7 +665,7 @@ void CRYPT_ImportSystemRootCertsToReg(void)
if
(
root_certs_imported
)
return
;
hsem
=
CreateSemaphoreW
(
NULL
,
0
,
1
,
semaphoreW
);
hsem
=
CreateSemaphoreW
(
NULL
,
0
,
1
,
L"crypt32_root_semaphore"
);
if
(
!
hsem
)
{
ERR
(
"Failed to create semaphore
\n
"
);
...
...
@@ -685,7 +678,7 @@ void CRYPT_ImportSystemRootCertsToReg(void)
{
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
);
if
(
!
rc
)
{
...
...
dlls/crypt32/sip.c
View file @
4120fb99
...
...
@@ -35,32 +35,6 @@
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 */
static
void
CRYPT_guid2wstr
(
const
GUID
*
guid
,
LPWSTR
wstr
)
{
...
...
@@ -84,7 +58,7 @@ static LONG CRYPT_SIPDeleteFunction( const GUID *guid, LPCWSTR szKey )
LONG
r
=
ERROR_SUCCESS
;
/* 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
);
CRYPT_guid2wstr
(
guid
,
&
szFullKey
[
lstrlenW
(
szFullKey
)
]
);
...
...
@@ -127,13 +101,13 @@ BOOL WINAPI CryptSIPRemoveProvider(GUID *pgProv)
r = CRYPT_SIPDeleteFunction( pgProv, key); \
if (r != ERROR_SUCCESS) remove_error = r
CRYPT_SIPREMOVEPROV
(
szPutSigned
);
CRYPT_SIPREMOVEPROV
(
szGetSigned
);
CRYPT_SIPREMOVEPROV
(
szRemoveSigned
);
CRYPT_SIPREMOVEPROV
(
szCreate
);
CRYPT_SIPREMOVEPROV
(
szVerify
);
CRYPT_SIPREMOVEPROV
(
szIsMyFile
);
CRYPT_SIPREMOVEPROV
(
szIsMyFile2
);
CRYPT_SIPREMOVEPROV
(
L"PutSignedDataMsg
\\
"
);
CRYPT_SIPREMOVEPROV
(
L"GetSignedDataMsg
\\
"
);
CRYPT_SIPREMOVEPROV
(
L"RemoveSignedDataMsg
\\
"
);
CRYPT_SIPREMOVEPROV
(
L"CreateIndirectData
\\
"
);
CRYPT_SIPREMOVEPROV
(
L"VerifyIndirectData
\\
"
);
CRYPT_SIPREMOVEPROV
(
L"IsMyFileType
\\
"
);
CRYPT_SIPREMOVEPROV
(
L"IsMyFileType2
\\
"
);
#undef CRYPT_SIPREMOVEPROV
...
...
@@ -163,7 +137,7 @@ static LONG CRYPT_SIPWriteFunction( const GUID *guid, LPCWSTR szKey,
return
ERROR_SUCCESS
;
/* 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
);
CRYPT_guid2wstr
(
guid
,
&
szFullKey
[
lstrlenW
(
szFullKey
)
]
);
...
...
@@ -173,10 +147,10 @@ static LONG CRYPT_SIPWriteFunction( const GUID *guid, LPCWSTR szKey,
if
(
r
!=
ERROR_SUCCESS
)
goto
error_close_key
;
/* 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
)
);
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
)
);
error_close_key:
...
...
@@ -234,13 +208,13 @@ BOOL WINAPI CryptSIPAddProvider(SIP_ADD_NEWPROVIDER *psNewProv)
psNewProv->pwszDLLFileName, psNewProv->field); \
if (r != ERROR_SUCCESS) goto end_function
CRYPT_SIPADDPROV
(
szPutSigned
,
pwszPutFuncName
);
CRYPT_SIPADDPROV
(
szGetSigned
,
pwszGetFuncName
);
CRYPT_SIPADDPROV
(
szRemoveSigned
,
pwszRemoveFuncName
);
CRYPT_SIPADDPROV
(
szCreate
,
pwszCreateFuncName
);
CRYPT_SIPADDPROV
(
szVerify
,
pwszVerifyFuncName
);
CRYPT_SIPADDPROV
(
szIsMyFile
,
pwszIsFunctionName
);
CRYPT_SIPADDPROV
(
szIsMyFile2
,
pwszIsFunctionNameFmt2
);
CRYPT_SIPADDPROV
(
L"PutSignedDataMsg
\\
"
,
pwszPutFuncName
);
CRYPT_SIPADDPROV
(
L"GetSignedDataMsg
\\
"
,
pwszGetFuncName
);
CRYPT_SIPADDPROV
(
L"RemoveSignedDataMsg
\\
"
,
pwszRemoveFuncName
);
CRYPT_SIPADDPROV
(
L"CreateIndirectData
\\
"
,
pwszCreateFuncName
);
CRYPT_SIPADDPROV
(
L"VerifyIndirectData
\\
"
,
pwszVerifyFuncName
);
CRYPT_SIPADDPROV
(
L"IsMyFileType
\\
"
,
pwszIsFunctionName
);
CRYPT_SIPADDPROV
(
L"IsMyFileType2
\\
"
,
pwszIsFunctionNameFmt2
);
#undef CRYPT_SIPADDPROV
...
...
@@ -266,7 +240,7 @@ static void *CRYPT_LoadSIPFuncFromKey(HKEY key, HMODULE *pLib)
/* Read the DLL entry */
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
;
/* Read the Function entry */
...
...
@@ -320,7 +294,6 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid
static
const
WORD
dosHdr
=
IMAGE_DOS_SIGNATURE
;
static
const
BYTE
cabHdr
[]
=
{
'M'
,
'S'
,
'C'
,
'F'
};
BYTE
hdr
[
SIP_MAX_MAGIC_NUMBER
];
WCHAR
szFullKey
[
0x100
];
LONG
r
=
ERROR_SUCCESS
;
HKEY
key
;
...
...
@@ -431,10 +404,7 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid
}
/* Check for supported functions using CryptSIPDllIsMyFileType */
/* max length of szFullKey depends on our code only, so we won't overrun */
lstrcpyW
(
szFullKey
,
szOID
);
lstrcatW
(
szFullKey
,
szIsMyFile
);
r
=
RegOpenKeyExW
(
HKEY_LOCAL_MACHINE
,
szFullKey
,
0
,
KEY_READ
,
&
key
);
r
=
RegOpenKeyExW
(
HKEY_LOCAL_MACHINE
,
L"Software
\\
Microsoft
\\
Cryptography
\\
OID
\\
EncodingType 0
\\
CryptSIPDllIsMyFileType
\\
"
,
0
,
KEY_READ
,
&
key
);
if
(
r
==
ERROR_SUCCESS
)
{
DWORD
index
=
0
,
size
;
...
...
@@ -470,9 +440,7 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid
/* Check for supported functions using CryptSIPDllIsMyFileType2 */
if
(
!
bRet
)
{
lstrcpyW
(
szFullKey
,
szOID
);
lstrcatW
(
szFullKey
,
szIsMyFile2
);
r
=
RegOpenKeyExW
(
HKEY_LOCAL_MACHINE
,
szFullKey
,
0
,
KEY_READ
,
&
key
);
r
=
RegOpenKeyExW
(
HKEY_LOCAL_MACHINE
,
L"Software
\\
Microsoft
\\
Cryptography
\\
OID
\\
EncodingType 0
\\
CryptSIPDllIsMyFileType2
\\
"
,
0
,
KEY_READ
,
&
key
);
if
(
r
==
ERROR_SUCCESS
)
{
DWORD
index
=
0
,
size
;
...
...
@@ -526,7 +494,7 @@ static LONG CRYPT_OpenSIPFunctionKey(const GUID *guid, LPCWSTR function,
{
WCHAR
szFullKey
[
0x100
];
lstrcpyW
(
szFullKey
,
szOID
);
lstrcpyW
(
szFullKey
,
L"Software
\\
Microsoft
\\
Cryptography
\\
OID
\\
EncodingType 0
\\
CryptSIPDll"
);
lstrcatW
(
szFullKey
,
function
);
CRYPT_guid2wstr
(
guid
,
&
szFullKey
[
lstrlenW
(
szFullKey
)]);
return
RegOpenKeyExW
(
HKEY_LOCAL_MACHINE
,
szFullKey
,
0
,
KEY_READ
,
key
);
...
...
@@ -628,25 +596,25 @@ static BOOL CRYPT_LoadSIP(const GUID *pgSubject)
SIP_DISPATCH_INFO
sip
=
{
0
};
HMODULE
lib
=
NULL
,
temp
=
NULL
;
sip
.
pfGet
=
CRYPT_LoadSIPFunc
(
pgSubject
,
szGetSigned
,
&
lib
);
sip
.
pfGet
=
CRYPT_LoadSIPFunc
(
pgSubject
,
L"GetSignedDataMsg
\\
"
,
&
lib
);
if
(
!
sip
.
pfGet
)
goto
error
;
sip
.
pfPut
=
CRYPT_LoadSIPFunc
(
pgSubject
,
szPutSigned
,
&
temp
);
sip
.
pfPut
=
CRYPT_LoadSIPFunc
(
pgSubject
,
L"PutSignedDataMsg
\\
"
,
&
temp
);
if
(
!
sip
.
pfPut
||
temp
!=
lib
)
goto
error
;
FreeLibrary
(
temp
);
temp
=
NULL
;
sip
.
pfCreate
=
CRYPT_LoadSIPFunc
(
pgSubject
,
szCreate
,
&
temp
);
sip
.
pfCreate
=
CRYPT_LoadSIPFunc
(
pgSubject
,
L"CreateIndirectData
\\
"
,
&
temp
);
if
(
!
sip
.
pfCreate
||
temp
!=
lib
)
goto
error
;
FreeLibrary
(
temp
);
temp
=
NULL
;
sip
.
pfVerify
=
CRYPT_LoadSIPFunc
(
pgSubject
,
szVerify
,
&
temp
);
sip
.
pfVerify
=
CRYPT_LoadSIPFunc
(
pgSubject
,
L"VerifyIndirectData
\\
"
,
&
temp
);
if
(
!
sip
.
pfVerify
||
temp
!=
lib
)
goto
error
;
FreeLibrary
(
temp
);
temp
=
NULL
;
sip
.
pfRemove
=
CRYPT_LoadSIPFunc
(
pgSubject
,
szRemoveSigned
,
&
temp
);
sip
.
pfRemove
=
CRYPT_LoadSIPFunc
(
pgSubject
,
L"RemoveSignedDataMsg
\\
"
,
&
temp
);
if
(
!
sip
.
pfRemove
||
temp
!=
lib
)
goto
error
;
FreeLibrary
(
temp
);
...
...
dlls/crypt32/store.c
View file @
4120fb99
...
...
@@ -402,12 +402,9 @@ static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv,
return
(
WINECRYPT_CERTSTORE
*
)
store
;
}
static
const
WCHAR
rootW
[]
=
{
'R'
,
'o'
,
'o'
,
't'
,
0
};
static
WINECRYPT_CERTSTORE
*
CRYPT_SysRegOpenStoreW
(
HCRYPTPROV
hCryptProv
,
DWORD
dwFlags
,
const
void
*
pvPara
)
{
static
const
WCHAR
fmt
[]
=
{
'%'
,
's'
,
'\\'
,
'%'
,
's'
,
0
};
LPCWSTR
storeName
=
pvPara
;
LPWSTR
storePath
;
WINECRYPT_CERTSTORE
*
store
=
NULL
;
...
...
@@ -429,7 +426,7 @@ static WINECRYPT_CERTSTORE *CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv,
root
=
HKEY_LOCAL_MACHINE
;
base
=
CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH
;
/* If the HKLM\Root certs are requested, expressing system certs into the registry */
if
(
!
lstrcmpiW
(
storeName
,
rootW
))
if
(
!
lstrcmpiW
(
storeName
,
L"Root"
))
CRYPT_ImportSystemRootCertsToReg
();
break
;
case
CERT_SYSTEM_STORE_CURRENT_USER
:
...
...
@@ -482,7 +479,7 @@ static WINECRYPT_CERTSTORE *CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv,
REGSAM
sam
=
dwFlags
&
CERT_STORE_READONLY_FLAG
?
KEY_READ
:
KEY_ALL_ACCESS
;
wsprintfW
(
storePath
,
fmt
,
base
,
storeName
);
wsprintfW
(
storePath
,
L"%s
\\
%s"
,
base
,
storeName
);
if
(
dwFlags
&
CERT_STORE_OPEN_EXISTING_FLAG
)
rc
=
RegOpenKeyExW
(
root
,
storePath
,
0
,
sam
,
&
key
);
else
...
...
@@ -1352,7 +1349,7 @@ BOOL WINAPI CertEnumSystemStore(DWORD dwFlags, void *pvSystemStoreLocationPara,
*/
if
(
ret
&&
(
dwFlags
&
CERT_SYSTEM_STORE_LOCATION_MASK
)
==
CERT_SYSTEM_STORE_LOCAL_MACHINE
)
ret
=
pfnEnum
(
rootW
,
dwFlags
,
&
info
,
NULL
,
pvArg
);
ret
=
pfnEnum
(
L"Root"
,
dwFlags
,
&
info
,
NULL
,
pvArg
);
return
ret
;
}
...
...
dlls/crypt32/str.c
View file @
4120fb99
...
...
@@ -570,18 +570,13 @@ static DWORD CRYPT_AddPrefixW(LPCWSTR prefix, LPWSTR psz, DWORD csz)
return
chars
;
}
static
const
WCHAR
indent
[]
=
{
' '
,
' '
,
' '
,
' '
,
' '
,
0
}
;
static
const
WCHAR
indent
[]
=
L" "
;
DWORD
cert_name_to_str_with_indent
(
DWORD
dwCertEncodingType
,
DWORD
indentLevel
,
const
CERT_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
;
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
;
BOOL
bRet
;
CERT_NAME_INFO
*
info
;
...
...
@@ -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
(
dwStrType
&
CERT_NAME_STR_SEMICOLON_FLAG
)
sep
=
semiSep
;
sep
=
L"; "
;
else
if
(
dwStrType
&
CERT_NAME_STR_CRLF_FLAG
)
sep
=
crlfSep
;
sep
=
L"
\r\n
"
;
else
sep
=
commaSep
;
sep
=
L", "
;
sepLen
=
lstrlenW
(
sep
);
if
(
dwStrType
&
CERT_NAME_STR_NO_PLUS_FLAG
)
rdnSep
=
spaceSep
;
rdnSep
=
L" "
;
else
rdnSep
=
plusSep
;
rdnSep
=
L" + "
;
rdnSepLen
=
lstrlenW
(
rdnSep
);
for
(
i
=
0
;
(
!
psz
||
ret
<
csz
)
&&
i
<
info
->
cRDN
;
i
++
)
{
...
...
@@ -1069,25 +1064,20 @@ BOOL WINAPI CertStrToNameW(DWORD dwCertEncodingType, LPCWSTR pszX500,
}
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
;
WCHAR
sep_used
;
str
++
;
if
(
dwStrType
&
CERT_NAME_STR_COMMA_FLAG
)
sep
=
commaSep
;
sep
=
L","
;
else
if
(
dwStrType
&
CERT_NAME_STR_SEMICOLON_FLAG
)
sep
=
semiSep
;
sep
=
L";"
;
else
if
(
dwStrType
&
CERT_NAME_STR_CRLF_FLAG
)
sep
=
crlfSep
;
sep
=
L"
\r\n
"
;
else
if
(
dwStrType
&
CERT_NAME_STR_NO_PLUS_FLAG
)
sep
=
allSepsWithoutPlus
;
sep
=
L",;
\r\n
"
;
else
sep
=
allSeps
;
sep
=
L"+,;
\r\n
"
;
ret
=
CRYPT_GetNextValueW
(
str
,
dwStrType
,
sep
,
&
sep_used
,
&
token
,
ppszError
);
if
(
ret
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment