📄 ssa-dse-10.c
字号:
};static void test_encodeInt(DWORD dwEncoding){ DWORD bufSize = 0; int i; BOOL ret; CRYPT_INTEGER_BLOB blob; BYTE *buf = ((void *)0); ret = CryptEncodeObjectEx(0, ((LPCSTR)27), &ints[0].val, 0, ((void *)0), ((void *)0), "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); { ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)27), &ints[i].val, 0x08000, ((void *)0), &buf, &bufSize); { (winetest_set_location("encode.c", 119), 0) ? 0 : winetest_ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n", buf[1], ints[i].encoded[1]); } ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)28), &blob, 0, ((void *)0), ((void *)0), &bufSize); { } ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)38), &blob, 0x08000, ((void *)0), &buf, &bufSize); { (winetest_set_location("encode.c", 187), 0) ? 0 : winetest_ok(buf[1] == bigUInts[i].encoded[1], "Got length %d, expected %d\n", buf[1], bigUInts[i].encoded[1]); (winetest_set_location("encode.c", 189), 0) ? 0 : winetest_ok(!memcmp(buf + 1, bigUInts[i].encoded + 1, bigUInts[i].encoded[1] + 1), "Encoded value didn't match expected\n"); } }}static void test_decodeInt(DWORD dwEncoding){ static const BYTE longForm[] = { 2, 0x81, 0x01, 0x01 }; BYTE *buf = ((void *)0); DWORD bufSize = 0; int i; BOOL ret; ret = CryptDecodeObjectEx(3, ((LPCSTR)27), (BYTE *)&ints[0].encoded, ints[0].encoded[1] + 2, 0, ((void *)0), ((void *)0), &bufSize); (winetest_set_location("encode.c", 225), 0) ? 0 : winetest_ok(!ret && GetLastError() == ((HRESULT)0x80093104L), "Expected CRYPT_E_ASN1_BADTAG, got %d\n", GetLastError()); { { (winetest_set_location("encode.c", 249), 0) ? 0 : winetest_ok(!memcmp(buf, &ints[i].val, bufSize), "Expected %d, got %d\n", ints[i].val, *(int *)buf); } } { ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)28), &bufSize); { CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf; (winetest_set_location("encode.c", 296), 0) ? 0 : winetest_ok(blob->cbData == strlen((const char*)bigUInts[i].val), "Unexpected value\n"); } } ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)28), longForm, sizeof(longForm), 0x08000, ((void *)0), (BYTE *)&buf, &bufSize); { }}static const struct encodedInt enums[] = {};static const LPCSTR enumeratedTypes[] = { ((LPCSTR)29), "2.5.29.21" };static void test_encodeEnumerated(DWORD dwEncoding){ DWORD i, j; { { BOOL ret; DWORD bufSize = 0; ret = CryptEncodeObjectEx(dwEncoding, enumeratedTypes[i], &bufSize); { } } }}static void test_decodeEnumerated(DWORD dwEncoding){ DWORD i, j; { { BOOL ret; DWORD bufSize = sizeof(int); int val; ret = CryptDecodeObjectEx(dwEncoding, enumeratedTypes[i], (BYTE *)&val, &bufSize); (winetest_set_location("encode.c", 403), 0) ? 0 : winetest_ok(val == enums[j].val, "Unexpected value %d, expected %d\n", val, enums[j].val); } }}struct encodedFiletime{ SYSTEMTIME sysTime; const BYTE *encodedTime;};static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType, const struct encodedFiletime *time){}static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType, const struct encodedFiletime *time){ BOOL ret; if (structType == ((LPCSTR)30) || (time->sysTime.wYear >= 1950 && time->sysTime.wYear <= 2050)) { } (winetest_set_location("encode.c", 476), 0) ? 0 : winetest_ok(!ret && GetLastError() == ((HRESULT)0x8009310BL), "Expected CRYPT_E_ASN1_BADTAG, got 0x%08x\n", GetLastError());}static const BYTE bin22[] = { 0x18,0x0f,'2','1','4','5','0','6','0','6','1','6','1','0','0','0','Z'};static const struct encodedFiletime times[] = {};static void test_encodeFiletime(DWORD dwEncoding){ { }}static const BYTE bin23[] = { 0x18,0x13,'1','9','4','5','0','6','0','6','1','6','1','0','0','0','.','0','0','0','Z'};static const BYTE bin24[] = { 0x18,0x13,'1','9','4','5','0','6','0','6','1','6','1','0','0','0','.','9','9','9','Z'};static const BYTE bin26[] = { 0x17,0x0b,'4','5','0','6','0','6','1','6','1','0','Z'};static const BYTE bin33[] = { 0x17,0x0f,'4','5','0','6','0','6','1','6','1','0','-','0','1','0','0'};static const BYTE bin35[] = { 0x17,0x08, '4','5','0','6','0','6','1','6'};static const BYTE bin38[] = { 0x18,0x08, '2','1','4','5','0','6','0','6'};static void test_decodeFiletime(DWORD dwEncoding){ static const struct encodedFiletime otherTimes[] = { }; static const unsigned char *bogusTimes[] = { }; { }}static const char commonName[] = "Juan Lang";static const char surName[] = "Lang";static const BYTE emptySequence[] = { 0x30, 0 };static const BYTE emptyRDNs[] = { 0x30, 0x02, 0x31, 0 };static const BYTE twoRDNs[] = { 0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0};static const BYTE encodedTwoRDNs[] = {};static const BYTE us[] = { 0x55, 0x53 };static const BYTE minnesota[] = { 0x4d, 0x69, 0x6e, 0x6e, 0x65, 0x73, 0x6f, 0x6f, 0x6c, 0x69, 0x73 };static const BYTE codeweavers[] = { 0x43, 0x6f, 0x64, 0x65, 0x57, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73 };static const BYTE wine[] = { 0x57, 0x69, 0x6e, 0x65, 0x20, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x6d, 0x65, 0x6e, 0x74 };static const BYTE aric[] = { 0x61, 0x72, 0x69, 0x63, 0x40, 0x63, 0x6f, 0x64, 0x65, 0x77, 0x65, 0x61, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x63, 0x6f, 0x6d };static CHAR oid_us[] = "2.5.4.6", oid_aric[] = "1.2.840.113549.1.9.1";static CERT_RDN_ATTR rdnAttrs[] = { { oid_us, 4, { sizeof(us), (LPBYTE)us } }, { oid_aric, 7, { sizeof(aric), (LPBYTE)aric } } };static const BYTE encodedRDNAttrs[] = {};static void test_encodeName(DWORD dwEncoding){ CERT_NAME_INFO info; static CHAR oid_common_name[] = "2.5.4.3", oid_sur_name[] = "2.5.4.4"; BOOL ret; ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)7), ((void *)0), "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); { } ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)7), &info, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); { } { } ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)7), &info, "Expected E_INVALIDARG, got %08x\n", GetLastError()); { }}static WCHAR commonNameW[] = { 'J','u','a','n',' ','L','a','n','g',0 };static const BYTE twoRDNsNoNull[] = { 0x20,0x4c,0x61,0x6e,0x67 };static const BYTE anyType[] = { 0x61,0x4c,0x67,0x6e };static void test_encodeUnicodeName(DWORD dwEncoding){ BOOL ret; ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)20), ((void *)0), "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); { }}static void compareNameValues(const CERT_NAME_VALUE *expected, const CERT_NAME_VALUE *got){ (winetest_set_location("encode.c", 913), 0) ? 0 : winetest_ok(got->dwValueType == expected->dwValueType, expected->dwValueType, got->Value.cbData, expected->Value.cbData); (winetest_set_location("encode.c", 920), 0) ? 0 : winetest_ok(!memcmp(got->Value.pbData, expected->Value.pbData, (((got->Value.cbData) < (expected->Value.cbData)) ? (got->Value.cbData) : (expected->Value.cbData))), "String type %d: unexpected value\n", expected->dwValueType);}static void compareRDNAttrs(const CERT_RDN_ATTR *expected, const CERT_RDN_ATTR *got){ { { (winetest_set_location("encode.c", 934), 0) ? 0 : winetest_ok(!__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (got->pszObjId) && __builtin_constant_p (expected->pszObjId) && (__s1_len = strlen (got->pszObjId), __s2_len = strlen (expected->pszObjId), (!((size_t)(const void *)((got->pszObjId) + 1) - (size_t)(const void *)(got->pszObjId) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((expected->pszObjId) + 1) - (size_t)(const void *)(expected->pszObjId) == 1) || __s2_len >= 4)) ? __builtin_strcmp (got->pszObjId, expected->pszObjId) : (__builtin_constant_p (got->pszObjId) && ((size_t)(const void *)((got->pszObjId) + 1) - (size_t)(const void *)(got->pszObjId) == 1) && (__s1_len = strlen (got->pszObjId), __s1_len < 4) ? (__builtin_constant_p (expected->pszObjId) && ((size_t)(const void *)((expected->pszObjId) + 1) - (size_t)(const void *)(expected->pszObjId) == 1) ? __builtin_strcmp (got->pszObjId, expected->pszObjId) : (__extension__ ({ __const unsigned char *__s2 = (__const unsigned char *) (__const char *) (expected->pszObjId); register int __result = (((__const unsigned char *) (__const char *) (got->pszObjId))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (got->pszObjId))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (got->pszObjId))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((__const unsigned char *) (__const char *) (got->pszObjId))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (expected->pszObjId) && ((size_t)(const void *)((expected->pszObjId) + 1) - (size_t)(const void *)(expected->pszObjId) == 1) && (__s2_len = strlen (expected->pszObjId), __s2_len < 4) ? (__builtin_constant_p (got->pszObjId) && ((size_t)(const void *)((got->pszObjId) + 1) - (size_t)(const void *)(got->pszObjId) == 1) ? __builtin_strcmp (got->pszObjId, expected->pszObjId) : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned char *) (__const char *) (got->pszObjId); register int __result = __s1[0] - ((__const unsigned char *) (__const char *) (expected->pszObjId))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((__const unsigned char *) (__const char *) (expected->pszObjId))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((__const unsigned char *) (__const char *) (expected->pszObjId))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((__const unsigned char *) (__const char *) (expected->pszObjId))[3]); } } __result; }))) : __builtin_strcmp (got->pszObjId, expected->pszObjId)))); }), expected->pszObjId); } }}static void compareRDNs(const CERT_RDN *expected, const CERT_RDN *got){ { }}static void compareNames(const CERT_NAME_INFO *expected, const CERT_NAME_INFO *got){ (winetest_set_location("encode.c", 959), 0) ? 0 : winetest_ok(got->cRDN == expected->cRDN, "Expected %d RDNs, got %d\n", expected->cRDN, got->cRDN); { }}static void test_decodeName(DWORD dwEncoding){ BYTE *buf = ((void *)0); DWORD bufSize = 0; BOOL ret; ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)7), emptySequence, (BYTE *)&buf, &bufSize); { static CHAR oid_sur_name[] = "2.5.4.4", oid_common_name[] = "2.5.4.3"; CERT_RDN_ATTR attrs[] = { { oid_sur_name, 4, { sizeof(surName), (BYTE *)commonName } }, }; } { }}static void test_decodeUnicodeName(DWORD dwEncoding){ BYTE *buf = ((void *)0); DWORD bufSize = 0; BOOL ret; ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)20), emptySequence, (BYTE *)&buf, &bufSize); { } ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)20), emptyRDNs, (BYTE *)&buf, &bufSize); { } ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)20), twoRDNsNoNull, (BYTE *)&buf, &bufSize); { static CHAR oid_sur_name[] = "2.5.4.4", oid_common_name[] = "2.5.4.3"; CERT_RDN_ATTR attrs[] = { { oid_sur_name, 4, { lstrlenW(commonNameW) * sizeof(WCHAR), (BYTE *)commonNameW } }, }; }}struct EncodedNameValue{ CERT_NAME_VALUE value;};static const char bogusPrintable[] = "~";static const BYTE bin42[] = { 0x16,0x02,0x80,0x00 };static const BYTE bin43[] = { 0x13,0x02,0x7e,0x00 };static BYTE octetCommonNameValue[] = { 0x12,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };static BYTE printableCommonNameValue[] = { 0x13,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };static BYTE t61CommonNameValue[] = { 0x14,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };static BYTE graphicCommonNameValue[] = { 0x61,0x00,0x6e,0x00,0x67,0x00,0x00 };static BYTE utf8CommonNameValue[] = { 0x0c,0x0a,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00 };static struct EncodedNameValue nameValues[] = { { { 5, { sizeof(commonName), (BYTE *)commonName } }, sizeof(bin42) }, { { 4, { sizeof(bogusPrintable), (BYTE *)bogusPrintable } }, bin43, sizeof(bin43) },};static void test_encodeNameValue(DWORD dwEncoding)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -