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
1252426d
Commit
1252426d
authored
Feb 15, 2023
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Oct 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32/tests: Add some tests for quoted RDN values.
Signed-off-by:
Dmitry Timoshkov
<
dmitry@baikal.ru
>
parent
c2962b22
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
148 additions
and
0 deletions
+148
-0
str.c
dlls/crypt32/tests/str.c
+148
-0
No files found.
dlls/crypt32/tests/str.c
View file @
1252426d
...
...
@@ -23,6 +23,7 @@
#include <winbase.h>
#include <winerror.h>
#include <wincrypt.h>
#include <winnls.h>
#include "wine/test.h"
...
...
@@ -1079,8 +1080,155 @@ static void test_CertGetNameString(void)
CertFreeCertificateContext
(
context
);
}
static
void
test_quoted_RDN
(
void
)
{
static
const
WCHAR
str1
[]
=
{
'1'
,
0x00a0
,
0
};
static
const
WCHAR
str2
[]
=
{
'1'
,
0x3000
,
0
};
static
const
struct
{
const
WCHAR
*
CN
;
const
WCHAR
*
X500_CN
;
}
test
[]
=
{
{
L"1"
,
L"1"
},
{
L" 1"
,
L"
\"
1
\"
"
},
{
L"1 "
,
L"
\"
1
\"
"
},
{
L"
\"
1
\"
"
,
L"
\"\"\"
1
\"\"\"
"
},
{
L"
\"
1
\"
"
,
L"
\"\"\"
1
\"\"\"
"
},
{
L"
\"\"\"
1
\"\"\"
"
,
L"
\"\"\"\"\"\"\"
1
\"\"\"\"\"\"\"
"
},
{
L"1+"
,
L"
\"
1+
\"
"
},
{
L"1="
,
L"
\"
1=
\"
"
},
{
L"1
\"
"
,
L"
\"
1
\"\"\"
"
},
{
L"1<"
,
L"
\"
1<
\"
"
},
{
L"1>"
,
L"
\"
1>
\"
"
},
{
L"1#"
,
L"
\"
1#
\"
"
},
{
L"1+"
,
L"
\"
1+
\"
"
},
{
L"1
\t
"
,
L"
\"
1
\t\"
"
},
{
L"1
\r
"
,
L"
\"
1
\r\"
"
},
{
L"1
\n
"
,
L"
\"
1
\n\"
"
},
{
str1
,
str1
},
{
str2
,
str2
},
};
CERT_RDN_ATTR
attr
;
CERT_RDN
rdn
;
CERT_NAME_INFO
info
;
CERT_NAME_BLOB
blob
;
BYTE
*
buf
;
WCHAR
str
[
256
];
DWORD
size
,
ret
,
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
test
);
i
++
)
{
winetest_push_context
(
"%lu"
,
i
);
attr
.
pszObjId
=
(
LPSTR
)
szOID_COMMON_NAME
;
attr
.
dwValueType
=
CERT_RDN_UNICODE_STRING
;
attr
.
Value
.
cbData
=
wcslen
(
test
[
i
].
CN
)
*
sizeof
(
WCHAR
);
attr
.
Value
.
pbData
=
(
BYTE
*
)
test
[
i
].
CN
;
rdn
.
cRDNAttr
=
1
;
rdn
.
rgRDNAttr
=
&
attr
;
info
.
cRDN
=
1
;
info
.
rgRDN
=
&
rdn
;
buf
=
NULL
;
size
=
0
;
ret
=
CryptEncodeObjectEx
(
X509_ASN_ENCODING
,
X509_UNICODE_NAME
,
&
info
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
&
buf
,
&
size
);
ok
(
ret
,
"CryptEncodeObjectEx error %08lx
\n
"
,
GetLastError
());
blob
.
pbData
=
buf
;
blob
.
cbData
=
size
;
str
[
0
]
=
0
;
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
0
,
str
,
ARRAY_SIZE
(
str
));
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
!
wcscmp
(
str
,
test
[
i
].
X500_CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
str
),
debugstr_w
(
test
[
i
].
X500_CN
));
str
[
0
]
=
0
;
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
CERT_SIMPLE_NAME_STR
,
str
,
ARRAY_SIZE
(
str
));
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
!
wcscmp
(
str
,
test
[
i
].
X500_CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
str
),
debugstr_w
(
test
[
i
].
X500_CN
));
str
[
0
]
=
0
;
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
CERT_OID_NAME_STR
,
str
,
ARRAY_SIZE
(
str
));
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
!
wcsncmp
(
str
,
L"2.5.4.3="
,
8
),
"got %s
\n
"
,
debugstr_w
(
str
));
ok
(
!
wcscmp
(
&
str
[
8
],
test
[
i
].
X500_CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
&
str
[
8
]),
debugstr_w
(
test
[
i
].
X500_CN
));
str
[
0
]
=
0
;
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
CERT_X500_NAME_STR
,
str
,
ARRAY_SIZE
(
str
));
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
!
wcsncmp
(
str
,
L"CN="
,
3
),
"got %s
\n
"
,
debugstr_w
(
str
));
ok
(
!
wcscmp
(
&
str
[
3
],
test
[
i
].
X500_CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
&
str
[
3
]),
debugstr_w
(
test
[
i
].
X500_CN
));
str
[
0
]
=
0
;
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
CERT_X500_NAME_STR
|
CERT_NAME_STR_NO_QUOTING_FLAG
,
str
,
ARRAY_SIZE
(
str
));
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
!
wcsncmp
(
str
,
L"CN="
,
3
),
"got %s
\n
"
,
debugstr_w
(
str
));
todo_wine_if
(
i
!=
0
&&
i
!=
13
&&
i
!=
14
)
ok
(
!
wcscmp
(
&
str
[
3
],
test
[
i
].
CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
&
str
[
3
]),
debugstr_w
(
test
[
i
].
CN
));
LocalFree
(
buf
);
winetest_pop_context
();
}
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
test
);
i
++
)
{
winetest_push_context
(
"%lu"
,
i
);
attr
.
pszObjId
=
(
LPSTR
)
szOID_COMMON_NAME
;
attr
.
dwValueType
=
CERT_RDN_UTF8_STRING
;
attr
.
Value
.
cbData
=
wcslen
(
test
[
i
].
CN
)
*
sizeof
(
WCHAR
);
attr
.
Value
.
pbData
=
(
BYTE
*
)
test
[
i
].
CN
;
rdn
.
cRDNAttr
=
1
;
rdn
.
rgRDNAttr
=
&
attr
;
info
.
cRDN
=
1
;
info
.
rgRDN
=
&
rdn
;
buf
=
NULL
;
size
=
0
;
ret
=
CryptEncodeObjectEx
(
X509_ASN_ENCODING
,
X509_UNICODE_NAME
,
&
info
,
CRYPT_ENCODE_ALLOC_FLAG
,
NULL
,
&
buf
,
&
size
);
ok
(
ret
,
"CryptEncodeObjectEx error %08lx
\n
"
,
GetLastError
());
blob
.
pbData
=
buf
;
blob
.
cbData
=
size
;
str
[
0
]
=
0
;
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
0
,
str
,
ARRAY_SIZE
(
str
));
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
!
wcscmp
(
str
,
test
[
i
].
X500_CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
str
),
debugstr_w
(
test
[
i
].
X500_CN
));
str
[
0
]
=
0
;
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
CERT_SIMPLE_NAME_STR
,
str
,
ARRAY_SIZE
(
str
));
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
!
wcscmp
(
str
,
test
[
i
].
X500_CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
str
),
debugstr_w
(
test
[
i
].
X500_CN
));
str
[
0
]
=
0
;
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
CERT_OID_NAME_STR
,
str
,
ARRAY_SIZE
(
str
));
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
!
wcsncmp
(
str
,
L"2.5.4.3="
,
8
),
"got %s
\n
"
,
debugstr_w
(
str
));
ok
(
!
wcscmp
(
&
str
[
8
],
test
[
i
].
X500_CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
&
str
[
8
]),
debugstr_w
(
test
[
i
].
X500_CN
));
str
[
0
]
=
0
;
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
CERT_X500_NAME_STR
,
str
,
ARRAY_SIZE
(
str
));
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
!
wcsncmp
(
str
,
L"CN="
,
3
),
"got %s
\n
"
,
debugstr_w
(
str
));
ok
(
!
wcscmp
(
&
str
[
3
],
test
[
i
].
X500_CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
&
str
[
3
]),
debugstr_w
(
test
[
i
].
X500_CN
));
str
[
0
]
=
0
;
ret
=
CertNameToStrW
(
X509_ASN_ENCODING
,
&
blob
,
CERT_X500_NAME_STR
|
CERT_NAME_STR_NO_QUOTING_FLAG
,
str
,
ARRAY_SIZE
(
str
));
ok
(
ret
,
"CertNameToStr error %08lx
\n
"
,
GetLastError
());
ok
(
!
wcsncmp
(
str
,
L"CN="
,
3
),
"got %s
\n
"
,
debugstr_w
(
str
));
todo_wine_if
(
i
!=
0
&&
i
!=
13
&&
i
!=
14
)
ok
(
!
wcscmp
(
&
str
[
3
],
test
[
i
].
CN
),
"got %s, expected %s
\n
"
,
debugstr_w
(
&
str
[
3
]),
debugstr_w
(
test
[
i
].
CN
));
LocalFree
(
buf
);
winetest_pop_context
();
}
}
START_TEST
(
str
)
{
test_quoted_RDN
();
test_CertRDNValueToStrA
();
test_CertRDNValueToStrW
();
test_CertNameToStrA
();
...
...
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