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
7e9ba76d
Commit
7e9ba76d
authored
May 11, 2006
by
Juan Lang
Committed by
Alexandre Julliard
May 15, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Use the HRESULT synonyms for converted Win32 error codes.
parent
746bf215
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
93 additions
and
133 deletions
+93
-133
cert.c
dlls/crypt32/cert.c
+4
-4
encode.c
dlls/crypt32/encode.c
+4
-4
oid.c
dlls/crypt32/oid.c
+1
-1
serialize.c
dlls/crypt32/serialize.c
+4
-5
store.c
dlls/crypt32/store.c
+13
-13
cert.c
dlls/crypt32/tests/cert.c
+10
-17
encode.c
dlls/crypt32/tests/encode.c
+8
-11
main.c
dlls/crypt32/tests/main.c
+2
-4
oid.c
dlls/crypt32/tests/oid.c
+3
-3
store.c
dlls/crypt32/tests/store.c
+44
-71
No files found.
dlls/crypt32/cert.c
View file @
7e9ba76d
...
...
@@ -266,7 +266,7 @@ BOOL WINAPI CryptVerifyCertificateSignatureEx(HCRYPTPROV hCryptProv,
break
;
}
default:
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
ret
=
FALSE
;
}
...
...
@@ -301,18 +301,18 @@ BOOL WINAPI CryptVerifyCertificateSignatureEx(HCRYPTPROV hCryptProv,
case
CRYPT_VERIFY_CERT_SIGN_ISSUER_NULL
:
if
(
pvIssuer
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
ret
=
FALSE
;
}
else
{
FIXME
(
"unimplemented for NULL signer
\n
"
);
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
ret
=
FALSE
;
}
break
;
default:
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
ret
=
FALSE
;
}
LocalFree
(
signedCert
);
...
...
dlls/crypt32/encode.c
View file @
7e9ba76d
...
...
@@ -1010,7 +1010,7 @@ static BOOL WINAPI CRYPT_AsnEncodeNameValue(DWORD dwCertEncodingType,
break
;
case
CERT_RDN_ANY_TYPE
:
/* explicitly disallowed */
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
FALSE
;
default:
FIXME
(
"String type %ld unimplemented
\n
"
,
value
->
dwValueType
);
...
...
@@ -1325,7 +1325,7 @@ static BOOL CRYPT_AsnEncodeAltNameEntry(const CERT_ALT_NAME_ENTRY *entry,
FIXME
(
"name type %ld unimplemented
\n
"
,
entry
->
dwAltNameChoice
);
return
FALSE
;
default:
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
FALSE
;
}
if
(
ret
)
...
...
@@ -1539,7 +1539,7 @@ static BOOL WINAPI CRYPT_AsnEncodeRsaPubKey(DWORD dwCertEncodingType,
if
(
hdr
->
bType
!=
PUBLICKEYBLOB
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
ret
=
FALSE
;
}
else
...
...
@@ -2171,7 +2171,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCRLDistPoints(DWORD dwCertEncodingType,
if
(
!
info
->
cDistPoint
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
ret
=
FALSE
;
}
else
...
...
dlls/crypt32/oid.c
View file @
7e9ba76d
...
...
@@ -453,7 +453,7 @@ BOOL WINAPI CryptRegisterOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName,
*/
if
(
!
pszFuncName
||
!
pszOID
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
FALSE
;
}
...
...
dlls/crypt32/serialize.c
View file @
7e9ba76d
...
...
@@ -251,7 +251,7 @@ static const WINE_CERT_PROP_HEADER *CRYPT_findPropID(const BYTE *buf,
buf
+=
sizeof
(
WINE_CERT_PROP_HEADER
);
if
(
size
<
hdr
->
cb
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
done
=
TRUE
;
}
else
if
(
!
hdr
->
propID
)
...
...
@@ -348,7 +348,7 @@ const void *CRYPT_ReadSerializedElement(const BYTE *pbElement, DWORD cbElement,
contextInterface
=
&
gCTLInterface
;
break
;
default:
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
ret
=
FALSE
;
}
if
(
!
hdr
)
...
...
@@ -375,8 +375,7 @@ const void *CRYPT_ReadSerializedElement(const BYTE *pbElement, DWORD cbElement,
pbElement
+=
sizeof
(
WINE_CERT_PROP_HEADER
);
if
(
cbElement
<
hdr
->
cb
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
));
SetLastError
(
E_INVALIDARG
);
ret
=
FALSE
;
}
else
if
(
!
hdr
->
propID
)
...
...
@@ -492,7 +491,7 @@ BOOL WINAPI CertAddSerializedElementToStore(HCERTSTORE hCertStore,
contextInterface
=
&
gCTLInterface
;
break
;
default:
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
}
if
(
contextInterface
)
{
...
...
dlls/crypt32/store.c
View file @
7e9ba76d
...
...
@@ -525,7 +525,7 @@ static BOOL CRYPT_CollectionAddCert(PWINECRYPT_CERTSTORE store,
}
LeaveCriticalSection
(
&
cs
->
cs
);
if
(
!
storeEntry
)
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_ACCESS_DENIED
)
);
SetLastError
(
E_ACCESSDENIED
);
}
if
(
ppStoreContext
&&
childContext
)
{
...
...
@@ -1410,7 +1410,7 @@ static PWINECRYPT_CERTSTORE CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv,
if
(
!
pvPara
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
NULL
;
}
...
...
@@ -1458,7 +1458,7 @@ static PWINECRYPT_CERTSTORE CRYPT_SysRegOpenStoreW(HCRYPTPROV hCryptProv,
debugstr_w
(
storeName
));
return
NULL
;
default:
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
NULL
;
}
...
...
@@ -1693,7 +1693,7 @@ HCERTSTORE WINAPI CertOpenSystemStoreA(HCRYPTPROV hProv,
{
if
(
!
szSubSystemProtocol
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
0
;
}
return
CertOpenStore
(
CERT_STORE_PROV_SYSTEM_A
,
0
,
hProv
,
...
...
@@ -1705,7 +1705,7 @@ HCERTSTORE WINAPI CertOpenSystemStoreW(HCRYPTPROV hProv,
{
if
(
!
szSubSystemProtocol
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
0
;
}
return
CertOpenStore
(
CERT_STORE_PROV_SYSTEM_W
,
0
,
hProv
,
...
...
@@ -1985,7 +1985,7 @@ BOOL WINAPI CertGetCertificateContextProperty(PCCERT_CONTEXT pCertContext,
case
CERT_CERT_PROP_ID
:
case
CERT_CRL_PROP_ID
:
case
CERT_CTL_PROP_ID
:
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
ret
=
FALSE
;
break
;
case
CERT_ACCESS_STATE_PROP_ID
:
...
...
@@ -2172,7 +2172,7 @@ BOOL WINAPI CertSetCertificateContextProperty(PCCERT_CONTEXT pCertContext,
case
CERT_CERT_PROP_ID
:
case
CERT_CRL_PROP_ID
:
case
CERT_CTL_PROP_ID
:
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
FALSE
;
}
ret
=
CertContext_SetProperty
((
PWINE_CERT_CONTEXT
)
pCertContext
,
dwPropId
,
...
...
@@ -2716,7 +2716,7 @@ PCCERT_CONTEXT WINAPI CertGetSubjectCertificateFromStore(HCERTSTORE hCertStore,
if
(
!
pCertId
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
NULL
;
}
return
CertFindCertificateInStore
(
hCertStore
,
dwCertEncodingType
,
0
,
...
...
@@ -2782,17 +2782,17 @@ BOOL WINAPI CertAddStoreToCollection(HCERTSTORE hCollectionStore,
return
TRUE
;
if
(
collection
->
hdr
.
dwMagic
!=
WINE_CRYPTCERTSTORE_MAGIC
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
FALSE
;
}
if
(
collection
->
hdr
.
type
!=
StoreTypeCollection
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
FALSE
;
}
if
(
sibling
->
dwMagic
!=
WINE_CRYPTCERTSTORE_MAGIC
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
FALSE
;
}
...
...
@@ -2848,14 +2848,14 @@ void WINAPI CertRemoveStoreFromCollection(HCERTSTORE hCollectionStore,
return
;
if
(
collection
->
hdr
.
dwMagic
!=
WINE_CRYPTCERTSTORE_MAGIC
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
;
}
if
(
collection
->
hdr
.
type
!=
StoreTypeCollection
)
return
;
if
(
sibling
->
dwMagic
!=
WINE_CRYPTCERTSTORE_MAGIC
)
{
SetLastError
(
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
);
SetLastError
(
E_INVALIDARG
);
return
;
}
EnterCriticalSection
(
&
collection
->
cs
);
...
...
dlls/crypt32/tests/cert.c
View file @
7e9ba76d
...
...
@@ -187,18 +187,15 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned,
if
(
pCryptVerifyCertificateSignatureEx
)
{
ret
=
pCryptVerifyCertificateSignatureEx
(
0
,
0
,
0
,
NULL
,
0
,
NULL
,
0
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
ret
=
pCryptVerifyCertificateSignatureEx
(
csp
,
0
,
0
,
NULL
,
0
,
NULL
,
0
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
ret
=
pCryptVerifyCertificateSignatureEx
(
csp
,
X509_ASN_ENCODING
,
0
,
NULL
,
0
,
NULL
,
0
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* This crashes
ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING,
CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, NULL, 0, NULL, 0, NULL);
...
...
@@ -234,17 +231,13 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned,
certBlob
.
pbData
=
cert
;
ret
=
pCryptVerifyCertificateSignatureEx
(
csp
,
X509_ASN_ENCODING
,
CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB
,
&
certBlob
,
0
,
NULL
,
0
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
ret
=
pCryptVerifyCertificateSignatureEx
(
csp
,
X509_ASN_ENCODING
,
CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB
,
&
certBlob
,
CRYPT_VERIFY_CERT_SIGN_ISSUER_NULL
,
NULL
,
0
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* This crashes
ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING,
CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob,
...
...
dlls/crypt32/tests/encode.c
View file @
7e9ba76d
...
...
@@ -800,8 +800,8 @@ static void test_encodeName(DWORD dwEncoding)
attrs
[
0
].
dwValueType
=
CERT_RDN_ANY_TYPE
;
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
X509_NAME
,
&
info
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
,
"Expected E
RROR_INVALID_PARAMETER
, got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E
_INVALIDARG
, got %08lx
\n
"
,
GetLastError
());
for
(
i
=
0
;
i
<
sizeof
(
names
)
/
sizeof
(
names
[
0
]);
i
++
)
{
rdn
.
cRDNAttr
=
1
;
...
...
@@ -1028,9 +1028,8 @@ static void test_encodeAltName(DWORD dwEncoding)
info
.
rgAltEntry
=
&
entry
;
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
X509_ALTERNATE_NAME
,
&
info
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* Test with an empty pointer */
entry
.
dwAltNameChoice
=
CERT_ALT_NAME_URL
;
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
X509_ALTERNATE_NAME
,
&
info
,
...
...
@@ -1637,9 +1636,8 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding)
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
RSA_CSP_PUBLICKEYBLOB
,
toEncode
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
bufSize
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* Now with a bogus reserved field */
hdr
->
bType
=
PUBLICKEYBLOB
;
hdr
->
reserved
=
1
;
...
...
@@ -2421,9 +2419,8 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding)
/* Test with an empty info */
ret
=
CryptEncodeObjectEx
(
dwEncoding
,
X509_CRL_DIST_POINTS
,
&
info
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
(
BYTE
*
)
&
buf
,
&
size
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* Test with one empty dist point */
info
.
cDistPoint
=
1
;
info
.
rgDistPoint
=
&
point
;
...
...
dlls/crypt32/tests/main.c
View file @
7e9ba76d
...
...
@@ -244,10 +244,8 @@ static void test_cryptTls(void)
/* Not sure if this fails because TlsFree should fail, so leave as
* todo for now.
*/
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
}
/* Similar pass, check I_CryptDetachTls */
index
=
pI_CryptAllocTls
();
...
...
dlls/crypt32/tests/oid.c
View file @
7e9ba76d
...
...
@@ -273,12 +273,12 @@ static void test_registerOIDFunction(void)
"1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
*/
/* On windows XP, GetLastError is incorrectly being set with an HRESULT,
*
HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER)
*
E_INVALIDARG
*/
ret
=
CryptRegisterOIDFunction
(
X509_ASN_ENCODING
,
"foo"
,
NULL
,
bogusDll
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
)
,
"Expected E
RROR_INVALID_PARAMETER
: %ld
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E
_INVALIDARG
: %ld
\n
"
,
GetLastError
());
/* This has no effect, but "succeeds" on XP */
ret
=
CryptRegisterOIDFunction
(
X509_ASN_ENCODING
,
"foo"
,
"1.2.3.4.5.6.7.8.9.10"
,
NULL
,
NULL
);
...
...
dlls/crypt32/tests/store.c
View file @
7e9ba76d
...
...
@@ -207,10 +207,8 @@ static void testAddCert(void)
/* but adding a new certificate isn't allowed. */
ret
=
CertAddCertificateContextToStore
(
collection
,
context
,
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_ACCESS_DENIED
),
"Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_ACCESSDENIED
,
"Expected E_ACCESSDENIED, got %08lx
\n
"
,
GetLastError
());
CertFreeCertificateContext
(
context
);
}
...
...
@@ -396,10 +394,8 @@ static void testGetSubjectCert(void)
context2
=
CertGetSubjectCertificateFromStore
(
store
,
X509_ASN_ENCODING
,
NULL
);
ok
(
!
context2
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
context2
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
context2
=
CertGetSubjectCertificateFromStore
(
store
,
X509_ASN_ENCODING
,
&
info
);
ok
(
!
context2
&&
GetLastError
()
==
CRYPT_E_NOT_FOUND
,
...
...
@@ -736,9 +732,8 @@ static void testCollectionStore(void)
/* Try adding a cert to any empty collection */
ret
=
CertAddEncodedCertificateToStore
(
collection
,
X509_ASN_ENCODING
,
bigCert
,
sizeof
(
bigCert
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_ACCESS_DENIED
),
"Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_ACCESSDENIED
,
"Expected E_ACCESSDENIED, got %08lx
\n
"
,
GetLastError
());
/* Create and add a cert to a memory store */
store1
=
CertOpenStore
(
CERT_STORE_PROV_MEMORY
,
0
,
0
,
...
...
@@ -760,9 +755,8 @@ static void testCollectionStore(void)
/* Check that adding to the collection isn't allowed */
ret
=
CertAddEncodedCertificateToStore
(
collection
,
X509_ASN_ENCODING
,
bigCert2
,
sizeof
(
bigCert2
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_ACCESS_DENIED
),
"Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_ACCESSDENIED
,
"Expected E_ACCESSDENIED, got %08lx
\n
"
,
GetLastError
());
/* Create a new memory store */
store2
=
CertOpenStore
(
CERT_STORE_PROV_MEMORY
,
0
,
0
,
...
...
@@ -770,9 +764,8 @@ static void testCollectionStore(void)
/* Try adding a store to a non-collection store */
ret
=
CertAddStoreToCollection
(
store1
,
store2
,
CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG
,
0
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* Try adding some bogus stores */
/* This crashes in Windows
ret = CertAddStoreToCollection(0, store2,
...
...
@@ -1363,10 +1356,8 @@ static void testSystemRegStore(void)
{
BOOL
ret
=
CertAddStoreToCollection
(
store
,
memStore
,
0
,
0
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
CertCloseStore
(
memStore
,
0
);
}
CertCloseStore
(
store
,
0
);
...
...
@@ -1387,19 +1378,16 @@ static void testSystemRegStore(void)
RegDeleteKeyW
(
HKEY_CURRENT_USER
,
BogusPathW
);
store
=
CertOpenStore
(
CERT_STORE_PROV_SYSTEM_REGISTRY
,
0
,
0
,
0
,
NULL
);
ok
(
!
store
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
store
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
store
=
CertOpenStore
(
CERT_STORE_PROV_SYSTEM_REGISTRY
,
0
,
0
,
CERT_SYSTEM_STORE_LOCAL_MACHINE
|
CERT_SYSTEM_STORE_CURRENT_USER
,
MyA
);
ok
(
!
store
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
store
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
store
=
CertOpenStore
(
CERT_STORE_PROV_SYSTEM_REGISTRY
,
0
,
0
,
CERT_SYSTEM_STORE_LOCAL_MACHINE
|
CERT_SYSTEM_STORE_CURRENT_USER
,
MyW
);
ok
(
!
store
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
store
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* The name is expected to be UNICODE, check with an ASCII name */
store
=
CertOpenStore
(
CERT_STORE_PROV_SYSTEM_REGISTRY
,
0
,
0
,
CERT_SYSTEM_STORE_CURRENT_USER
|
CERT_STORE_OPEN_EXISTING_FLAG
,
MyA
);
...
...
@@ -1487,9 +1475,8 @@ static void testCertOpenSystemStore(void)
HCERTSTORE
store
;
store
=
CertOpenSystemStoreW
(
0
,
NULL
);
ok
(
!
store
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
store
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* This succeeds, and on WinXP at least, the Bogus key is created under
* HKCU (but not under HKLM, even when run as an administrator.)
*/
...
...
@@ -1552,20 +1539,16 @@ static void testCertProperties(void)
/* Tests with a NULL cert context. Prop ID 0 fails.. */
ret
=
CertSetCertificateContextProperty
(
NULL
,
0
,
0
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* while this just crashes.
ret = CertSetCertificateContextProperty(NULL,
CERT_KEY_PROV_HANDLE_PROP_ID, 0, NULL);
*/
ret
=
CertSetCertificateContextProperty
(
context
,
0
,
0
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* Can't set the cert property directly, this crashes.
ret = CertSetCertificateContextProperty(context,
CERT_CERT_PROP_ID, 0, bigCert2);
...
...
@@ -1684,66 +1667,56 @@ static void testAddSerialized(void)
hdr
->
cb
=
0
;
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
buf
),
0
,
0
,
0
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* Test with a bad size in property header */
hdr
->
cb
=
sizeof
(
bigCert
)
-
1
;
memcpy
(
buf
+
sizeof
(
struct
CertPropIDHeader
),
bigCert
,
sizeof
(
bigCert
));
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
buf
),
0
,
0
,
0
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
0
,
0
,
0
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
CERT_STORE_ADD_NEW
,
0
,
0
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* Kosher size in property header, but no context type */
hdr
->
cb
=
sizeof
(
bigCert
);
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
buf
),
0
,
0
,
0
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
0
,
0
,
0
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
CERT_STORE_ADD_NEW
,
0
,
0
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* With a bad context type */
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
buf
),
0
,
0
,
CERT_STORE_CRL_CONTEXT_FLAG
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
0
,
0
,
CERT_STORE_CRL_CONTEXT_FLAG
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
struct
CertPropIDHeader
)
+
sizeof
(
bigCert
),
CERT_STORE_ADD_NEW
,
0
,
CERT_STORE_CRL_CONTEXT_FLAG
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
ok
(
!
ret
&&
GetLastError
()
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %08lx
\n
"
,
GetLastError
());
/* Bad unknown field, good type */
hdr
->
unknown1
=
2
;
ret
=
CertAddSerializedElementToStore
(
store
,
buf
,
sizeof
(
buf
),
0
,
0
,
...
...
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