crypt32: Add more tests for CertCompareCertificateName.
This commit is contained in:
parent
459361d4d6
commit
4a948fa929
|
@ -2541,6 +2541,29 @@ static void testGetValidUsages(void)
|
|||
CertFreeCertificateContext(contexts[2]);
|
||||
}
|
||||
|
||||
static BYTE cn[] = {
|
||||
0x30,0x14,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,
|
||||
0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67 };
|
||||
static BYTE cnWithLeadingSpace[] = {
|
||||
0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x20,0x4a,
|
||||
0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67 };
|
||||
static BYTE cnWithTrailingSpace[] = {
|
||||
0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,
|
||||
0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x20 };
|
||||
static BYTE cnWithIntermediateSpace[] = {
|
||||
0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,0x4a,0x75,
|
||||
0x61,0x6e,0x20,0x20,0x4c,0x61,0x6e,0x67 };
|
||||
static BYTE cnThenO[] = {
|
||||
0x30,0x2d,0x31,0x2b,0x30,0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,
|
||||
0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x30,0x17,0x06,0x03,0x55,0x04,0x0a,0x13,
|
||||
0x10,0x54,0x68,0x65,0x20,0x57,0x69,0x6e,0x65,0x20,0x50,0x72,0x6f,0x6a,0x65,
|
||||
0x63,0x74 };
|
||||
static BYTE oThenCN[] = {
|
||||
0x30,0x2d,0x31,0x2b,0x30,0x10,0x06,0x03,0x55,0x04,0x0a,0x13,0x09,0x4a,0x75,
|
||||
0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x30,0x17,0x06,0x03,0x55,0x04,0x03,0x13,
|
||||
0x10,0x54,0x68,0x65,0x20,0x57,0x69,0x6e,0x65,0x20,0x50,0x72,0x6f,0x6a,0x65,
|
||||
0x63,0x74 };
|
||||
|
||||
static void testCompareCertName(void)
|
||||
{
|
||||
static BYTE bogus[] = { 1, 2, 3, 4 };
|
||||
|
@ -2572,6 +2595,43 @@ static void testCompareCertName(void)
|
|||
blob2.cbData = sizeof(emptyPrime);
|
||||
ret = CertCompareCertificateName(0, &blob1, &blob2);
|
||||
ok(!ret, "Expected failure\n");
|
||||
/* Tests to show that CertCompareCertificateName doesn't decode the name
|
||||
* to remove spaces, or to do an order-independent comparison.
|
||||
*/
|
||||
/* Compare CN="Juan Lang" with CN=" Juan Lang" */
|
||||
blob1.pbData = cn;
|
||||
blob1.cbData = sizeof(cn);
|
||||
blob2.pbData = cnWithLeadingSpace;
|
||||
blob2.cbData = sizeof(cnWithLeadingSpace);
|
||||
ret = CertCompareCertificateName(0, &blob1, &blob2);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ret = CertCompareCertificateName(X509_ASN_ENCODING, &blob1, &blob2);
|
||||
ok(!ret, "Expected failure\n");
|
||||
/* Compare CN="Juan Lang" with CN="Juan Lang " */
|
||||
blob2.pbData = cnWithTrailingSpace;
|
||||
blob2.cbData = sizeof(cnWithTrailingSpace);
|
||||
ret = CertCompareCertificateName(0, &blob1, &blob2);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ret = CertCompareCertificateName(X509_ASN_ENCODING, &blob1, &blob2);
|
||||
ok(!ret, "Expected failure\n");
|
||||
/* Compare CN="Juan Lang" with CN="Juan Lang" */
|
||||
blob2.pbData = cnWithIntermediateSpace;
|
||||
blob2.cbData = sizeof(cnWithIntermediateSpace);
|
||||
ret = CertCompareCertificateName(0, &blob1, &blob2);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ret = CertCompareCertificateName(X509_ASN_ENCODING, &blob1, &blob2);
|
||||
ok(!ret, "Expected failure\n");
|
||||
/* Compare 'CN="Juan Lang", O="The Wine Project"' with
|
||||
* 'O="The Wine Project", CN="Juan Lang"'
|
||||
*/
|
||||
blob1.pbData = cnThenO;
|
||||
blob1.cbData = sizeof(cnThenO);
|
||||
blob2.pbData = oThenCN;
|
||||
blob2.cbData = sizeof(oThenCN);
|
||||
ret = CertCompareCertificateName(0, &blob1, &blob2);
|
||||
ok(!ret, "Expected failure\n");
|
||||
ret = CertCompareCertificateName(X509_ASN_ENCODING, &blob1, &blob2);
|
||||
ok(!ret, "Expected failure\n");
|
||||
}
|
||||
|
||||
static BYTE int1[] = { 0x88, 0xff, 0xff, 0xff };
|
||||
|
|
Loading…
Reference in New Issue