crypto/ec/ectest.c:963: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `EC_POINT_mul`.
Showing all 13 steps of the trace


crypto/ec/ectest.c:963:2: Call
961.   
962.   	/* Curve K-163 (FIPS PUB 186-2, App. 6) */
963.   	CHAR2_CURVE_TEST
        ^
964.   		(
965.   		"NIST curve K-163",

crypto/ec/ec_lib.c:1139:9: Call
  1137.   	scalars[0] = p_scalar;
  1138.   
  1139.   	return EC_POINTs_mul(group, r, g_scalar, (point != NULL && p_scalar != NULL), points, scalars, ctx);
                  ^
  1140.   	}
  1141.   

crypto/ec/ec_lib.c:1118:1: Parameter `scalar->top`
    1116.    */
    1117.   
    1118. > int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
    1119.   	size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx)
    1120.   	{

crypto/ec/ectest.c:963:2: Call
961.   
962.   	/* Curve K-163 (FIPS PUB 186-2, App. 6) */
963.   	CHAR2_CURVE_TEST
        ^
964.   		(
965.   		"NIST curve K-163",

crypto/ec/ec_lib.c:1128:1: Parameter `g_scalar->top`
  1126.   	}
  1127.   
  1128. > int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar,
  1129.   	const EC_POINT *point, const BIGNUM *p_scalar, BN_CTX *ctx)
  1130.   	{

crypto/ec/ec_lib.c:1139:9: Call
  1137.   	scalars[0] = p_scalar;
  1138.   
  1139.   	return EC_POINTs_mul(group, r, g_scalar, (point != NULL && p_scalar != NULL), points, scalars, ctx);
                  ^
  1140.   	}
  1141.   

crypto/ec/ec_lib.c:1118:1: Parameter `scalar->top`
    1116.    */
    1117.   
    1118. > int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
    1119.   	size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx)
    1120.   	{

crypto/ec/ec_lib.c:1123:10: Call
    1121.   	if (group->meth->mul == 0)
    1122.   		/* use default */
    1123.   		return ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx);
                     ^
    1124.   
    1125.   	return group->meth->mul(group, r, scalar, num, points, scalars, ctx);

crypto/ec/ec_mult.c:344:1: Parameter `scalar->top`
      342.    * in the addition if scalar != NULL
      343.    */
      344. > int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
      345.   	size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx)
      346.   	{

crypto/ec/ec_mult.c:416:17: Call
      414.   			/* determine maximum number of blocks that wNAF splitting may yield
      415.   			 * (NB: maximum wNAF length is bit length plus one) */
      416.   			numblocks = (BN_num_bits(scalar) / blocksize) + 1;
                             ^
      417.   
      418.   			/* we cannot use more blocks than we have precomputation for */

crypto/bn/bn_lib.c:248:1: <LHS trace>
246.   	}
247.   
248. > int BN_num_bits(const BIGNUM *a)
249.   	{
250.   	int i = a->top - 1;

crypto/bn/bn_lib.c:248:1: Parameter `a->top`
        246.   	}
        247.   
        248. > int BN_num_bits(const BIGNUM *a)
        249.   	{
        250.   	int i = a->top - 1;

crypto/bn/bn_lib.c:250:2: Binary operation: ([0, +oo] - 1):unsigned64 by call to `EC_POINT_mul` 
        248.   int BN_num_bits(const BIGNUM *a)
        249.   	{
        250.   	int i = a->top - 1;
                ^
        251.   	bn_check_top(a);
        252.   

int BN_num_bits(const BIGNUM *a)
	{
	int i = a->top - 1;
	bn_check_top(a);
	if (BN_is_zero(a)) return 0;
	return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
	}
['void char2_field_tests()\n\t{\n\tBN_CTX *ctx = NULL;\n\tBIGNUM *p, *a, *b;\n\tEC_GROUP *group;\n\tEC_GROUP *C2_K163 = NULL, *C2_K233 = NULL, *C2_K283 = NULL, *C2_K409 = NULL, *C2_K571 = NULL;\n\tEC_GROUP *C2_B163 = NULL, *C2_B233 = NULL, *C2_B283 = NULL, *C2_B409 = NULL, *C2_B571 = NULL;\n\tEC_POINT *P, *Q, *R;\n\tBIGNUM *x, *y, *z, *cof;\n\tunsigned char buf[100];\n\tsize_t i, len;\n\tint k;\n#if 1\n\tctx = BN_CTX_new();\n\tif (!ctx) ABORT;\n#endif\n\tp = BN_new();\n\ta = BN_new();\n\tb = BN_new();\n\tif (!p || !a || !b) ABORT;\n\tif (!BN_hex2bn(&p, "13")) ABORT;\n\tif (!BN_hex2bn(&a, "3")) ABORT;\n\tif (!BN_hex2bn(&b, "1")) ABORT;\n\tgroup = EC_GROUP_new(EC_GF2m_simple_method());\n\tif (!group) ABORT;\n\tif (!EC_GROUP_set_curve_GF2m(group, p, a, b, ctx)) ABORT;\n\t{\n\t\tEC_GROUP *tmp;\n\t\ttmp = EC_GROUP_new(EC_GROUP_method_of(group));\n\t\tif (!tmp) ABORT;\n\t\tif (!EC_GROUP_copy(tmp, group)) ABORT;\n\t\tEC_GROUP_free(group);\n\t\tgroup = tmp;\n\t}\n\tif (!EC_GROUP_get_curve_GF2m(group, p, a, b, ctx)) ABORT;\n\tfprintf(stdout, "Curve defined by Weierstrass equation\\n     y^2 + x*y = x^3 + a*x^2 + b  (mod 0x");\n\tBN_print_fp(stdout, p);\n\tfprintf(stdout, ")\\n     a = 0x");\n\tBN_print_fp(stdout, a);\n\tfprintf(stdout, "\\n     b = 0x");\n\tBN_print_fp(stdout, b);\n\tfprintf(stdout, "\\n(0x... means binary polynomial)\\n");\n\tP = EC_POINT_new(group);\n\tQ = EC_POINT_new(group);\n\tR = EC_POINT_new(group);\n\tif (!P || !Q || !R) ABORT;\n\tif (!EC_POINT_set_to_infinity(group, P)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, P)) ABORT;\n\tbuf[0] = 0;\n\tif (!EC_POINT_oct2point(group, Q, buf, 1, ctx)) ABORT;\n\tif (!EC_POINT_add(group, P, P, Q, ctx)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, P)) ABORT;\n\tx = BN_new();\n\ty = BN_new();\n\tz = BN_new();\n\tcof = BN_new();\n\tif (!x || !y || !z || !cof) ABORT;\n\tif (!BN_hex2bn(&x, "6")) ABORT;\n#ifdef OPENSSL_EC_BIN_PT_COMP\n\tif (!EC_POINT_set_compressed_coordinates_GF2m(group, Q, x, 1, ctx)) ABORT;\n#else\n\tif (!BN_hex2bn(&y, "8")) ABORT;\n\tif (!EC_POINT_set_affine_coordinates_GF2m(group, Q, x, y, ctx)) ABORT;\n#endif\n\tif (!EC_POINT_is_on_curve(group, Q, ctx))\n\t\t{\n#ifdef OPENSSL_EC_BIN_PT_COMP\n\t\tif (!EC_POINT_get_affine_coordinates_GF2m(group, Q, x, y, ctx)) ABORT;\n#endif\n\t\tfprintf(stderr, "Point is not on curve: x = 0x");\n\t\tBN_print_fp(stderr, x);\n\t\tfprintf(stderr, ", y = 0x");\n\t\tBN_print_fp(stderr, y);\n\t\tfprintf(stderr, "\\n");\n\t\tABORT;\n\t\t}\n\tfprintf(stdout, "A cyclic subgroup:\\n");\n\tk = 100;\n\tdo\n\t\t{\n\t\tif (k-- == 0) ABORT;\n\t\tif (EC_POINT_is_at_infinity(group, P))\n\t\t\tfprintf(stdout, "     point at infinity\\n");\n\t\telse\n\t\t\t{\n\t\t\tif (!EC_POINT_get_affine_coordinates_GF2m(group, P, x, y, ctx)) ABORT;\n\t\t\tfprintf(stdout, "     x = 0x");\n\t\t\tBN_print_fp(stdout, x);\n\t\t\tfprintf(stdout, ", y = 0x");\n\t\t\tBN_print_fp(stdout, y);\n\t\t\tfprintf(stdout, "\\n");\n\t\t\t}\n\t\tif (!EC_POINT_copy(R, P)) ABORT;\n\t\tif (!EC_POINT_add(group, P, P, Q, ctx)) ABORT;\n\t\t}\n\twhile (!EC_POINT_is_at_infinity(group, P));\n\tif (!EC_POINT_add(group, P, Q, R, ctx)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, P)) ABORT;\n#ifdef OPENSSL_EC_BIN_PT_COMP\n\tlen = EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED, buf, sizeof buf, ctx);\n\tif (len == 0) ABORT;\n\tif (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT;\n\tif (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT;\n\tfprintf(stdout, "Generator as octet string, compressed form:\\n     ");\n\tfor (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]);\n#endif\n\tlen = EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED, buf, sizeof buf, ctx);\n\tif (len == 0) ABORT;\n\tif (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT;\n\tif (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT;\n\tfprintf(stdout, "\\nGenerator as octet string, uncompressed form:\\n     ");\n\tfor (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]);\n#ifdef OPENSSL_EC_BIN_PT_COMP\n\tlen = EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof buf, ctx);\n\tif (len == 0) ABORT;\n\tif (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT;\n\tif (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT;\n\tfprintf(stdout, "\\nGenerator as octet string, hybrid form:\\n     ");\n\tfor (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]);\n#endif\n\tfprintf(stdout, "\\n");\n\tif (!EC_POINT_invert(group, P, ctx)) ABORT;\n\tif (0 != EC_POINT_cmp(group, P, R, ctx)) ABORT;\n\tCHAR2_CURVE_TEST\n\t\t(\n\t\t"NIST curve K-163",\n\t\t"0800000000000000000000000000000000000000C9",\n\t\t"1",\n\t\t"1",\n\t\t"02FE13C0537BBC11ACAA07D793DE4E6D5E5C94EEE8",\n\t\t"0289070FB05D38FF58321F2E800536D538CCDAA3D9",\n\t\t1,\n\t\t"04000000000000000000020108A2E0CC0D99F8A5EF",\n\t\t"2",\n\t\t163,\n\t\tC2_K163\n\t\t);\n\tCHAR2_CURVE_TEST\n\t\t(\n\t\t"NIST curve B-163",\n\t\t"0800000000000000000000000000000000000000C9",\n\t\t"1",\n\t\t"020A601907B8C953CA1481EB10512F78744A3205FD",\n\t\t"03F0EBA16286A2D57EA0991168D4994637E8343E36",\n\t\t"00D51FBC6C71A0094FA2CDD545B11C5C0C797324F1",\n\t\t1,\n\t\t"040000000000000000000292FE77E70C12A4234C33",\n\t\t"2",\n\t\t163,\n\t\tC2_B163\n\t\t);\n\tCHAR2_CURVE_TEST\n\t\t(\n\t\t"NIST curve K-233",\n\t\t"020000000000000000000000000000000000000004000000000000000001",\n\t\t"0",\n\t\t"1",\n\t\t"017232BA853A7E731AF129F22FF4149563A419C26BF50A4C9D6EEFAD6126",\n\t\t"01DB537DECE819B7F70F555A67C427A8CD9BF18AEB9B56E0C11056FAE6A3",\n\t\t0,\n\t\t"008000000000000000000000000000069D5BB915BCD46EFB1AD5F173ABDF",\n\t\t"4",\n\t\t233,\n\t\tC2_K233\n\t\t);\n\tCHAR2_CURVE_TEST\n\t\t(\n\t\t"NIST curve B-233",\n\t\t"020000000000000000000000000000000000000004000000000000000001",\n\t\t"000000000000000000000000000000000000000000000000000000000001",\n\t\t"0066647EDE6C332C7F8C0923BB58213B333B20E9CE4281FE115F7D8F90AD",\n\t\t"00FAC9DFCBAC8313BB2139F1BB755FEF65BC391F8B36F8F8EB7371FD558B",\n\t\t"01006A08A41903350678E58528BEBF8A0BEFF867A7CA36716F7E01F81052",\n\t\t1,\n\t\t"01000000000000000000000000000013E974E72F8A6922031D2603CFE0D7",\n\t\t"2",\n\t\t233,\n\t\tC2_B233\n\t\t);\n\tCHAR2_CURVE_TEST\n\t\t(\n\t\t"NIST curve K-283",\n\t\t"0800000000000000000000000000000000000000000000000000000000000000000010A1",\n\t\t"0",\n\t\t"1",\n\t\t"0503213F78CA44883F1A3B8162F188E553CD265F23C1567A16876913B0C2AC2458492836",\n\t\t"01CCDA380F1C9E318D90F95D07E5426FE87E45C0E8184698E45962364E34116177DD2259",\n\t\t0,\n\t\t"01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE9AE2ED07577265DFF7F94451E061E163C61",\n\t\t"4",\n\t\t283,\n\t\tC2_K283\n\t\t);\n\tCHAR2_CURVE_TEST\n\t\t(\n\t\t"NIST curve B-283",\n\t\t"0800000000000000000000000000000000000000000000000000000000000000000010A1",\n\t\t"000000000000000000000000000000000000000000000000000000000000000000000001",\n\t\t"027B680AC8B8596DA5A4AF8A19A0303FCA97FD7645309FA2A581485AF6263E313B79A2F5",\n\t\t"05F939258DB7DD90E1934F8C70B0DFEC2EED25B8557EAC9C80E2E198F8CDBECD86B12053",\n\t\t"03676854FE24141CB98FE6D4B20D02B4516FF702350EDDB0826779C813F0DF45BE8112F4",\n\t\t1,\n\t\t"03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF90399660FC938A90165B042A7CEFADB307",\n\t\t"2",\n\t\t283,\n\t\tC2_B283\n\t\t);\n\tCHAR2_CURVE_TEST\n\t\t(\n\t\t"NIST curve K-409",\n\t\t"02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001",\n\t\t"0",\n\t\t"1",\n\t\t"0060F05F658F49C1AD3AB1890F7184210EFD0987E307C84C27ACCFB8F9F67CC2C460189EB5AAAA62EE222EB1B35540CFE9023746",\n\t\t"01E369050B7C4E42ACBA1DACBF04299C3460782F918EA427E6325165E9EA10E3DA5F6C42E9C55215AA9CA27A5863EC48D8E0286B",\n\t\t1,\n\t\t"007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE5F83B2D4EA20400EC4557D5ED3E3E7CA5B4B5C83B8E01E5FCF",\n\t\t"4",\n\t\t409,\n\t\tC2_K409\n\t\t);\n\tCHAR2_CURVE_TEST\n\t\t(\n\t\t"NIST curve B-409",\n\t\t"02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001",\n\t\t"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",\n\t\t"0021A5C2C8EE9FEB5C4B9A753B7B476B7FD6422EF1F3DD674761FA99D6AC27C8A9A197B272822F6CD57A55AA4F50AE317B13545F",\n\t\t"015D4860D088DDB3496B0C6064756260441CDE4AF1771D4DB01FFE5B34E59703DC255A868A1180515603AEAB60794E54BB7996A7",\n\t\t"0061B1CFAB6BE5F32BBFA78324ED106A7636B9C5A7BD198D0158AA4F5488D08F38514F1FDF4B4F40D2181B3681C364BA0273C706",\n\t\t1,\n\t\t"010000000000000000000000000000000000000000000000000001E2AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173",\n\t\t"2",\n\t\t409,\n\t\tC2_B409\n\t\t);\n\tCHAR2_CURVE_TEST\n\t\t(\n\t\t"NIST curve K-571",\n\t\t"80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425",\n\t\t"0",\n\t\t"1",\n\t\t"026EB7A859923FBC82189631F8103FE4AC9CA2970012D5D46024804801841CA44370958493B205E647DA304DB4CEB08CBBD1BA39494776FB988B47174DCA88C7E2945283A01C8972",\n\t\t"0349DC807F4FBF374F4AEADE3BCA95314DD58CEC9F307A54FFC61EFC006D8A2C9D4979C0AC44AEA74FBEBBB9F772AEDCB620B01A7BA7AF1B320430C8591984F601CD4C143EF1C7A3",\n\t\t0,\n\t\t"020000000000000000000000000000000000000000000000000000000000000000000000131850E1F19A63E4B391A8DB917F4138B630D84BE5D639381E91DEB45CFE778F637C1001",\n\t\t"4",\n\t\t571,\n\t\tC2_K571\n\t\t);\n\tCHAR2_CURVE_TEST\n\t\t(\n\t\t"NIST curve B-571",\n\t\t"80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425",\n\t\t"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",\n\t\t"02F40E7E2221F295DE297117B7F3D62F5C6A97FFCB8CEFF1CD6BA8CE4A9A18AD84FFABBD8EFA59332BE7AD6756A66E294AFD185A78FF12AA520E4DE739BACA0C7FFEFF7F2955727A",\n\t\t"0303001D34B856296C16C0D40D3CD7750A93D1D2955FA80AA5F40FC8DB7B2ABDBDE53950F4C0D293CDD711A35B67FB1499AE60038614F1394ABFA3B4C850D927E1E7769C8EEC2D19",\n\t\t"037BF27342DA639B6DCCFFFEB73D69D78C6C27A6009CBBCA1980F8533921E8A684423E43BAB08A576291AF8F461BB2A8B3531D2F0485C19B16E2F1516E23DD3C1A4827AF1B8AC15B",\n\t\t1,\n\t\t"03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE661CE18FF55987308059B186823851EC7DD9CA1161DE93D5174D66E8382E9BB2FE84E47",\n\t\t"2",\n\t\t571,\n\t\tC2_B571\n\t\t);\n\tif (!EC_POINT_copy(Q, P)) ABORT;\n\tif (EC_POINT_is_at_infinity(group, Q)) ABORT;\n\tif (!EC_POINT_dbl(group, P, P, ctx)) ABORT;\n\tif (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;\n\tif (!EC_POINT_invert(group, Q, ctx)) ABORT;\n\tif (!EC_POINT_add(group, R, P, Q, ctx)) ABORT;\n\tif (!EC_POINT_add(group, R, R, Q, ctx)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, R)) ABORT;\n\t{\n\t\tconst EC_POINT *points[3];\n\t\tconst BIGNUM *scalars[3];\n\t\tif (EC_POINT_is_at_infinity(group, Q)) ABORT;\n\t\tpoints[0] = Q;\n\t\tpoints[1] = Q;\n\t\tpoints[2] = Q;\n\t\tif (!BN_add(y, z, BN_value_one())) ABORT;\n\t\tif (BN_is_odd(y)) ABORT;\n\t\tif (!BN_rshift1(y, y)) ABORT;\n\t\tscalars[0] = y;\n\t\tscalars[1] = y;\n\t\tfprintf(stdout, "combined multiplication ...");\n\t\tfflush(stdout);\n\t\tif (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx)) ABORT;\n\t\tif (!EC_POINTs_mul(group, R, z, 2, points, scalars, ctx)) ABORT;\n\t\tif (0 != EC_POINT_cmp(group, P, R, ctx)) ABORT;\n\t\tif (0 != EC_POINT_cmp(group, R, Q, ctx)) ABORT;\n\t\tfprintf(stdout, ".");\n\t\tfflush(stdout);\n\t\tif (!BN_pseudo_rand(y, BN_num_bits(y), 0, 0)) ABORT;\n\t\tif (!BN_add(z, z, y)) ABORT;\n\t\tBN_set_negative(z, 1);\n\t\tscalars[0] = y;\n\t\tscalars[1] = z;\n\t\tif (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx)) ABORT;\n\t\tif (!EC_POINT_is_at_infinity(group, P)) ABORT;\n\t\tfprintf(stdout, ".");\n\t\tfflush(stdout);\n\t\tif (!BN_pseudo_rand(x, BN_num_bits(y) - 1, 0, 0)) ABORT;\n\t\tif (!BN_add(z, x, y)) ABORT;\n\t\tBN_set_negative(z, 1);\n\t\tscalars[0] = x;\n\t\tscalars[1] = y;\n\t\tscalars[2] = z;\n\t\tif (!EC_POINTs_mul(group, P, NULL, 3, points, scalars, ctx)) ABORT;\n\t\tif (!EC_POINT_is_at_infinity(group, P)) ABORT;\n\t\tfprintf(stdout, " ok\\n\\n");\n\t}\n#if 0\n\ttimings(C2_K163, TIMING_BASE_PT, ctx);\n\ttimings(C2_K163, TIMING_RAND_PT, ctx);\n\ttimings(C2_K163, TIMING_SIMUL, ctx);\n\ttimings(C2_B163, TIMING_BASE_PT, ctx);\n\ttimings(C2_B163, TIMING_RAND_PT, ctx);\n\ttimings(C2_B163, TIMING_SIMUL, ctx);\n\ttimings(C2_K233, TIMING_BASE_PT, ctx);\n\ttimings(C2_K233, TIMING_RAND_PT, ctx);\n\ttimings(C2_K233, TIMING_SIMUL, ctx);\n\ttimings(C2_B233, TIMING_BASE_PT, ctx);\n\ttimings(C2_B233, TIMING_RAND_PT, ctx);\n\ttimings(C2_B233, TIMING_SIMUL, ctx);\n\ttimings(C2_K283, TIMING_BASE_PT, ctx);\n\ttimings(C2_K283, TIMING_RAND_PT, ctx);\n\ttimings(C2_K283, TIMING_SIMUL, ctx);\n\ttimings(C2_B283, TIMING_BASE_PT, ctx);\n\ttimings(C2_B283, TIMING_RAND_PT, ctx);\n\ttimings(C2_B283, TIMING_SIMUL, ctx);\n\ttimings(C2_K409, TIMING_BASE_PT, ctx);\n\ttimings(C2_K409, TIMING_RAND_PT, ctx);\n\ttimings(C2_K409, TIMING_SIMUL, ctx);\n\ttimings(C2_B409, TIMING_BASE_PT, ctx);\n\ttimings(C2_B409, TIMING_RAND_PT, ctx);\n\ttimings(C2_B409, TIMING_SIMUL, ctx);\n\ttimings(C2_K571, TIMING_BASE_PT, ctx);\n\ttimings(C2_K571, TIMING_RAND_PT, ctx);\n\ttimings(C2_K571, TIMING_SIMUL, ctx);\n\ttimings(C2_B571, TIMING_BASE_PT, ctx);\n\ttimings(C2_B571, TIMING_RAND_PT, ctx);\n\ttimings(C2_B571, TIMING_SIMUL, ctx);\n#endif\n\tif (ctx)\n\t\tBN_CTX_free(ctx);\n\tBN_free(p); BN_free(a);\tBN_free(b);\n\tEC_GROUP_free(group);\n\tEC_POINT_free(P);\n\tEC_POINT_free(Q);\n\tEC_POINT_free(R);\n\tBN_free(x); BN_free(y); BN_free(z); BN_free(cof);\n\tif (C2_K163) EC_GROUP_free(C2_K163);\n\tif (C2_B163) EC_GROUP_free(C2_B163);\n\tif (C2_K233) EC_GROUP_free(C2_K233);\n\tif (C2_B233) EC_GROUP_free(C2_B233);\n\tif (C2_K283) EC_GROUP_free(C2_K283);\n\tif (C2_B283) EC_GROUP_free(C2_B283);\n\tif (C2_K409) EC_GROUP_free(C2_K409);\n\tif (C2_B409) EC_GROUP_free(C2_B409);\n\tif (C2_K571) EC_GROUP_free(C2_K571);\n\tif (C2_B571) EC_GROUP_free(C2_B571);\n\t}', 'int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar,\n\tconst EC_POINT *point, const BIGNUM *p_scalar, BN_CTX *ctx)\n\t{\n\tconst EC_POINT *points[1];\n\tconst BIGNUM *scalars[1];\n\tpoints[0] = point;\n\tscalars[0] = p_scalar;\n\treturn EC_POINTs_mul(group, r, g_scalar, (point != NULL && p_scalar != NULL), points, scalars, ctx);\n\t}', 'int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,\n\tsize_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx)\n\t{\n\tif (group->meth->mul == 0)\n\t\treturn ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx);\n\treturn group->meth->mul(group, r, scalar, num, points, scalars, ctx);\n\t}', 'int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,\n\tsize_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx)\n\t{\n\tBN_CTX *new_ctx = NULL;\n\tconst EC_POINT *generator = NULL;\n\tEC_POINT *tmp = NULL;\n\tsize_t totalnum;\n\tsize_t blocksize = 0, numblocks = 0;\n\tsize_t pre_points_per_block = 0;\n\tsize_t i, j;\n\tint k;\n\tint r_is_inverted = 0;\n\tint r_is_at_infinity = 1;\n\tsize_t *wsize = NULL;\n\tsigned char **wNAF = NULL;\n\tsize_t *wNAF_len = NULL;\n\tsize_t max_len = 0;\n\tsize_t num_val;\n\tEC_POINT **val = NULL;\n\tEC_POINT **v;\n\tEC_POINT ***val_sub = NULL;\n\tconst EC_PRE_COMP *pre_comp = NULL;\n\tint num_scalar = 0;\n\tint ret = 0;\n\tif (group->meth != r->meth)\n\t\t{\n\t\tECerr(EC_F_EC_WNAF_MUL, EC_R_INCOMPATIBLE_OBJECTS);\n\t\treturn 0;\n\t\t}\n\tif ((scalar == NULL) && (num == 0))\n\t\t{\n\t\treturn EC_POINT_set_to_infinity(group, r);\n\t\t}\n\tfor (i = 0; i < num; i++)\n\t\t{\n\t\tif (group->meth != points[i]->meth)\n\t\t\t{\n\t\t\tECerr(EC_F_EC_WNAF_MUL, EC_R_INCOMPATIBLE_OBJECTS);\n\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\tif (ctx == NULL)\n\t\t{\n\t\tctx = new_ctx = BN_CTX_new();\n\t\tif (ctx == NULL)\n\t\t\tgoto err;\n\t\t}\n\tif (scalar != NULL)\n\t\t{\n\t\tgenerator = EC_GROUP_get0_generator(group);\n\t\tif (generator == NULL)\n\t\t\t{\n\t\t\tECerr(EC_F_EC_WNAF_MUL, EC_R_UNDEFINED_GENERATOR);\n\t\t\tgoto err;\n\t\t\t}\n\t\tpre_comp = EC_EX_DATA_get_data(group->extra_data, ec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free);\n\t\tif (pre_comp && pre_comp->numblocks && (EC_POINT_cmp(group, generator, pre_comp->points[0], ctx) == 0))\n\t\t\t{\n\t\t\tblocksize = pre_comp->blocksize;\n\t\t\tnumblocks = (BN_num_bits(scalar) / blocksize) + 1;\n\t\t\tif (numblocks > pre_comp->numblocks)\n\t\t\t\tnumblocks = pre_comp->numblocks;\n\t\t\tpre_points_per_block = 1u << (pre_comp->w - 1);\n\t\t\tif (pre_comp->num != (pre_comp->numblocks * pre_points_per_block))\n\t\t\t\t{\n\t\t\t\tECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tpre_comp = NULL;\n\t\t\tnumblocks = 1;\n\t\t\tnum_scalar = 1;\n\t\t\t}\n\t\t}\n\ttotalnum = num + numblocks;\n\twsize    = OPENSSL_malloc(totalnum * sizeof wsize[0]);\n\twNAF_len = OPENSSL_malloc(totalnum * sizeof wNAF_len[0]);\n\twNAF     = OPENSSL_malloc((totalnum + 1) * sizeof wNAF[0]);\n\tval_sub  = OPENSSL_malloc(totalnum * sizeof val_sub[0]);\n\tif (!wsize || !wNAF_len || !wNAF || !val_sub)\n\t\t{\n\t\tECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\twNAF[0] = NULL;\n\tnum_val = 0;\n\tfor (i = 0; i < num + num_scalar; i++)\n\t\t{\n\t\tsize_t bits;\n\t\tbits = i < num ? BN_num_bits(scalars[i]) : BN_num_bits(scalar);\n\t\twsize[i] = EC_window_bits_for_scalar_size(bits);\n\t\tnum_val += 1u << (wsize[i] - 1);\n\t\twNAF[i + 1] = NULL;\n\t\twNAF[i] = compute_wNAF((i < num ? scalars[i] : scalar), wsize[i], &wNAF_len[i]);\n\t\tif (wNAF[i] == NULL)\n\t\t\tgoto err;\n\t\tif (wNAF_len[i] > max_len)\n\t\t\tmax_len = wNAF_len[i];\n\t\t}\n\tif (numblocks)\n\t\t{\n\t\tif (pre_comp == NULL)\n\t\t\t{\n\t\t\tif (num_scalar != 1)\n\t\t\t\t{\n\t\t\t\tECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tsigned char *tmp_wNAF = NULL;\n\t\t\tsize_t tmp_len = 0;\n\t\t\tif (num_scalar != 0)\n\t\t\t\t{\n\t\t\t\tECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\twsize[num] = pre_comp->w;\n\t\t\ttmp_wNAF = compute_wNAF(scalar, wsize[num], &tmp_len);\n\t\t\tif (!tmp_wNAF)\n\t\t\t\tgoto err;\n\t\t\tif (tmp_len <= max_len)\n\t\t\t\t{\n\t\t\t\tnumblocks = 1;\n\t\t\t\ttotalnum = num + 1;\n\t\t\t\twNAF[num] = tmp_wNAF;\n\t\t\t\twNAF[num + 1] = NULL;\n\t\t\t\twNAF_len[num] = tmp_len;\n\t\t\t\tif (tmp_len > max_len)\n\t\t\t\t\tmax_len = tmp_len;\n\t\t\t\tval_sub[num] = pre_comp->points;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tsigned char *pp;\n\t\t\t\tEC_POINT **tmp_points;\n\t\t\t\tif (tmp_len < numblocks * blocksize)\n\t\t\t\t\t{\n\t\t\t\t\tnumblocks = (tmp_len + blocksize - 1) / blocksize;\n\t\t\t\t\tif (numblocks > pre_comp->numblocks)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n\t\t\t\t\t\tgoto err;\n\t\t\t\t\t\t}\n\t\t\t\t\ttotalnum = num + numblocks;\n\t\t\t\t\t}\n\t\t\t\tpp = tmp_wNAF;\n\t\t\t\ttmp_points = pre_comp->points;\n\t\t\t\tfor (i = num; i < totalnum; i++)\n\t\t\t\t\t{\n\t\t\t\t\tif (i < totalnum - 1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\twNAF_len[i] = blocksize;\n\t\t\t\t\t\tif (tmp_len < blocksize)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n\t\t\t\t\t\t\tgoto err;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\ttmp_len -= blocksize;\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\twNAF_len[i] = tmp_len;\n\t\t\t\t\twNAF[i + 1] = NULL;\n\t\t\t\t\twNAF[i] = OPENSSL_malloc(wNAF_len[i]);\n\t\t\t\t\tif (wNAF[i] == NULL)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE);\n\t\t\t\t\t\tOPENSSL_free(tmp_wNAF);\n\t\t\t\t\t\tgoto err;\n\t\t\t\t\t\t}\n\t\t\t\t\tmemcpy(wNAF[i], pp, wNAF_len[i]);\n\t\t\t\t\tif (wNAF_len[i] > max_len)\n\t\t\t\t\t\tmax_len = wNAF_len[i];\n\t\t\t\t\tif (*tmp_points == NULL)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n\t\t\t\t\t\tOPENSSL_free(tmp_wNAF);\n\t\t\t\t\t\tgoto err;\n\t\t\t\t\t\t}\n\t\t\t\t\tval_sub[i] = tmp_points;\n\t\t\t\t\ttmp_points += pre_points_per_block;\n\t\t\t\t\tpp += blocksize;\n\t\t\t\t\t}\n\t\t\t\tOPENSSL_free(tmp_wNAF);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tval = OPENSSL_malloc((num_val + 1) * sizeof val[0]);\n\tif (val == NULL)\n\t\t{\n\t\tECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\tval[num_val] = NULL;\n\tv = val;\n\tfor (i = 0; i < num + num_scalar; i++)\n\t\t{\n\t\tval_sub[i] = v;\n\t\tfor (j = 0; j < (1u << (wsize[i] - 1)); j++)\n\t\t\t{\n\t\t\t*v = EC_POINT_new(group);\n\t\t\tif (*v == NULL) goto err;\n\t\t\tv++;\n\t\t\t}\n\t\t}\n\tif (!(v == val + num_val))\n\t\t{\n\t\tECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n\t\tgoto err;\n\t\t}\n\tif (!(tmp = EC_POINT_new(group)))\n\t\tgoto err;\n\tfor (i = 0; i < num + num_scalar; i++)\n\t\t{\n\t\tif (i < num)\n\t\t\t{\n\t\t\tif (!EC_POINT_copy(val_sub[i][0], points[i])) goto err;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tif (!EC_POINT_copy(val_sub[i][0], generator)) goto err;\n\t\t\t}\n\t\tif (wsize[i] > 1)\n\t\t\t{\n\t\t\tif (!EC_POINT_dbl(group, tmp, val_sub[i][0], ctx)) goto err;\n\t\t\tfor (j = 1; j < (1u << (wsize[i] - 1)); j++)\n\t\t\t\t{\n\t\t\t\tif (!EC_POINT_add(group, val_sub[i][j], val_sub[i][j - 1], tmp, ctx)) goto err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n#if 1\n\tif (!EC_POINTs_make_affine(group, num_val, val, ctx))\n\t\tgoto err;\n#endif\n\tr_is_at_infinity = 1;\n\tfor (k = max_len - 1; k >= 0; k--)\n\t\t{\n\t\tif (!r_is_at_infinity)\n\t\t\t{\n\t\t\tif (!EC_POINT_dbl(group, r, r, ctx)) goto err;\n\t\t\t}\n\t\tfor (i = 0; i < totalnum; i++)\n\t\t\t{\n\t\t\tif (wNAF_len[i] > (size_t)k)\n\t\t\t\t{\n\t\t\t\tint digit = wNAF[i][k];\n\t\t\t\tint is_neg;\n\t\t\t\tif (digit)\n\t\t\t\t\t{\n\t\t\t\t\tis_neg = digit < 0;\n\t\t\t\t\tif (is_neg)\n\t\t\t\t\t\tdigit = -digit;\n\t\t\t\t\tif (is_neg != r_is_inverted)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tif (!r_is_at_infinity)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (!EC_POINT_invert(group, r, ctx)) goto err;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tr_is_inverted = !r_is_inverted;\n\t\t\t\t\t\t}\n\t\t\t\t\tif (r_is_at_infinity)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tif (!EC_POINT_copy(r, val_sub[i][digit >> 1])) goto err;\n\t\t\t\t\t\tr_is_at_infinity = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\tif (!EC_POINT_add(group, r, r, val_sub[i][digit >> 1], ctx)) goto err;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif (r_is_at_infinity)\n\t\t{\n\t\tif (!EC_POINT_set_to_infinity(group, r)) goto err;\n\t\t}\n\telse\n\t\t{\n\t\tif (r_is_inverted)\n\t\t\tif (!EC_POINT_invert(group, r, ctx)) goto err;\n\t\t}\n\tret = 1;\n err:\n\tif (new_ctx != NULL)\n\t\tBN_CTX_free(new_ctx);\n\tif (tmp != NULL)\n\t\tEC_POINT_free(tmp);\n\tif (wsize != NULL)\n\t\tOPENSSL_free(wsize);\n\tif (wNAF_len != NULL)\n\t\tOPENSSL_free(wNAF_len);\n\tif (wNAF != NULL)\n\t\t{\n\t\tsigned char **w;\n\t\tfor (w = wNAF; *w != NULL; w++)\n\t\t\tOPENSSL_free(*w);\n\t\tOPENSSL_free(wNAF);\n\t\t}\n\tif (val != NULL)\n\t\t{\n\t\tfor (v = val; *v != NULL; v++)\n\t\t\tEC_POINT_clear_free(*v);\n\t\tOPENSSL_free(val);\n\t\t}\n\tif (val_sub != NULL)\n\t\t{\n\t\tOPENSSL_free(val_sub);\n\t\t}\n\treturn ret;\n\t}', 'int BN_num_bits(const BIGNUM *a)\n\t{\n\tint i = a->top - 1;\n\tbn_check_top(a);\n\tif (BN_is_zero(a)) return 0;\n\treturn ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));\n\t}']