⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ssa-dse-10.c

📁 用于进行gcc测试
💻 C
📖 第 1 页 / 共 5 页
字号:
{    DWORD size = 0, i;    BOOL ret;    CERT_NAME_VALUE value = { 0, { 0, ((void *)0) } };    ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)6), &value,     "Expected CRYPT_E_ASN1_CHOICE, got %08x\n", GetLastError());    {        (winetest_set_location("encode.c", 1209), 0) ? 0 : winetest_ok(size == sizeof(printableCommonNameValue), "Unexpected size %d\n",         "Unexpected encoding\n");        ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)6),         nameValues[i].value.dwValueType, GetLastError());        {        }    }}static void test_decodeNameValue(DWORD dwEncoding){    int i;    BYTE *buf = ((void *)0);    DWORD bufSize = 0;    BOOL ret;    {        ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)6),         (BYTE *)&buf, &bufSize);        {            compareNameValues(&nameValues[i].value,             (const CERT_NAME_VALUE *)buf);        }    }}static const BYTE emptyURL[] = { 0x30, 0x02, 0x86, 0x00 };static const WCHAR url[] = { 'h','t','t','p',':','/','/','w','i','n','e', 0x6f, 0x72, 0x67 };static const BYTE encodedIPAddr[] = { 0x30, 0x06, 0x87, 0x04, 0x7f, 0x00, 0x00, 0x01 };static void test_encodeAltName(DWORD dwEncoding){    CERT_ALT_NAME_INFO info = { 0 };    BYTE *buf = ((void *)0);    DWORD size = 0;    BOOL ret;    ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)12), &info,     0x08000, ((void *)0), (BYTE *)&buf, &size);    {    }    {    }}static void test_decodeAltName(DWORD dwEncoding){    BOOL ret;    DWORD bufSize = 0;    CERT_ALT_NAME_INFO *info;    ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)12),     &bufSize);    {        (winetest_set_location("encode.c", 1392), 0) ? 0 : winetest_ok(info->cAltEntry == 0, "Expected 0 entries, got %d\n",         info->cAltEntry);    }    ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)12), emptyURL,     &bufSize);    {    }}struct encodedBits{    const BYTE *encoded;    DWORD cbDecoded;};static const struct encodedBits bits[] = {};static void test_encodeBits(DWORD dwEncoding){    DWORD i;    {        DWORD bufSize = 0;        {            (winetest_set_location("encode.c", 1802), 0) ? 0 : winetest_ok(bufSize == bits[i].encoded[1] + 2,             bits[i].encoded[1] + 2);        }    }}static void test_decodeBits(DWORD dwEncoding){    DWORD i;    {        {            CRYPT_BIT_BLOB *blob;            (winetest_set_location("encode.c", 1835), 0) ? 0 : winetest_ok(blob->cbData == bits[i].cbDecoded,                 "Unexpected value\n");        }    }    {    }}struct Constraints2{    CERT_BASIC_CONSTRAINTS2_INFO info;};static const struct Constraints2 constraints2[] = {};static const BYTE encodedDomainName[] = { 0x30, 0x2b, 0x31, 0x29, 0x30, 0x11, 0x16, 0x06, 0x77, 0x69, 0x6e, 0x65, 0x68, 0x71 };static void test_encodeBasicConstraints(DWORD dwEncoding){    CERT_NAME_BLOB nameBlob = { sizeof(encodedDomainName),     (LPBYTE)encodedDomainName };    {        {        }    }    {    }}static const unsigned char encodedCommonName[] = {    0x30,0x15,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x03,0x13,0x0a,'J','u','a','n',' ','L','a','n','g',0};static void test_decodeBasicConstraints(DWORD dwEncoding){    static const BYTE inverted[] = { 0x30, 0x06, 0x02, 0x01, 0x01, 0x01, 0x01,     0xff };    DWORD i;    BOOL ret;    BYTE *buf = ((void *)0);    DWORD bufSize = 0;    {        ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)15),         0x08000, ((void *)0), (BYTE *)&buf, &bufSize);        {            CERT_BASIC_CONSTRAINTS2_INFO *info =            (winetest_set_location("encode.c", 1984), 0) ? 0 : winetest_ok(!memcmp(info, &constraints2[i].info, sizeof(*info)),             "Unexpected value for item %d\n", i);        }    }    ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)15),     (BYTE *)&buf, &bufSize);    {        CERT_BASIC_CONSTRAINTS_INFO *info = (CERT_BASIC_CONSTRAINTS_INFO *)buf;        {            (winetest_set_location("encode.c", 2043), 0) ? 0 : winetest_ok(info->rgSubtreesConstraint[0].cbData ==             info->rgSubtreesConstraint[0].cbData);            (winetest_set_location("encode.c", 2046), 0) ? 0 : winetest_ok(!memcmp(info->rgSubtreesConstraint[0].pbData, encodedDomainName,             sizeof(encodedDomainName)), "Unexpected value\n");        }    }}static const BYTE modulus1[] = { 0,0,0,1,1,1,1,1 };struct EncodedRSAPubKey{    const BYTE *modulus;    size_t decodedModulusLen;};struct EncodedRSAPubKey rsaPubKeys[] = {};static void test_encodeRsaPublicKey(DWORD dwEncoding){    BYTE toEncode[sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) + sizeof(modulus1)];    RSAPUBKEY *rsaPubKey = (RSAPUBKEY *)(toEncode + sizeof(BLOBHEADER));    BOOL ret;    BYTE *buf = ((void *)0);    DWORD bufSize = 0, i;    ret = CryptDecodeObjectEx(dwEncoding, "1.2.840.113549.1.1.1",     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());    {        {            (winetest_set_location("encode.c", 2210), 0) ? 0 : winetest_ok(bufSize >= sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) +             "Wrong size %d\n", bufSize);            (winetest_set_location("encode.c", 2223), 0) ? 0 : winetest_ok(rsaPubKey->magic == 0x31415352,             rsaPubKey->pubexp);            (winetest_set_location("encode.c", 2229), 0) ? 0 : winetest_ok(!memcmp(buf + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY),             rsaPubKeys[i].modulus, rsaPubKeys[i].decodedModulusLen),             "Unexpected modulus\n");        }    }}static const BYTE intSequence[] = { 0x30, 0x1b, 0x02, 0x01, 0x01, 0x02, 0x01, 0x02, 0xff, 0x7f, 0x02, 0x04, 0xba, 0xdd, 0xf0, 0x0d };static const BYTE mixedSequence[] = { 0x30, 0x27, 0x17, 0x0d, 0x30, 0x35, 0x30, 0xff, 0x7f, 0x02, 0x04, 0xba, 0xdd, 0xf0, 0x0d };static void test_encodeSequenceOfAny(DWORD dwEncoding){    BYTE *buf = ((void *)0);    {    }    {        (winetest_set_location("encode.c", 2284), 0) ? 0 : winetest_ok(!memcmp(buf, mixedSequence, mixedSequence[1] + 2),         "Unexpected value\n");    }}static void test_decodeSequenceOfAny(DWORD dwEncoding){    BOOL ret;    BYTE *buf = ((void *)0);    DWORD bufSize = 0;    {        {        }    }    ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)34), mixedSequence,     &bufSize);    {        CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)buf;        (winetest_set_location("encode.c", 2324), 0) ? 0 : winetest_ok(seq->cValue == sizeof(ints) / sizeof(ints[0]),         seq->rgValue[0].cbData);        (winetest_set_location("encode.c", 2330), 0) ? 0 : winetest_ok(!memcmp(seq->rgValue[0].pbData, times[0].encodedTime,         times[0].encodedTime[1] + 2), "Unexpected value\n");    }}struct encodedExtensions{    CERT_EXTENSIONS exts;};static BYTE noncrit_ext_data[] = { 0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };static CHAR oid_basic_constraints2[] = "2.5.29.19";static CERT_EXTENSION nonCriticalExt = { oid_basic_constraints2, 0, { 8, noncrit_ext_data } };static const struct encodedExtensions exts[] = {};static void test_encodeExtensions(DWORD dwEncoding){    DWORD i;    {        {        }    }    {        BOOL ret;        BYTE *buf = ((void *)0);        DWORD bufSize = 0;        ret = CryptDecodeObjectEx(dwEncoding, ((LPCSTR)5),         ((void *)0), (BYTE *)&buf, &bufSize);        {            CERT_EXTENSIONS *ext = (CERT_EXTENSIONS *)buf;            DWORD j;            (winetest_set_location("encode.c", 2405), 0) ? 0 : winetest_ok(ext->cExtension == exts[i].exts.cExtension,             ext->cExtension);            {                (winetest_set_location("encode.c", 2410), 0) ? 0 : winetest_ok(!__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (ext->rgExtension[j].pszObjId) && __builtin_constant_p (exts[i].exts.rgExtension[j].pszObjId) && (__s1_len = strlen (ext->rgExtension[j].pszObjId), __s2_len = strlen (exts[i].exts.rgExtension[j].pszObjId), (!((size_t)(const void *)((ext->rgExtension[j].pszObjId) + 1) - (size_t)(const void *)(ext->rgExtension[j].pszObjId) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((exts[i].exts.rgExtension[j].pszObjId) + 1) - (size_t)(const void *)(exts[i].exts.rgExtension[j].pszObjId) == 1) || __s2_len >= 4)) ? __builtin_strcmp (ext->rgExtension[j].pszObjId, exts[i].exts.rgExtension[j].pszObjId) : (__builtin_constant_p (ext->rgExtension[j].pszObjId) && ((size_t)(const void *)((ext->rgExtension[j].pszObjId) + 1) - (size_t)(const void *)(ext->rgExtension[j].pszObjId) == 1) && (__s1_len = strlen (ext->rgExtension[j].pszObjId), __s1_len < 4) ? (__builtin_constant_p (exts[i].exts.rgExtension[j].pszObjId) && ((size_t)(const void *)((exts[i].exts.rgExtension[j].pszObjId) + 1) - (size_t)(const void *)(exts[i].exts.rgExtension[j].pszObjId) == 1) ? __builtin_strcmp (ext->rgExtension[j].pszObjId, exts[i].exts.rgExtension[j].pszObjId) : (__extension__ ({ __const unsigned char *__s2 = (__const unsigned char *) (__const char *) (exts[i].exts.rgExtension[j].pszObjId); register int __result = (((__const unsigned char *) (__const char *) (ext->rgExtension[j].pszObjId))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (ext->rgExtension[j].pszObjId))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (ext->rgExtension[j].pszObjId))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((__const unsigned char *) (__const char *) (ext->rgExtension[j].pszObjId))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (exts[i].exts.rgExtension[j].pszObjId) && ((size_t)(const void *)((exts[i].exts.rgExtension[j].pszObjId) + 1) - (size_t)(const void *)(exts[i].exts.rgExtension[j].pszObjId) == 1) && (__s2_len = strlen (exts[i].exts.rgExtension[j].pszObjId), __s2_len < 4) ? (__builtin_constant_p (ext->rgExtension[j].pszObjId) && ((size_t)(const void *)((ext->rgExtension[j].pszObjId) + 1) - (size_t)(const void *)(ext->rgExtension[j].pszObjId) == 1) ? __builtin_strcmp (ext->rgExtension[j].pszObjId, exts[i].exts.rgExtension[j].pszObjId) : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned char *) (__const char *) (ext->rgExtension[j].pszObjId); register int __result = __s1[0] - ((__const unsigned char *) (__const char *) (exts[i].exts.rgExtension[j].pszObjId))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((__const unsigned char *) (__const char *) (exts[i].exts.rgExtension[j].pszObjId))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((__const unsigned char *) (__const char *) (exts[i].exts.rgExtension[j].pszObjId))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((__const unsigned char *) (__const char *) (exts[i].exts.rgExtension[j].pszObjId))[3]); } } __result; }))) : __builtin_strcmp (ext->rgExtension[j].pszObjId, exts[i].exts.rgExtension[j].pszObjId)))); }),                 ext->rgExtension[j].pszObjId);                (winetest_set_location("encode.c", 2415), 0) ? 0 : winetest_ok(!memcmp(ext->rgExtension[j].Value.pbData,                 exts[i].exts.rgExtension[j].Value.cbData),                 "Unexpected value\n");            }        }    }}struct encodedPublicKey{    const BYTE *encoded;    const BYTE *encodedNoNull;};static const BYTE aKey[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf };static const BYTE params[] = { 0x02, 0x01, 0x01 };static const unsigned char bin66[] = {    0x30,0x0f,0x30,0x0a,0x06,0x06,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x05,0x00,0x03,0x01,0x00};static const unsigned char bin67[] = {    0x30,0x0d,0x30,0x08,0x06,0x06,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x03,0x01,0x00};static const unsigned char bin69[] = {    0x0f};static unsigned char bin72[] = { 0x05,0x00};static CHAR oid_bogus[] = "1.2.3",            oid_rsa[] = "1.2.840.113549";static const struct encodedPublicKey pubKeys[] = { { { { oid_rsa, { 0, ((void *)0) } }, { 0, ((void *)0), 0} },  { { oid_rsa, { 2, bin72 } }, { sizeof(aKey), (BYTE *)aKey, 0} } }, { { { oid_rsa, { sizeof(params), (BYTE *)params } }, { sizeof(aKey),  (BYTE *)aKey, 0 } } },};static void test_encodePublicKeyInfo(DWORD dwEncoding){    DWORD i;    {        BOOL ret;        BYTE *buf = ((void *)0);        DWORD bufSize = 0;        ret = CryptEncodeObjectEx(dwEncoding, ((LPCSTR)8),         &bufSize);        {            (winetest_set_location("encode.c", 2505), 0) ? 0 : winetest_ok(bufSize == pubKeys[i].encoded[1] + 2 ||             pubKeys[i].encodedNoNull[1] + 2, bufSize);                (winetest_set_location("encode.c", 2510), 0) ? 0 : winetest_ok(!memcmp(buf, pubKeys[i].encoded, pubKeys[i].encoded[1] + 2),                 "Unexpected value\n");                (winetest_set_location("encode.c", 2513), 0) ? 0 : winetest_ok(!memcmp(buf, pubKeys[i].encodedNoNull,                 pubKeys[i].encodedNoNull[1] + 2), "Unexpected value\n");        }    }}static void comparePublicKeyInfo(const CERT_PUBLIC_KEY_INFO *expected, const CERT_PUBLIC_KEY_INFO *got){    (winetest_set_location("encode.c", 2523), 0) ? 0 : winetest_ok(!__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (expected->Algorithm.pszObjId) && __builtin_constant_p (got->Algorithm.pszObjId) && (__s1_len = strlen (expected->Algorithm.pszObjId), __s2_len = strlen (got->Algorithm.pszObjId), (!((size_t)(const void *)((expected->Algorithm.pszObjId) + 1) - (size_t)(const void *)(expected->Algorithm.pszObjId) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((got->Algorithm.pszObjId) + 1) - (size_t)(const void *)(got->Algorithm.pszObjId) == 1) || __s2_len >= 4)) ? __builtin_strcmp (expected->Algorithm.pszObjId, got->Algorithm.pszObjId) : (__builtin_constant_p (expected->Algorithm.pszObjId) && ((size_t)(const void *)((expected->Algorithm.pszObjId) + 1) - (size_t)(const void *)(expected->Algorithm.pszObjId) == 1) && (__s1_len = strlen (expected->Algorithm.pszObjId), __s1_len < 4) ? (__builtin_constant_p (got->Algorithm.pszObjId) && ((size_t)(const void *)((got->Algorithm.pszObjId) + 1) - (size_t)(const void *)(got->Algorithm.pszObjId) == 1) ? __builtin_strcmp (expected->Algorithm.pszObjId, got->Algorithm.pszObjId) : (__extension__ ({ __const unsigned char *__s2 = (__const unsigned char *) (__const char *) (got->Algorithm.pszObjId); register int __result = (((__const unsigned char *) (__const char *) (expected->Algorithm.pszObjId))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (expected->Algorithm.pszObjId))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (expected->Algorithm.pszObjId))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((__const unsigned char *) (__const char *) (expected->Algorithm.pszObjId))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (got->Algorithm.pszObjId) && ((size_t)(const void *)((got->Algorithm.pszObjId) + 1) - (size_t)(const void *)(got->Algorithm.pszObjId) == 1) && (__s2_len = strlen (got->Algorithm.pszObjId), __s2_len < 4) ? (__builtin_constant_p (expected->Algorithm.pszObjId) && ((size_t)(const void *)((expected->Algorithm.pszObjId) + 1) - (size_t)(const void *)(expected->Algorithm.pszObjId) == 1) ? __builtin_strcmp (expected->Algorithm.pszObjId, got->Algorithm.pszObjId) : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned char *) (__const char *) (expected->Algorithm.pszObjId); register int __result = __s1[0] - ((__const unsigned char *) (__const char *) (got->Algorithm.pszObjId))[0]; if (__s2_len > 0 && __result == 0) { __result = (__s1[1] - ((__const unsigned char *) (__const char *) (got->Algorithm.pszObjId))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((__const unsigned char *) (__const char *) (got->Algorithm.pszObjId))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((__const unsigned char *) (__const char *) (got->Algorithm.pszObjId))[3]); } } __result; }))) : __builtin_strcmp (expected->Algorithm.pszObjId, got->Algorithm.pszObjId)))); }),     expected->PublicKey.cbData, got->PublicKey.cbData);        (winetest_set_location("encode.c", 2538), 0) ? 0 : winetest_ok(!memcmp(expected->PublicKey.pbData, got->PublicKey.pbData,         got->PublicKey.cbData), "Unexpected public key value\n");}static void test_decodePublicKeyInfo(DWORD dwEncoding){    static const BYTE bogusPubKeyInfo[] = { 0x30, 0x22, 0x30, 0x0d, 0x06, 0x06,     0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };    BOOL ret;    BYTE *buf = ((void *)0);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -