crypt32: Test encoding a cert with a subject key identifier extension.

This commit is contained in:
Juan Lang 2007-08-02 12:23:14 -07:00 committed by Alexandre Julliard
parent 0c5772dc0a
commit c98f605b0e
1 changed files with 30 additions and 3 deletions

View File

@ -2736,6 +2736,16 @@ static const BYTE v1CertWithPubKeyNoNull[] = {
0x01,0x01,0x03,0x11,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0xa3,0x16,0x30,0x14,0x30,0x12,0x06,0x03,0x55,
0x1d,0x13,0x01,0x01,0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
static const BYTE v1CertWithSubjectKeyId[] = {
0x30,0x7b,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,0x17,0x30,0x15,0x30,
0x13,0x06,0x03,0x55,0x1d,0x0e,0x04,0x0c,0x04,0x0a,0x4a,0x75,0x61,0x6e,0x20,
0x4c,0x61,0x6e,0x67,0x00 };
static const BYTE serialNum[] = { 0x01 };
@ -2746,6 +2756,8 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
DWORD size = 0;
CERT_INFO info = { 0 };
static char oid_rsa_rsa[] = szOID_RSA_RSA;
static char oid_subject_key_identifier[] = szOID_SUBJECT_KEY_IDENTIFIER;
CERT_EXTENSION ext;
/* Test with NULL pvStructInfo */
ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL,
@ -2841,9 +2853,24 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
"Got unexpected value\n");
LocalFree(buf);
}
/* for now, I let more interesting tests be done for each subcomponent,
* rather than retesting them all here.
*/
/* Remove the public key, and add a subject key identifier extension */
info.SubjectPublicKeyInfo.Algorithm.pszObjId = NULL;
info.SubjectPublicKeyInfo.PublicKey.cbData = 0;
info.SubjectPublicKeyInfo.PublicKey.pbData = NULL;
ext.pszObjId = oid_subject_key_identifier;
ext.fCritical = FALSE;
ext.Value.cbData = sizeof(octetCommonNameValue);
ext.Value.pbData = (BYTE *)octetCommonNameValue;
info.cExtension = 1;
info.rgExtension = &ext;
ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info,
CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size);
if (buf)
{
ok(size == sizeof(v1CertWithSubjectKeyId), "Wrong size %d\n", size);
ok(!memcmp(buf, v1CertWithSubjectKeyId, size), "Unexpected value\n");
LocalFree(buf);
}
}
static void test_decodeCertToBeSigned(DWORD dwEncoding)