Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
1d947024
Commit
1d947024
authored
May 24, 2010
by
Juan Lang
Committed by
Alexandre Julliard
May 26, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32/tests: Always compare serialized stores in memory.
parent
6451b962
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
62 deletions
+38
-62
store.c
dlls/crypt32/tests/store.c
+38
-62
No files found.
dlls/crypt32/tests/store.c
View file @
1d947024
...
@@ -277,29 +277,35 @@ static void testMemStore(void)
...
@@ -277,29 +277,35 @@ static void testMemStore(void)
CertCloseStore
(
store1
,
0
);
CertCloseStore
(
store1
,
0
);
}
}
static
void
compareFile
(
LPCWSTR
filename
,
const
BYTE
*
pb
,
DWORD
cb
)
static
void
compareStore
(
HCERTSTORE
store
,
LPCSTR
name
,
const
BYTE
*
pb
,
DWORD
cb
,
BOOL
todo
)
{
{
HANDLE
h
;
BYTE
buf
[
200
];
BOOL
ret
;
BOOL
ret
;
DWORD
cbRead
=
0
,
totalRead
=
0
;
CRYPT_DATA_BLOB
blob
=
{
0
,
NULL
}
;
h
=
CreateFileW
(
filename
,
GENERIC_READ
,
0
,
NULL
,
OPEN_EXISTING
,
ret
=
CertSaveStore
(
store
,
X509_ASN_ENCODING
,
CERT_STORE_SAVE_AS_STORE
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
CERT_STORE_SAVE_TO_MEMORY
,
&
blob
,
0
);
if
(
h
==
INVALID_HANDLE_VALUE
)
ok
(
ret
,
"CertSaveStore failed: %08x
\n
"
,
GetLastError
());
return
;
if
(
todo
)
do
{
todo_wine
ret
=
ReadFile
(
h
,
buf
,
sizeof
(
buf
),
&
cbRead
,
NULL
);
ok
(
blob
.
cbData
==
cb
,
"%s: expected size %d, got %d
\n
"
,
name
,
cb
,
if
(
ret
&&
cbRead
)
blob
.
cbData
);
{
else
ok
(
totalRead
+
cbRead
<=
cb
,
"Expected total count %d, see %d
\n
"
,
ok
(
blob
.
cbData
==
cb
,
"%s: expected size %d, got %d
\n
"
,
name
,
cb
,
cb
,
totalRead
+
cbRead
);
blob
.
cbData
);
ok
(
!
memcmp
(
pb
+
totalRead
,
buf
,
cbRead
),
blob
.
pbData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
blob
.
cbData
);
"Unexpected data in file
\n
"
);
if
(
blob
.
pbData
)
totalRead
+=
cbRead
;
{
}
ret
=
CertSaveStore
(
store
,
X509_ASN_ENCODING
,
CERT_STORE_SAVE_AS_STORE
,
}
while
(
ret
&&
cbRead
);
CERT_STORE_SAVE_TO_MEMORY
,
&
blob
,
0
);
CloseHandle
(
h
);
ok
(
ret
,
"CertSaveStore failed: %08x
\n
"
,
GetLastError
());
if
(
todo
)
todo_wine
ok
(
!
memcmp
(
pb
,
blob
.
pbData
,
cb
),
"%s: unexpected value
\n
"
,
name
);
else
ok
(
!
memcmp
(
pb
,
blob
.
pbData
,
cb
),
"%s: unexpected value
\n
"
,
name
);
HeapFree
(
GetProcessHeap
(),
0
,
blob
.
pbData
);
}
}
}
static
const
BYTE
serializedStoreWithCert
[]
=
{
static
const
BYTE
serializedStoreWithCert
[]
=
{
...
@@ -689,11 +695,10 @@ static void testCollectionStore(void)
...
@@ -689,11 +695,10 @@ static void testCollectionStore(void)
GetLastError
());
GetLastError
());
ret
=
pCertControlStore
(
collection
,
0
,
CERT_STORE_CTRL_COMMIT
,
NULL
);
ret
=
pCertControlStore
(
collection
,
0
,
CERT_STORE_CTRL_COMMIT
,
NULL
);
ok
(
ret
,
"CertControlStore failed: %d
\n
"
,
ret
);
ok
(
ret
,
"CertControlStore failed: %d
\n
"
,
ret
);
compareStore
(
collection
,
"serialized store with cert"
,
serializedStoreWithCert
,
sizeof
(
serializedStoreWithCert
),
FALSE
);
CertCloseStore
(
collection
,
0
);
CertCloseStore
(
collection
,
0
);
compareFile
(
filename
,
serializedStoreWithCert
,
sizeof
(
serializedStoreWithCert
));
DeleteFileW
(
filename
);
DeleteFileW
(
filename
);
}
}
...
@@ -1294,8 +1299,8 @@ static void testFileStore(void)
...
@@ -1294,8 +1299,8 @@ static void testFileStore(void)
/* with commits enabled, commit is allowed */
/* with commits enabled, commit is allowed */
ret
=
pCertControlStore
(
store
,
0
,
CERT_STORE_CTRL_COMMIT
,
NULL
);
ret
=
pCertControlStore
(
store
,
0
,
CERT_STORE_CTRL_COMMIT
,
NULL
);
ok
(
ret
,
"CertControlStore failed: %d
\n
"
,
ret
);
ok
(
ret
,
"CertControlStore failed: %d
\n
"
,
ret
);
compare
File
(
filename
,
serializedStoreWithCert
,
compare
Store
(
store
,
"serialized store with cert"
,
s
izeof
(
serializedStoreWithCert
)
);
s
erializedStoreWithCert
,
sizeof
(
serializedStoreWithCert
),
FALSE
);
CertCloseStore
(
store
,
0
);
CertCloseStore
(
store
,
0
);
}
}
file
=
CreateFileW
(
filename
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
file
=
CreateFileW
(
filename
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
...
@@ -1311,9 +1316,10 @@ static void testFileStore(void)
...
@@ -1311,9 +1316,10 @@ static void testFileStore(void)
ret
=
CertAddEncodedCRLToStore
(
store
,
X509_ASN_ENCODING
,
signedCRL
,
ret
=
CertAddEncodedCRLToStore
(
store
,
X509_ASN_ENCODING
,
signedCRL
,
sizeof
(
signedCRL
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
sizeof
(
signedCRL
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
ret
,
"CertAddEncodedCRLToStore failed: %08x
\n
"
,
GetLastError
());
ok
(
ret
,
"CertAddEncodedCRLToStore failed: %08x
\n
"
,
GetLastError
());
compareStore
(
store
,
"serialized store with cert and CRL"
,
serializedStoreWithCertAndCRL
,
sizeof
(
serializedStoreWithCertAndCRL
),
FALSE
);
CertCloseStore
(
store
,
0
);
CertCloseStore
(
store
,
0
);
compareFile
(
filename
,
serializedStoreWithCertAndCRL
,
sizeof
(
serializedStoreWithCertAndCRL
));
}
}
DeleteFileW
(
filename
);
DeleteFileW
(
filename
);
...
@@ -1517,9 +1523,9 @@ static void testFileNameStore(void)
...
@@ -1517,9 +1523,9 @@ static void testFileNameStore(void)
bigCert
,
sizeof
(
bigCert
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
bigCert
,
sizeof
(
bigCert
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08x
\n
"
,
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08x
\n
"
,
GetLastError
());
GetLastError
());
compareStore
(
store
,
"serialized store with cert"
,
serializedStoreWithCert
,
sizeof
(
serializedStoreWithCert
),
FALSE
);
CertCloseStore
(
store
,
0
);
CertCloseStore
(
store
,
0
);
compareFile
(
filename
,
serializedStoreWithCert
,
sizeof
(
serializedStoreWithCert
));
}
}
store
=
CertOpenStore
(
CERT_STORE_PROV_FILENAME_W
,
0
,
0
,
store
=
CertOpenStore
(
CERT_STORE_PROV_FILENAME_W
,
0
,
0
,
CERT_FILE_STORE_COMMIT_ENABLE_FLAG
,
filename
);
CERT_FILE_STORE_COMMIT_ENABLE_FLAG
,
filename
);
...
@@ -1529,9 +1535,10 @@ static void testFileNameStore(void)
...
@@ -1529,9 +1535,10 @@ static void testFileNameStore(void)
ret
=
CertAddEncodedCRLToStore
(
store
,
X509_ASN_ENCODING
,
ret
=
CertAddEncodedCRLToStore
(
store
,
X509_ASN_ENCODING
,
signedCRL
,
sizeof
(
signedCRL
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
signedCRL
,
sizeof
(
signedCRL
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
ret
,
"CertAddEncodedCRLToStore failed: %08x
\n
"
,
GetLastError
());
ok
(
ret
,
"CertAddEncodedCRLToStore failed: %08x
\n
"
,
GetLastError
());
compareStore
(
store
,
"serialized store with cert and CRL"
,
serializedStoreWithCertAndCRL
,
sizeof
(
serializedStoreWithCertAndCRL
),
FALSE
);
CertCloseStore
(
store
,
0
);
CertCloseStore
(
store
,
0
);
compareFile
(
filename
,
serializedStoreWithCertAndCRL
,
sizeof
(
serializedStoreWithCertAndCRL
));
}
}
DeleteFileW
(
filename
);
DeleteFileW
(
filename
);
...
@@ -2063,37 +2070,6 @@ static void testAddSerialized(void)
...
@@ -2063,37 +2070,6 @@ static void testAddSerialized(void)
CertCloseStore
(
store
,
0
);
CertCloseStore
(
store
,
0
);
}
}
static
void
compareStore
(
HCERTSTORE
store
,
LPCSTR
name
,
const
BYTE
*
pb
,
DWORD
cb
,
BOOL
todo
)
{
BOOL
ret
;
CRYPT_DATA_BLOB
blob
=
{
0
,
NULL
};
ret
=
CertSaveStore
(
store
,
X509_ASN_ENCODING
,
CERT_STORE_SAVE_AS_STORE
,
CERT_STORE_SAVE_TO_MEMORY
,
&
blob
,
0
);
ok
(
ret
,
"CertSaveStore failed: %08x
\n
"
,
GetLastError
());
if
(
todo
)
todo_wine
ok
(
blob
.
cbData
==
cb
,
"%s: expected size %d, got %d
\n
"
,
name
,
cb
,
blob
.
cbData
);
else
ok
(
blob
.
cbData
==
cb
,
"%s: expected size %d, got %d
\n
"
,
name
,
cb
,
blob
.
cbData
);
blob
.
pbData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
blob
.
cbData
);
if
(
blob
.
pbData
)
{
ret
=
CertSaveStore
(
store
,
X509_ASN_ENCODING
,
CERT_STORE_SAVE_AS_STORE
,
CERT_STORE_SAVE_TO_MEMORY
,
&
blob
,
0
);
ok
(
ret
,
"CertSaveStore failed: %08x
\n
"
,
GetLastError
());
if
(
todo
)
todo_wine
ok
(
!
memcmp
(
pb
,
blob
.
pbData
,
cb
),
"%s: unexpected value
\n
"
,
name
);
else
ok
(
!
memcmp
(
pb
,
blob
.
pbData
,
cb
),
"%s: unexpected value
\n
"
,
name
);
HeapFree
(
GetProcessHeap
(),
0
,
blob
.
pbData
);
}
}
static
const
BYTE
serializedCertWithFriendlyName
[]
=
{
static
const
BYTE
serializedCertWithFriendlyName
[]
=
{
0x0b
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x12
,
0x00
,
0x00
,
0x00
,
0x57
,
0x00
,
0x69
,
0x0b
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x12
,
0x00
,
0x00
,
0x00
,
0x57
,
0x00
,
0x69
,
0x00
,
0x6e
,
0x00
,
0x65
,
0x00
,
0x54
,
0x00
,
0x65
,
0x00
,
0x73
,
0x00
,
0x74
,
0x00
,
0x00
,
0x00
,
0x00
,
0x6e
,
0x00
,
0x65
,
0x00
,
0x54
,
0x00
,
0x65
,
0x00
,
0x73
,
0x00
,
0x74
,
0x00
,
0x00
,
0x00
,
...
...
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