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
ed74536f
Commit
ed74536f
authored
Nov 16, 2009
by
Juan Lang
Committed by
Alexandre Julliard
Nov 17, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Add tests for CertIsRDNAttrsInCertificateName.
parent
7d12294f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
138 additions
and
0 deletions
+138
-0
cert.c
dlls/crypt32/tests/cert.c
+138
-0
No files found.
dlls/crypt32/tests/cert.c
View file @
ed74536f
...
...
@@ -2634,6 +2634,143 @@ static void testCompareCertName(void)
ok
(
!
ret
,
"Expected failure
\n
"
);
}
static
void
testIsRDNAttrsInCertificateName
(
void
)
{
static
char
oid_1_2_3
[]
=
"1.2.3"
;
static
char
oid_common_name
[]
=
szOID_COMMON_NAME
;
static
char
oid_organization
[]
=
szOID_ORGANIZATION_NAME
;
static
char
juan
[]
=
"Juan Lang"
;
static
char
juan_with_leading_space
[]
=
" Juan Lang"
;
static
char
juan_with_intermediate_space
[]
=
"Juan Lang"
;
static
char
juan_with_trailing_space
[]
=
"Juan Lang "
;
static
char
juan_lower_case
[]
=
"juan lang"
;
static
WCHAR
juanW
[]
=
{
'J'
,
'u'
,
'a'
,
'n'
,
' '
,
'L'
,
'a'
,
'n'
,
'g'
,
0
};
static
char
the_wine_project
[]
=
"The Wine Project"
;
BOOL
ret
;
CERT_NAME_BLOB
name
;
CERT_RDN_ATTR
attr
[
2
];
CERT_RDN
rdn
=
{
0
,
NULL
};
name
.
cbData
=
sizeof
(
cn
);
name
.
pbData
=
cn
;
if
(
0
)
{
/* Crash */
ret
=
CertIsRDNAttrsInCertificateName
(
0
,
0
,
NULL
,
NULL
);
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
0
,
&
name
,
NULL
);
}
SetLastError
(
0xdeadbeef
);
ret
=
CertIsRDNAttrsInCertificateName
(
0
,
0
,
&
name
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"expected ERROR_FILE_NOT_FOUND, got %08x
\n
"
,
GetLastError
());
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
0
,
&
name
,
&
rdn
);
todo_wine
ok
(
ret
,
"CertIsRDNAttrsInCertificateName failed: %08x
\n
"
,
GetLastError
());
attr
[
0
].
pszObjId
=
oid_1_2_3
;
rdn
.
rgRDNAttr
=
attr
;
rdn
.
cRDNAttr
=
1
;
SetLastError
(
0xdeadbeef
);
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
0
,
&
name
,
&
rdn
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NO_MATCH
,
"expected CRYPT_E_NO_MATCH, got %08x
\n
"
,
GetLastError
());
attr
[
0
].
pszObjId
=
oid_common_name
;
attr
[
0
].
dwValueType
=
CERT_RDN_PRINTABLE_STRING
;
attr
[
0
].
Value
.
cbData
=
strlen
(
juan
);
attr
[
0
].
Value
.
pbData
=
(
BYTE
*
)
juan
;
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
0
,
&
name
,
&
rdn
);
todo_wine
ok
(
ret
,
"CertIsRDNAttrsInCertificateName failed: %08x
\n
"
,
GetLastError
());
/* Again, spaces are not removed for name comparison. */
attr
[
0
].
Value
.
cbData
=
strlen
(
juan_with_leading_space
);
attr
[
0
].
Value
.
pbData
=
(
BYTE
*
)
juan_with_leading_space
;
SetLastError
(
0xdeadbeef
);
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
0
,
&
name
,
&
rdn
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NO_MATCH
,
"expected CRYPT_E_NO_MATCH, got %08x
\n
"
,
GetLastError
());
attr
[
0
].
Value
.
cbData
=
strlen
(
juan_with_intermediate_space
);
attr
[
0
].
Value
.
pbData
=
(
BYTE
*
)
juan_with_intermediate_space
;
SetLastError
(
0xdeadbeef
);
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
0
,
&
name
,
&
rdn
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NO_MATCH
,
"expected CRYPT_E_NO_MATCH, got %08x
\n
"
,
GetLastError
());
attr
[
0
].
Value
.
cbData
=
strlen
(
juan_with_trailing_space
);
attr
[
0
].
Value
.
pbData
=
(
BYTE
*
)
juan_with_trailing_space
;
SetLastError
(
0xdeadbeef
);
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
0
,
&
name
,
&
rdn
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NO_MATCH
,
"expected CRYPT_E_NO_MATCH, got %08x
\n
"
,
GetLastError
());
/* The lower case name isn't matched unless a case insensitive match is
* specified.
*/
attr
[
0
].
Value
.
cbData
=
strlen
(
juan_lower_case
);
attr
[
0
].
Value
.
pbData
=
(
BYTE
*
)
juan_lower_case
;
SetLastError
(
0xdeadbeef
);
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
0
,
&
name
,
&
rdn
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NO_MATCH
,
"expected CRYPT_E_NO_MATCH, got %08x
\n
"
,
GetLastError
());
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG
,
&
name
,
&
rdn
);
todo_wine
ok
(
ret
,
"CertIsRDNAttrsInCertificateName failed: %08x
\n
"
,
GetLastError
());
/* The values don't match unless they have the same RDN type */
attr
[
0
].
dwValueType
=
CERT_RDN_UNICODE_STRING
;
attr
[
0
].
Value
.
cbData
=
lstrlenW
(
juanW
)
*
sizeof
(
WCHAR
);
attr
[
0
].
Value
.
pbData
=
(
BYTE
*
)
juanW
;
SetLastError
(
0xdeadbeef
);
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
0
,
&
name
,
&
rdn
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NO_MATCH
,
"expected CRYPT_E_NO_MATCH, got %08x
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
CERT_UNICODE_IS_RDN_ATTRS_FLAG
,
&
name
,
&
rdn
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NO_MATCH
,
"expected CRYPT_E_NO_MATCH, got %08x
\n
"
,
GetLastError
());
attr
[
0
].
dwValueType
=
CERT_RDN_IA5_STRING
;
attr
[
0
].
Value
.
cbData
=
strlen
(
juan
);
attr
[
0
].
Value
.
pbData
=
(
BYTE
*
)
juan
;
SetLastError
(
0xdeadbeef
);
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
0
,
&
name
,
&
rdn
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NO_MATCH
,
"expected CRYPT_E_NO_MATCH, got %08x
\n
"
,
GetLastError
());
/* All attributes must be present */
attr
[
0
].
dwValueType
=
CERT_RDN_PRINTABLE_STRING
;
attr
[
0
].
Value
.
cbData
=
strlen
(
juan
);
attr
[
0
].
Value
.
pbData
=
(
BYTE
*
)
juan
;
attr
[
1
].
pszObjId
=
oid_organization
;
attr
[
1
].
dwValueType
=
CERT_RDN_PRINTABLE_STRING
;
attr
[
1
].
Value
.
cbData
=
strlen
(
the_wine_project
);
attr
[
1
].
Value
.
pbData
=
(
BYTE
*
)
the_wine_project
;
rdn
.
cRDNAttr
=
2
;
SetLastError
(
0xdeadbeef
);
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
0
,
&
name
,
&
rdn
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NO_MATCH
,
"expected CRYPT_E_NO_MATCH, got %08x
\n
"
,
GetLastError
());
/* Order also matters */
name
.
pbData
=
cnThenO
;
name
.
cbData
=
sizeof
(
cnThenO
);
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
0
,
&
name
,
&
rdn
);
todo_wine
ok
(
ret
,
"CertIsRDNAttrsInCertificateName failed: %08x
\n
"
,
GetLastError
());
name
.
pbData
=
oThenCN
;
name
.
cbData
=
sizeof
(
oThenCN
);
SetLastError
(
0xdeadbeef
);
ret
=
CertIsRDNAttrsInCertificateName
(
X509_ASN_ENCODING
,
0
,
&
name
,
&
rdn
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NO_MATCH
,
"expected CRYPT_E_NO_MATCH, got %08x
\n
"
,
GetLastError
());
}
static
BYTE
int1
[]
=
{
0x88
,
0xff
,
0xff
,
0xff
};
static
BYTE
int2
[]
=
{
0x88
,
0xff
};
static
BYTE
int3
[]
=
{
0x23
,
0xff
};
...
...
@@ -3343,4 +3480,5 @@ START_TEST(cert)
testVerifyRevocation
();
testAcquireCertPrivateKey
();
testGetPublicKeyLength
();
testIsRDNAttrsInCertificateName
();
}
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