crypt32: Add tests for CertIsRDNAttrsInCertificateName.
This commit is contained in:
parent
7d12294f08
commit
ed74536f0c
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue