📄 ssa-dse-10.c
字号:
DWORD bufSize = 0; { ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)8), 0x08000, ((void *)0), (BYTE *)&buf, &bufSize); { } } ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)8), "Expected CRYPT_E_ASN1_CORRUPT, got %08x\n", GetLastError());}static const BYTE v1Cert[] = { 0x30, 0x33, 0x02, 0x00, 0x30, 0x02, 0x06, 0x00, 0x02, 0x06, 0x00, 0x03, 0x01, 0x00 };static const BYTE v2Cert[] = { 0x30, 0x38, 0xa0, 0x03, 0x02, 0x01, 0x01, 0x02, 0x30, 0x5a, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01, 0x00 };static const BYTE v3Cert[] = { 0x30, 0x38, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x30, 0x5a, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01, 0x00 };static const BYTE v1CertWithConstraints[] = { 0x30, 0x4b, 0x02, 0x00, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };static const BYTE v1CertWithSerial[] = { 0x30, 0x4c, 0x02, 0x01, 0x01, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };static const BYTE bigCert[] = { 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 };static void test_encodeCertToBeSigned(DWORD dwEncoding){ BOOL ret; BYTE *buf = ((void *)0); DWORD size = 0; CERT_INFO info = { 0 }; ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)2), ((void *)0), 0x08000, ((void *)0), (BYTE *)&buf, &size); { } { } ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)2), &info, 0x08000, ((void *)0), (BYTE *)&buf, &size); { } { }}static void test_decodeCertToBeSigned(DWORD dwEncoding){ static const BYTE *corruptCerts[] = { v1Cert, v2Cert, v3Cert, v1CertWithConstraints, v1CertWithSerial }; BOOL ret; (winetest_set_location("encode.c", 2727), 0) ? 0 : winetest_ok(!ret && GetLastError() == ((HRESULT)0x80093102L), "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); { ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)2), "Expected CRYPT_E_ASN1_CORRUPT, got %08x\n", GetLastError()); } { }}static const BYTE hash[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf };static const BYTE signedBigCert[] = { 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };static void test_encodeCert(DWORD dwEncoding){ CERT_SIGNED_CONTENT_INFO info = { { sizeof(bigCert), (BYTE *)bigCert }, { ((void *)0), { 0, ((void *)0) } }, { sizeof(hash), (BYTE *)hash, 0 } }; BOOL ret; BYTE *buf = ((void *)0); DWORD bufSize = 0; ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)1), &info, 0x08000, ((void *)0), (BYTE *)&buf, &bufSize); { }}static void test_decodeCert(DWORD dwEncoding){ BOOL ret; BYTE *buf = ((void *)0); DWORD size = 0; { } ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)2), signedBigCert, sizeof(signedBigCert), 0x08000, ((void *)0), (BYTE *)&buf, &size); { CERT_INFO *info = (CERT_INFO *)buf; (winetest_set_location("encode.c", 2843), 0) ? 0 : winetest_ok(info->SerialNumber.cbData == 1, *info->SerialNumber.pbData); (winetest_set_location("encode.c", 2852), 0) ? 0 : winetest_ok(info->Subject.cbData == sizeof(encodedCommonName), "Wrong size %d\n", info->Subject.cbData); (winetest_set_location("encode.c", 2854), 0) ? 0 : winetest_ok(!memcmp(info->Subject.pbData, encodedCommonName, info->Subject.cbData), "Unexpected subject\n"); }}static const BYTE distPointWithUrl[] = { 0x30, 0x19, 0x30, 0x17, 0xa0, 0x15, 0x6e, 0x65, 0x68, 0x71, 0x2e, 0x6f, 0x72, 0x67 };static const BYTE distPointWithIssuer[] = { 0x30, 0x17, 0x30, 0x15, 0xa2, 0x13, 0x2e, 0x6f, 0x72, 0x67 };static const BYTE crlReason = 1 | 3;static void test_encodeCRLDistPoints(DWORD dwEncoding){ CRL_DIST_POINTS_INFO xxxinfo = { 0 }; CRL_DIST_POINT point = { { 0 } }; BOOL ret; BYTE *buf = ((void *)0); DWORD size = 0; ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)35), &xxxinfo, "Expected E_INVALIDARG, got %08x\n", GetLastError()); xxxinfo.cDistPoint = 1; xxxinfo.rgDistPoint = &point; ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)35), &xxxinfo, 0x08000, ((void *)0), (BYTE *)&buf, &size); point.ReasonFlags.cbData = sizeof(crlReason); { }}static void test_decodeCRLDistPoints(DWORD dwEncoding){ BOOL ret; BYTE *buf = ((void *)0); DWORD size = 0; PCERT_ALT_NAME_ENTRY entry; ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)35), (BYTE *)&buf, &size); { (winetest_set_location("encode.c", 3065), 0) ? 0 : winetest_ok(entry->dwAltNameChoice == 7, "Expected CERT_ALT_NAME_URL, got %d\n", entry->dwAltNameChoice); }}static const BYTE urlIDP[] = { 0x30,0x17,0xa0,0x15,0xa0,0x13,0x86,0x11,0x68, 0x67 };static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding){ BOOL ret; BYTE *buf = ((void *)0); DWORD size = 0; CRL_ISSUING_DIST_POINT point = { { 0 } }; ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)54), ((void *)0), "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); { } ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)54), &point, 0x08000, ((void *)0), (BYTE *)&buf, &size); { } { }}static void compareAltNameEntry(const CERT_ALT_NAME_ENTRY *expected, const CERT_ALT_NAME_ENTRY *got){ (winetest_set_location("encode.c", 3149), 0) ? 0 : winetest_ok(expected->dwAltNameChoice == got->dwAltNameChoice, got->dwAltNameChoice); { { (winetest_set_location("encode.c", 3161), 0) ? 0 : winetest_ok((!(*expected).pwszURL && !(*got).pwszURL) || !lstrcmpW((*expected).pwszURL, (*got).pwszURL), "Unexpected name\n"); } }}static void compareAltNameInfo(const CERT_ALT_NAME_INFO *expected, const CERT_ALT_NAME_INFO *got){}static const BYTE v1CRL[] = { 0x30, 0x15, 0x30, 0x02, 0x06, 0x00, 0x18, 0x0f, 0x30, 0x5a };static const BYTE v2CRL[] = { 0x30, 0x18, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06, 0x30, 0x30, 0x30, 0x30, 0x5a };static const BYTE v1CRLWithIssuer[] = { 0x30, 0x2c, 0x30, 0x02, 0x06, 0x00, 0x5a };static const BYTE v1CRLWithIssuerAndEmptyEntry[] = { 0x30, 0x43, 0x30, 0x02, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a };static const BYTE v1CRLWithIssuerAndEntry[] = { 0x30, 0x44, 0x30, 0x02, 0x06, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a };static const BYTE v1CRLWithEntryExt[] = { 0x30,0x5a,0x30,0x02,0x06,0x00,0x30, 0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };static const BYTE v1CRLWithExt[] = { 0x30,0x5c,0x30,0x02,0x06,0x00,0x30,0x15, 0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };static const BYTE v2CRLWithExt[] = { 0x30,0x5c,0x02,0x01,0x01,0x30,0x02,0x06, 0x13,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };static const BYTE v2CRLWithIssuingDistPoint[] = { 0x30,0x5c,0x02,0x01,0x01, 0x03,0x55,0x1d,0x13,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };static void test_encodeCRLToBeSigned(DWORD dwEncoding){ BOOL ret; BYTE *buf = ((void *)0); DWORD size = 0; CRL_INFO info = { 0 }; { (winetest_set_location("encode.c", 3386), 0) ? 0 : winetest_ok(size == sizeof(v1CRLWithIssuerAndEntry), "Wrong size %d\n", size); } { } ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)3), &info, 0x08000, ((void *)0), (BYTE *)&buf, &size); { } { }}static const BYTE verisignCRL[] = { 0x30, 0x82, 0x01, 0xb1, 0x30, 0x82, 0x01,0x61,0xc0,0x99,0x16,0x71,0x05,0xb6,0x25,0x14,0x64,0x4f,0x30 };static void test_decodeCRLToBeSigned(DWORD dwEncoding){ BOOL ret; BYTE *buf = ((void *)0); DWORD size = 0, i; { } ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)3), (BYTE *)&buf, &size); { CRL_INFO *info = (CRL_INFO *)buf; (winetest_set_location("encode.c", 4016), 0) ? 0 : winetest_ok(info->cCRLEntry == 0, "Expected 0 CRL entries, got %d\n", "Unexpected issuer\n"); } ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)3), 0x08000, ((void *)0), (BYTE *)&buf, &size); { CRL_INFO *info = (CRL_INFO *)buf; (winetest_set_location("encode.c", 4041), 0) ? 0 : winetest_ok(info->cCRLEntry == 1, "Expected 1 CRL entries, got %d\n", "Unexpected issuer\n"); } ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)3), 0x08000, ((void *)0), (BYTE *)&buf, &size); { CRL_INFO *info = (CRL_INFO *)buf; (winetest_set_location("encode.c", 4085), 0) ? 0 : winetest_ok(info->cCRLEntry == 209, "Expected 209 CRL entries, got %d\n", info->cExtension); } ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)3), ((void *)0), (BYTE *)&buf, &size); { }}static const BYTE authorityKeyIdWithIssuer[] = { 0x30,0x19,0xa1,0x17,0x30,0x15, 0x20,0x4c,0x61,0x6e,0x67,0x00 };static const BYTE authorityKeyIdWithSerial[] = { 0x30,0x03,0x82,0x01,0x01 };static void test_encodeAuthorityKeyId(DWORD dwEncoding){ CERT_AUTHORITY_KEY_ID_INFO info = { { 0 } }; BOOL ret; BYTE *buf = ((void *)0); DWORD size = 0; { } { } ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)9), &info, 0x08000, ((void *)0), (BYTE *)&buf, &size); { } ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)9), &info, 0x08000, ((void *)0), (BYTE *)&buf, &size); { (winetest_set_location("encode.c", 4284), 0) ? 0 : winetest_ok(size == sizeof(authorityKeyIdWithSerial), "Unexpected size %d\n", size); }}static void test_decodeAuthorityKeyId(DWORD dwEncoding){ BOOL ret; LPBYTE buf = ((void *)0); DWORD size = 0; ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)9), (BYTE *)&buf, &size); { } ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)9), 0x08000, ((void *)0), (BYTE *)&buf, &size); { (winetest_set_location("encode.c", 4355), 0) ? 0 : winetest_ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %d\n", "Unexpected serial number\n"); }}static void testExportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO *pInfo){ BOOL ret; DWORD size = 0; { ret = CryptExportPublicKeyInfoEx(csp, 2, 0x00000001, ((void *)0), 0, ((void *)0), ((void *)0), &size); { { (winetest_set_location("encode.c", 4416), 0) ? 0 : winetest_ok(!__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ((*pInfo)->Algorithm.pszObjId) && __builtin_constant_p ("1.2.840.113549.1.1.1") && (__s1_len = strlen ((*pInfo)->Algorithm.pszObjId), __s2_len = strlen ("1.2.840.113549.1.1.1"), (!((size_t)(const void *)(((*pInfo)->Algorithm.pszObjId) + 1) - (size_t)(const void *)((*pInfo)->Algorithm.pszObjId) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("1.2.840.113549.1.1.1") + 1) - (size_t)(const void *)("1.2.840.113549.1.1.1") == 1) || __s2_len >= 4)) ? __builtin_strcmp ((*pInfo)->Algorithm.pszObjId, "1.2.840.113549.1.1.1") : (__builtin_constant_p ((*pInfo)->Algorithm.pszObjId) && ((size_t)(const void *)(((*pInfo)->Algorithm.pszObjId) + 1) - (size_t)(const void *)((*pInfo)->Algorithm.pszObjId) == 1) && (__s1_len = strlen ((*pInfo)->Algorithm.pszObjId), __s1_len < 4) ? (__builtin_constant_p ("1.2.840.113549.1.1.1") && ((size_t)(const void *)(("1.2.840.113549.1.1.1") + 1) - (size_t)(const void *)("1.2.840.113549.1.1.1") == 1) ? __builtin_strcmp ((*pInfo)->Algorithm.pszObjId, "1.2.840.113549.1.1.1") : (__extension__ ({ __const unsigned char *__s2 = (__const unsigned char *) (__const char *) ("1.2.840.113549.1.1.1"); register int __result = (((__const unsigned char *) (__const char *) ((*pInfo)->Algorithm.pszObjId))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((__const unsigned char *) (__const char *) ((*pInfo)->Algorithm.pszObjId))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((__const unsigned char *) (__const char *) ((*pInfo)->Algorithm.pszObjId))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((__const unsigned char *) (__const char *) ((*pInfo)->Algorithm.pszObjId))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("1.2.840.113549.1.1.1") && ((size_t)(const void *)(("1.2.840.113549.1.1.1") + 1) - (size_t)(const void *)("1.2.840.113549.1.1.1") == 1) && (__s2_len = strlen ("1.2.840.113549.1.1.1"), __s2_len < 4) ? (__builtin_constant_p ((*pInfo)->Algorithm.pszObjId) && ((size_t)(const void *)(((*pInfo)->Algorithm.pszObjId) + 1) - (size_t)(const void *)((*pInfo)->Algorithm.pszObjId) == 1) ? __builtin_strcmp ((*pInfo)->Algorithm.pszObjId, "1.2.840.113549.1.1.1") : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned char *) (__const char *) ((*pInfo)->Algorithm.pszObjId); register int __result = __s1[0] - ((__const unsigned char *) (__const char *) ("1.2.840.113549.1.1.1"))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((__const unsigned char *) (__const char *) ("1.2.840.113549.1.1.1"))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((__const unsigned char *) (__const char *) ("1.2.840.113549.1.1.1"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((__const unsigned char *) (__const char *) ("1.2.840.113549.1.1.1"))[3]); } } __result; }))) : __builtin_strcmp ((*pInfo)->Algorithm.pszObjId, "1.2.840.113549.1.1.1")))); }), (*pInfo)->Algorithm.pszObjId); } } }}static const BYTE expiredCert[] = { 0x30, 0x82, 0x01, 0x33, 0x30, 0x81, 0xe2, 0x49, 0xe5, 0xf9, 0x65, 0xf3 };static void testImportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO info){ BOOL ret; HCRYPTKEY key; PCCERT_CONTEXT context; (winetest_set_location("encode.c", 4464), 0) ? 0 : winetest_ok(!ret && GetLastError() == 2, GetLastError()); { (winetest_set_location("encode.c", 4485), 0) ? 0 : winetest_ok(!__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ("1.2.840.113549.1.1.1") && __builtin_constant_p (context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId) && (__s1_len = strlen ("1.2.840.113549.1.1.1"), __s2_len = strlen (context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId), (!((size_t)(const void *)(("1.2.840.113549.1.1.1") + 1) - (size_t)(const void *)("1.2.840.113549.1.1.1") == 1) || __s1_len >= 4) && (!((size_t)(const void *)((context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId) + 1) - (size_t)(const void *)(context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId) == 1) || __s2_len >= 4)) ? __builtin_strcmp ("1.2.840.113549.1.1.1", context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId) : (__builtin_constant_p ("1.2.840.113549.1.1.1") && ((size_t)(const void *)(("1.2.840.113549.1.1.1") + 1) - (size_t)(const void *)("1.2.840.113549.1.1.1") == 1) && (__s1_len = strlen ("1.2.840.113549.1.1.1"), __s1_len < 4) ? (__builtin_constant_p (context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId) && ((size_t)(const void *)((context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId) + 1) - (size_t)(const void *)(context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId) == 1) ? __builtin_strcmp ("1.2.840.113549.1.1.1", context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId) : (__extension__ ({ __const unsigned char *__s2 = (__const unsigned char *) (__const char *) (context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId); register int __result = (((__const unsigned char *) (__const char *) ("1.2.840.113549.1.1.1"))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((__const unsigned char *) (__const char *) ("1.2.840.113549.1.1.1"))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((__const unsigned char *) (__const char *) ("1.2.840.113549.1.1.1"))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((__const unsigned char *) (__const char *) ("1.2.840.113549.1.1.1"))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId) && ((size_t)(const void *)((context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId) + 1) - (size_t)(const void *)(context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId) == 1) && (__s2_len = strlen (context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId), __s2_len < 4) ? (__builtin_constant_p ("1.2.840.113549.1.1.1"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -