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
d76e1899
Commit
d76e1899
authored
Jul 27, 2007
by
Juan Lang
Committed by
Alexandre Julliard
Jul 30, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Add tests for message stores.
parent
115edc67
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
168 additions
and
0 deletions
+168
-0
store.c
dlls/crypt32/tests/store.c
+168
-0
No files found.
dlls/crypt32/tests/store.c
View file @
d76e1899
...
...
@@ -1333,6 +1333,173 @@ static void testFileNameStore(void)
DeleteFileW
(
filename
);
}
static
const
BYTE
signedContent
[]
=
{
0x30
,
0x81
,
0xb2
,
0x06
,
0x09
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x01
,
0x07
,
0x02
,
0xa0
,
0x81
,
0xa4
,
0x30
,
0x81
,
0xa1
,
0x02
,
0x01
,
0x01
,
0x31
,
0x0e
,
0x30
,
0x0c
,
0x06
,
0x08
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x02
,
0x05
,
0x05
,
0x00
,
0x30
,
0x13
,
0x06
,
0x09
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x01
,
0x07
,
0x01
,
0xa0
,
0x06
,
0x04
,
0x04
,
0x01
,
0x02
,
0x03
,
0x04
,
0x31
,
0x77
,
0x30
,
0x75
,
0x02
,
0x01
,
0x01
,
0x30
,
0x1a
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
0x0a
,
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
,
0x02
,
0x01
,
0x01
,
0x30
,
0x0c
,
0x06
,
0x08
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x02
,
0x05
,
0x05
,
0x00
,
0x30
,
0x04
,
0x06
,
0x00
,
0x05
,
0x00
,
0x04
,
0x40
,
0x81
,
0xa6
,
0x70
,
0xb3
,
0xef
,
0x59
,
0xd1
,
0x66
,
0xd1
,
0x9b
,
0xc0
,
0x9a
,
0xb6
,
0x9a
,
0x5e
,
0x6d
,
0x6f
,
0x6d
,
0x0d
,
0x59
,
0xa9
,
0xaa
,
0x6e
,
0xe9
,
0x2c
,
0xa0
,
0x1e
,
0xee
,
0xc2
,
0x60
,
0xbc
,
0x59
,
0xbe
,
0x3f
,
0x63
,
0x06
,
0x8d
,
0xc9
,
0x11
,
0x1d
,
0x23
,
0x64
,
0x92
,
0xef
,
0x2e
,
0xfc
,
0x57
,
0x29
,
0xa4
,
0xaf
,
0xe0
,
0xee
,
0x93
,
0x19
,
0x39
,
0x51
,
0xe4
,
0x44
,
0xb8
,
0x0b
,
0x28
,
0xf4
,
0xa8
,
0x0d
};
static
const
BYTE
signedWithCertAndCrlBareContent
[]
=
{
0x30
,
0x82
,
0x01
,
0x4f
,
0x02
,
0x01
,
0x01
,
0x31
,
0x0e
,
0x30
,
0x0c
,
0x06
,
0x08
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x02
,
0x05
,
0x05
,
0x00
,
0x30
,
0x13
,
0x06
,
0x09
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x01
,
0x07
,
0x01
,
0xa0
,
0x06
,
0x04
,
0x04
,
0x01
,
0x02
,
0x03
,
0x04
,
0xa0
,
0x7c
,
0x30
,
0x7a
,
0x02
,
0x01
,
0x01
,
0x30
,
0x02
,
0x06
,
0x00
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
0x0a
,
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
,
0x30
,
0x22
,
0x18
,
0x0f
,
0x31
,
0x36
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x5a
,
0x18
,
0x0f
,
0x31
,
0x36
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x5a
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
0x0a
,
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
,
0x30
,
0x07
,
0x30
,
0x02
,
0x06
,
0x00
,
0x03
,
0x01
,
0x00
,
0xa3
,
0x16
,
0x30
,
0x14
,
0x30
,
0x12
,
0x06
,
0x03
,
0x55
,
0x1d
,
0x13
,
0x01
,
0x01
,
0xff
,
0x04
,
0x08
,
0x30
,
0x06
,
0x01
,
0x01
,
0xff
,
0x02
,
0x01
,
0x01
,
0xa1
,
0x2e
,
0x30
,
0x2c
,
0x30
,
0x02
,
0x06
,
0x00
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
0x0a
,
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
,
0x18
,
0x0f
,
0x31
,
0x36
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x31
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x30
,
0x5a
,
0x31
,
0x77
,
0x30
,
0x75
,
0x02
,
0x01
,
0x01
,
0x30
,
0x1a
,
0x30
,
0x15
,
0x31
,
0x13
,
0x30
,
0x11
,
0x06
,
0x03
,
0x55
,
0x04
,
0x03
,
0x13
,
0x0a
,
0x4a
,
0x75
,
0x61
,
0x6e
,
0x20
,
0x4c
,
0x61
,
0x6e
,
0x67
,
0x00
,
0x02
,
0x01
,
0x01
,
0x30
,
0x0c
,
0x06
,
0x08
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x02
,
0x05
,
0x05
,
0x00
,
0x30
,
0x04
,
0x06
,
0x00
,
0x05
,
0x00
,
0x04
,
0x40
,
0x81
,
0xa6
,
0x70
,
0xb3
,
0xef
,
0x59
,
0xd1
,
0x66
,
0xd1
,
0x9b
,
0xc0
,
0x9a
,
0xb6
,
0x9a
,
0x5e
,
0x6d
,
0x6f
,
0x6d
,
0x0d
,
0x59
,
0xa9
,
0xaa
,
0x6e
,
0xe9
,
0x2c
,
0xa0
,
0x1e
,
0xee
,
0xc2
,
0x60
,
0xbc
,
0x59
,
0xbe
,
0x3f
,
0x63
,
0x06
,
0x8d
,
0xc9
,
0x11
,
0x1d
,
0x23
,
0x64
,
0x92
,
0xef
,
0x2e
,
0xfc
,
0x57
,
0x29
,
0xa4
,
0xaf
,
0xe0
,
0xee
,
0x93
,
0x19
,
0x39
,
0x51
,
0xe4
,
0x44
,
0xb8
,
0x0b
,
0x28
,
0xf4
,
0xa8
,
0x0d
};
static
const
BYTE
hashContent
[]
=
{
0x30
,
0x47
,
0x06
,
0x09
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x01
,
0x07
,
0x05
,
0xa0
,
0x3a
,
0x30
,
0x38
,
0x02
,
0x01
,
0x00
,
0x30
,
0x0c
,
0x06
,
0x08
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x02
,
0x05
,
0x05
,
0x00
,
0x30
,
0x13
,
0x06
,
0x09
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x01
,
0x07
,
0x01
,
0xa0
,
0x06
,
0x04
,
0x04
,
0x01
,
0x02
,
0x03
,
0x04
,
0x04
,
0x10
,
0x08
,
0xd6
,
0xc0
,
0x5a
,
0x21
,
0x51
,
0x2a
,
0x79
,
0xa1
,
0xdf
,
0xeb
,
0x9d
,
0x2a
,
0x8f
,
0x26
,
0x2f
};
static
const
BYTE
hashBareContent
[]
=
{
0x30
,
0x38
,
0x02
,
0x01
,
0x00
,
0x30
,
0x0c
,
0x06
,
0x08
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x02
,
0x05
,
0x05
,
0x00
,
0x30
,
0x13
,
0x06
,
0x09
,
0x2a
,
0x86
,
0x48
,
0x86
,
0xf7
,
0x0d
,
0x01
,
0x07
,
0x01
,
0xa0
,
0x06
,
0x04
,
0x04
,
0x01
,
0x02
,
0x03
,
0x04
,
0x04
,
0x10
,
0x08
,
0xd6
,
0xc0
,
0x5a
,
0x21
,
0x51
,
0x2a
,
0x79
,
0xa1
,
0xdf
,
0xeb
,
0x9d
,
0x2a
,
0x8f
,
0x26
,
0x2f
};
static
void
testMessageStore
(
void
)
{
HCERTSTORE
store
;
HCRYPTMSG
msg
=
CryptMsgOpenToDecode
(
PKCS_7_ASN_ENCODING
,
0
,
0
,
0
,
NULL
,
NULL
);
CRYPT_DATA_BLOB
blob
=
{
sizeof
(
signedWithCertAndCrlBareContent
),
(
LPBYTE
)
signedWithCertAndCrlBareContent
};
DWORD
count
,
size
;
BOOL
ret
;
/* Crashes
store = CertOpenStore(CERT_STORE_PROV_MSG, 0, 0, 0, NULL);
*/
SetLastError
(
0xdeadbeef
);
store
=
CertOpenStore
(
CERT_STORE_PROV_MSG
,
0
,
0
,
0
,
msg
);
todo_wine
ok
(
!
store
&&
GetLastError
()
==
CRYPT_E_INVALID_MSG_TYPE
,
"Expected CRYPT_E_INVALID_MSG_TYPE, got %08x
\n
"
,
GetLastError
());
CryptMsgUpdate
(
msg
,
signedContent
,
sizeof
(
signedContent
),
TRUE
);
store
=
CertOpenStore
(
CERT_STORE_PROV_MSG
,
0
,
0
,
0
,
msg
);
todo_wine
ok
(
store
!=
NULL
,
"CertOpenStore failed: %08x
\n
"
,
GetLastError
());
if
(
store
)
{
PCCERT_CONTEXT
cert
=
NULL
;
PCCRL_CONTEXT
crl
=
NULL
;
count
=
0
;
do
{
cert
=
CertEnumCertificatesInStore
(
store
,
cert
);
if
(
cert
)
count
++
;
}
while
(
cert
);
ok
(
count
==
0
,
"Expected 0 certificates, got %d
\n
"
,
count
);
count
=
0
;
do
{
crl
=
CertEnumCRLsInStore
(
store
,
crl
);
if
(
crl
)
count
++
;
}
while
(
crl
);
ok
(
count
==
0
,
"Expected 0 CRLs, got %d
\n
"
,
count
);
/* Can add certs to a message store */
ret
=
CertAddEncodedCertificateToStore
(
store
,
X509_ASN_ENCODING
,
bigCert
,
sizeof
(
bigCert
),
CERT_STORE_ADD_ALWAYS
,
NULL
);
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08x
\n
"
,
GetLastError
());
count
=
0
;
do
{
cert
=
CertEnumCertificatesInStore
(
store
,
cert
);
if
(
cert
)
count
++
;
}
while
(
cert
);
ok
(
count
==
1
,
"Expected 1 certificate, got %d
\n
"
,
count
);
CertCloseStore
(
store
,
0
);
}
/* but the added certs weren't actually added to the message */
size
=
sizeof
(
count
);
ret
=
CryptMsgGetParam
(
msg
,
CMSG_CERT_COUNT_PARAM
,
0
,
&
count
,
&
size
);
ok
(
ret
,
"CryptMsgGetParam failed: %08x
\n
"
,
GetLastError
());
ok
(
count
==
0
,
"Expected 0 certificates, got %d
\n
"
,
count
);
CryptMsgClose
(
msg
);
/* Crashes
store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, NULL);
*/
store
=
CertOpenStore
(
CERT_STORE_PROV_PKCS7
,
0
,
0
,
0
,
&
blob
);
todo_wine
ok
(
store
!=
NULL
,
"CertOpenStore failed: %08x
\n
"
,
GetLastError
());
if
(
store
)
{
DWORD
count
=
0
;
PCCERT_CONTEXT
cert
=
NULL
;
PCCRL_CONTEXT
crl
=
NULL
;
do
{
cert
=
CertEnumCertificatesInStore
(
store
,
cert
);
if
(
cert
)
count
++
;
}
while
(
cert
);
ok
(
count
==
1
,
"Expected 1 certificate, got %d
\n
"
,
count
);
count
=
0
;
do
{
crl
=
CertEnumCRLsInStore
(
store
,
crl
);
if
(
crl
)
count
++
;
}
while
(
crl
);
ok
(
count
==
1
,
"Expected 1 CRL, got %d
\n
"
,
count
);
CertCloseStore
(
store
,
0
);
}
/* Encoding appears to be ignored */
store
=
CertOpenStore
(
CERT_STORE_PROV_PKCS7
,
X509_ASN_ENCODING
,
0
,
0
,
&
blob
);
todo_wine
ok
(
store
!=
NULL
,
"CertOpenStore failed: %08x
\n
"
,
GetLastError
());
if
(
store
)
CertCloseStore
(
store
,
0
);
/* Messages other than signed messages aren't allowed */
blob
.
cbData
=
sizeof
(
hashContent
);
blob
.
pbData
=
(
LPBYTE
)
hashContent
;
SetLastError
(
0xdeadbeef
);
store
=
CertOpenStore
(
CERT_STORE_PROV_PKCS7
,
0
,
0
,
0
,
&
blob
);
todo_wine
ok
(
!
store
&&
GetLastError
()
==
CRYPT_E_INVALID_MSG_TYPE
,
"Expected CRYPT_E_INVALID_MSG_TYPE, got %08x
\n
"
,
GetLastError
());
blob
.
cbData
=
sizeof
(
hashBareContent
);
blob
.
pbData
=
(
LPBYTE
)
hashBareContent
;
SetLastError
(
0xdeadbeef
);
store
=
CertOpenStore
(
CERT_STORE_PROV_PKCS7
,
0
,
0
,
0
,
&
blob
);
todo_wine
ok
(
!
store
&&
GetLastError
()
==
CRYPT_E_ASN1_BADTAG
,
"Expected CRYPT_E_ASN1_BADTAG, got %08x
\n
"
,
GetLastError
());
}
static
void
testCertOpenSystemStore
(
void
)
{
HCERTSTORE
store
;
...
...
@@ -1637,6 +1804,7 @@ START_TEST(store)
testSystemStore
();
testFileStore
();
testFileNameStore
();
testMessageStore
();
testCertOpenSystemStore
();
testCertEnumSystemStore
();
...
...
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