crypto/ec/ectest.c:200: error: BUFFER_OVERRUN_L3
  Offset: [-7, +oo] (⇐ [0, 1] + [-7, +oo]) Size: 2 by call to `BN_hex2bn`.
Showing all 7 steps of the trace


crypto/ec/ectest.c:200:7: Call
198.   
199.   	if (!BN_hex2bn(&p, "17")) ABORT;
200.   	if (!BN_hex2bn(&a, "1")) ABORT;
             ^
201.   	if (!BN_hex2bn(&b, "1")) ABORT;
202.   	

crypto/bn/bn_print.c:168:7: <Offset trace>
166.   	if (*a == '-') { neg=1; a++; }
167.   
168.   	for (i=0; isxdigit((unsigned char) a[i]); i++)
             ^
169.   		;
170.   

crypto/bn/bn_print.c:168:7: Assignment
  166.   	if (*a == '-') { neg=1; a++; }
  167.   
  168.   	for (i=0; isxdigit((unsigned char) a[i]); i++)
               ^
  169.   		;
  170.   

crypto/bn/bn_print.c:188:2: Assignment
  186.   	if (bn_expand(ret,i*4) == NULL) goto err;
  187.   
  188.   	j=i; /* least significant 'hex' */
          ^
  189.   	m=0;
  190.   	h=0;

crypto/bn/bn_print.c:157:1: <Length trace>
155.   	}
156.   
157. > int BN_hex2bn(BIGNUM **bn, const char *a)
158.   	{
159.   	BIGNUM *ret=NULL;

crypto/bn/bn_print.c:157:1: Parameter `*a`
  155.   	}
  156.   
  157. > int BN_hex2bn(BIGNUM **bn, const char *a)
  158.   	{
  159.   	BIGNUM *ret=NULL;

crypto/bn/bn_print.c:197:6: Array access: Offset: [-7, +oo] (⇐ [0, 1] + [-7, +oo]) Size: 2 by call to `BN_hex2bn` 
  195.   		for (;;)
  196.   			{
  197.   			c=a[j-m];
              ^
  198.   			if ((c >= '0') && (c <= '9')) k=c-'0';
  199.   			else if ((c >= 'a') && (c <= 'f')) k=c-'a'+10;

int BN_hex2bn(BIGNUM **bn, const char *a)
	{
	BIGNUM *ret=NULL;
	BN_ULONG l=0;
	int neg=0,h,m,i,j,k,c;
	int num;
	if ((a == NULL) || (*a == '\0')) return(0);
	if (*a == '-') { neg=1; a++; }
	for (i=0; isxdigit((unsigned char) a[i]); i++)
		;
	num=i+neg;
	if (bn == NULL) return(num);
	if (*bn == NULL)
		{
		if ((ret=BN_new()) == NULL) return(0);
		}
	else
		{
		ret= *bn;
		BN_zero(ret);
		}
	if (bn_expand(ret,i*4) == NULL) goto err;
	j=i;
	m=0;
	h=0;
	while (j > 0)
		{
		m=((BN_BYTES*2) <= j)?(BN_BYTES*2):j;
		l=0;
		for (;;)
			{
			c=a[j-m];
			if ((c >= '0') && (c <= '9')) k=c-'0';
			else if ((c >= 'a') && (c <= 'f')) k=c-'a'+10;
			else if ((c >= 'A') && (c <= 'F')) k=c-'A'+10;
			else k=0;
			l=(l<<4)|k;
			if (--m <= 0)
				{
				ret->d[h++]=l;
				break;
				}
			}
		j-=(BN_BYTES*2);
		}
	ret->top=h;
	bn_fix_top(ret);
	ret->neg=neg;
	*bn=ret;
	return(num);
err:
	if (*bn == NULL) BN_free(ret);
	return(0);
	}
['void prime_field_tests()\n\t{\n\tBN_CTX *ctx = NULL;\n\tBIGNUM *p, *a, *b;\n\tEC_GROUP *group;\n\tEC_GROUP *P_192 = NULL, *P_224 = NULL, *P_256 = NULL, *P_384 = NULL, *P_521 = NULL;\n\tEC_POINT *P, *Q, *R;\n\tBIGNUM *x, *y, *z;\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, "17")) ABORT;\n\tif (!BN_hex2bn(&a, "1")) ABORT;\n\tif (!BN_hex2bn(&b, "1")) ABORT;\n\tgroup = EC_GROUP_new(EC_GFp_mont_method());\n\tif (!group) ABORT;\n\tif (!EC_GROUP_set_curve_GFp(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));\n\t\tEC_GROUP_free(group);\n\t\tgroup = tmp;\n\t}\n\tif (!EC_GROUP_get_curve_GFp(group, p, a, b, ctx)) ABORT;\n\tfprintf(stdout, "Curve defined by Weierstrass equation\\n     y^2 = x^3 + a*x + 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");\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\tif (!x || !y || !z) ABORT;\n\tif (!BN_hex2bn(&x, "D")) ABORT;\n\tif (!EC_POINT_set_compressed_coordinates_GFp(group, Q, x, 1, ctx)) ABORT;\n\tif (!EC_POINT_is_on_curve(group, Q, ctx))\n\t\t{\n\t\tif (!EC_POINT_get_affine_coordinates_GFp(group, Q, x, y, ctx)) ABORT;\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_GFp(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#if 0\n\t\t{\n\t\t\tEC_POINT *points[3];\n\t\t\tpoints[0] = R;\n\t\t\tpoints[1] = Q;\n\t\t\tpoints[2] = P;\n\t\t\tif (!EC_POINTs_make_affine(group, 2, points, ctx)) ABORT;\n\t\t}\n#endif\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\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 octect string, compressed form:\\n     ");\n\tfor (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]);\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 octect string, uncompressed form:\\n     ");\n\tfor (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]);\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 octect string, hybrid form:\\n     ");\n\tfor (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]);\n\tif (!EC_POINT_get_Jprojective_coordinates_GFp(group, R, x, y, z, ctx)) ABORT;\n\tfprintf(stdout, "\\nA representation of the inverse of that generator in\\nJacobian projective coordinates:\\n     X = 0x");\n\tBN_print_fp(stdout, x);\n\tfprintf(stdout, ", Y = 0x");\n\tBN_print_fp(stdout, y);\n\tfprintf(stdout, ", Z = 0x");\n\tBN_print_fp(stdout, z);\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\tif (!BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF")) ABORT;\n\tif (1 != BN_is_prime(p, BN_prime_checks, 0, ctx, NULL)) ABORT;\n\tif (!BN_hex2bn(&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC")) ABORT;\n\tif (!BN_hex2bn(&b, "64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1")) ABORT;\n\tif (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;\n\tif (!BN_hex2bn(&x, "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012")) ABORT;\n\tif (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx)) ABORT;\n\tif (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;\n\tif (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831")) ABORT;\n\tif (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;\n\tif (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;\n\tfprintf(stdout, "\\nNIST curve P-192 -- Generator:\\n     x = 0x");\n\tBN_print_fp(stdout, x);\n\tfprintf(stdout, "\\n     y = 0x");\n\tBN_print_fp(stdout, y);\n\tfprintf(stdout, "\\n");\n\tif (!BN_hex2bn(&z, "07192B95FFC8DA78631011ED6B24CDD573F977A11E794811")) ABORT;\n\tif (0 != BN_cmp(y, z)) ABORT;\n\tfprintf(stdout, "verify degree ...");\n\tif (EC_GROUP_get_degree(group) != 192) ABORT;\n\tfprintf(stdout, " ok\\n");\n\tfprintf(stdout, "verify group order ...");\n\tfflush(stdout);\n\tif (!EC_GROUP_get_order(group, z, ctx)) ABORT;\n\tif (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, Q)) ABORT;\n\tfprintf(stdout, ".");\n\tfflush(stdout);\n\tif (!EC_GROUP_precompute_mult(group, ctx)) ABORT;\n\tif (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, Q)) ABORT;\n\tfprintf(stdout, " ok\\n");\n\tif (!(P_192 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;\n\tif (!EC_GROUP_copy(P_192, group)) ABORT;\n\tif (!BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001")) ABORT;\n\tif (1 != BN_is_prime(p, BN_prime_checks, 0, ctx, NULL)) ABORT;\n\tif (!BN_hex2bn(&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE")) ABORT;\n\tif (!BN_hex2bn(&b, "B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4")) ABORT;\n\tif (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;\n\tif (!BN_hex2bn(&x, "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21")) ABORT;\n\tif (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 0, ctx)) ABORT;\n\tif (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;\n\tif (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D")) ABORT;\n\tif (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;\n\tif (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;\n\tfprintf(stdout, "\\nNIST curve P-224 -- Generator:\\n     x = 0x");\n\tBN_print_fp(stdout, x);\n\tfprintf(stdout, "\\n     y = 0x");\n\tBN_print_fp(stdout, y);\n\tfprintf(stdout, "\\n");\n\tif (!BN_hex2bn(&z, "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34")) ABORT;\n\tif (0 != BN_cmp(y, z)) ABORT;\n\tfprintf(stdout, "verify degree ...");\n\tif (EC_GROUP_get_degree(group) != 224) ABORT;\n\tfprintf(stdout, " ok\\n");\n\tfprintf(stdout, "verify group order ...");\n\tfflush(stdout);\n\tif (!EC_GROUP_get_order(group, z, ctx)) ABORT;\n\tif (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, Q)) ABORT;\n\tfprintf(stdout, ".");\n\tfflush(stdout);\n\tif (!EC_GROUP_precompute_mult(group, ctx)) ABORT;\n\tif (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, Q)) ABORT;\n\tfprintf(stdout, " ok\\n");\n\tif (!(P_224 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;\n\tif (!EC_GROUP_copy(P_224, group)) ABORT;\n\tif (!BN_hex2bn(&p, "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF")) ABORT;\n\tif (1 != BN_is_prime(p, BN_prime_checks, 0, ctx, NULL)) ABORT;\n\tif (!BN_hex2bn(&a, "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC")) ABORT;\n\tif (!BN_hex2bn(&b, "5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B")) ABORT;\n\tif (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;\n\tif (!BN_hex2bn(&x, "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296")) ABORT;\n\tif (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx)) ABORT;\n\tif (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;\n\tif (!BN_hex2bn(&z, "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E"\n\t\t"84F3B9CAC2FC632551")) ABORT;\n\tif (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;\n\tif (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;\n\tfprintf(stdout, "\\nNIST curve P-256 -- Generator:\\n     x = 0x");\n\tBN_print_fp(stdout, x);\n\tfprintf(stdout, "\\n     y = 0x");\n\tBN_print_fp(stdout, y);\n\tfprintf(stdout, "\\n");\n\tif (!BN_hex2bn(&z, "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5")) ABORT;\n\tif (0 != BN_cmp(y, z)) ABORT;\n\tfprintf(stdout, "verify degree ...");\n\tif (EC_GROUP_get_degree(group) != 256) ABORT;\n\tfprintf(stdout, " ok\\n");\n\tfprintf(stdout, "verify group order ...");\n\tfflush(stdout);\n\tif (!EC_GROUP_get_order(group, z, ctx)) ABORT;\n\tif (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, Q)) ABORT;\n\tfprintf(stdout, ".");\n\tfflush(stdout);\n\tif (!EC_GROUP_precompute_mult(group, ctx)) ABORT;\n\tif (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, Q)) ABORT;\n\tfprintf(stdout, " ok\\n");\n\tif (!(P_256 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;\n\tif (!EC_GROUP_copy(P_256, group)) ABORT;\n\tif (!BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n\t\t"FFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF")) ABORT;\n\tif (1 != BN_is_prime(p, BN_prime_checks, 0, ctx, NULL)) ABORT;\n\tif (!BN_hex2bn(&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n\t\t"FFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC")) ABORT;\n\tif (!BN_hex2bn(&b, "B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141"\n\t\t"120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF")) ABORT;\n\tif (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;\n\tif (!BN_hex2bn(&x, "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B"\n\t\t"9859F741E082542A385502F25DBF55296C3A545E3872760AB7")) ABORT;\n\tif (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx)) ABORT;\n\tif (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;\n\tif (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n\t\t"FFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973")) ABORT;\n\tif (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;\n\tif (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;\n\tfprintf(stdout, "\\nNIST curve P-384 -- Generator:\\n     x = 0x");\n\tBN_print_fp(stdout, x);\n\tfprintf(stdout, "\\n     y = 0x");\n\tBN_print_fp(stdout, y);\n\tfprintf(stdout, "\\n");\n\tif (!BN_hex2bn(&z, "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A14"\n\t\t"7CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F")) ABORT;\n\tif (0 != BN_cmp(y, z)) ABORT;\n\tfprintf(stdout, "verify degree ...");\n\tif (EC_GROUP_get_degree(group) != 384) ABORT;\n\tfprintf(stdout, " ok\\n");\n\tfprintf(stdout, "verify group order ...");\n\tfflush(stdout);\n\tif (!EC_GROUP_get_order(group, z, ctx)) ABORT;\n\tif (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, Q)) ABORT;\n\tfprintf(stdout, ".");\n\tfflush(stdout);\n\tif (!EC_GROUP_precompute_mult(group, ctx)) ABORT;\n\tif (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, Q)) ABORT;\n\tfprintf(stdout, " ok\\n");\n\tif (!(P_384 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;\n\tif (!EC_GROUP_copy(P_384, group)) ABORT;\n\tif (!BN_hex2bn(&p, "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n\t\t"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n\t\t"FFFFFFFFFFFFFFFFFFFFFFFFFFFF")) ABORT;\n\tif (1 != BN_is_prime(p, BN_prime_checks, 0, ctx, NULL)) ABORT;\n\tif (!BN_hex2bn(&a, "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n\t\t"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n\t\t"FFFFFFFFFFFFFFFFFFFFFFFFFFFC")) ABORT;\n\tif (!BN_hex2bn(&b, "051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B"\n\t\t"315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573"\n\t\t"DF883D2C34F1EF451FD46B503F00")) ABORT;\n\tif (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;\n\tif (!BN_hex2bn(&x, "C6858E06B70404E9CD9E3ECB662395B4429C648139053F"\n\t\t"B521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B"\n\t\t"3C1856A429BF97E7E31C2E5BD66")) ABORT;\n\tif (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 0, ctx)) ABORT;\n\tif (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;\n\tif (!BN_hex2bn(&z, "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n\t\t"FFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5"\n\t\t"C9B8899C47AEBB6FB71E91386409")) ABORT;\n\tif (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;\n\tif (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;\n\tfprintf(stdout, "\\nNIST curve P-521 -- Generator:\\n     x = 0x");\n\tBN_print_fp(stdout, x);\n\tfprintf(stdout, "\\n     y = 0x");\n\tBN_print_fp(stdout, y);\n\tfprintf(stdout, "\\n");\n\tif (!BN_hex2bn(&z, "11839296A789A3BC0045C8A5FB42C7D1BD998F54449579"\n\t\t"B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C"\n\t\t"7086A272C24088BE94769FD16650")) ABORT;\n\tif (0 != BN_cmp(y, z)) ABORT;\n\tfprintf(stdout, "verify degree ...");\n\tif (EC_GROUP_get_degree(group) != 521) ABORT;\n\tfprintf(stdout, " ok\\n");\n\tfprintf(stdout, "verify group order ...");\n\tfflush(stdout);\n\tif (!EC_GROUP_get_order(group, z, ctx)) ABORT;\n\tif (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, Q)) ABORT;\n\tfprintf(stdout, ".");\n\tfflush(stdout);\n\tif (!EC_GROUP_precompute_mult(group, ctx)) ABORT;\n\tif (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;\n\tif (!EC_POINT_is_at_infinity(group, Q)) ABORT;\n\tfprintf(stdout, " ok\\n");\n\tif (!(P_521 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;\n\tif (!EC_GROUP_copy(P_521, group)) ABORT;\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\tz->neg = 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\tz->neg = 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(P_192, 0, ctx);\n\ttimings(P_192, 1, ctx);\n\ttimings(P_224, 0, ctx);\n\ttimings(P_224, 1, ctx);\n\ttimings(P_256, 0, ctx);\n\ttimings(P_256, 1, ctx);\n\ttimings(P_384, 0, ctx);\n\ttimings(P_384, 1, ctx);\n\ttimings(P_521, 0, ctx);\n\ttimings(P_521, 1, 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);\n\tif (P_192) EC_GROUP_free(P_192);\n\tif (P_224) EC_GROUP_free(P_224);\n\tif (P_256) EC_GROUP_free(P_256);\n\tif (P_384) EC_GROUP_free(P_384);\n\tif (P_521) EC_GROUP_free(P_521);\n\t}', "int BN_hex2bn(BIGNUM **bn, const char *a)\n\t{\n\tBIGNUM *ret=NULL;\n\tBN_ULONG l=0;\n\tint neg=0,h,m,i,j,k,c;\n\tint num;\n\tif ((a == NULL) || (*a == '\\0')) return(0);\n\tif (*a == '-') { neg=1; a++; }\n\tfor (i=0; isxdigit((unsigned char) a[i]); i++)\n\t\t;\n\tnum=i+neg;\n\tif (bn == NULL) return(num);\n\tif (*bn == NULL)\n\t\t{\n\t\tif ((ret=BN_new()) == NULL) return(0);\n\t\t}\n\telse\n\t\t{\n\t\tret= *bn;\n\t\tBN_zero(ret);\n\t\t}\n\tif (bn_expand(ret,i*4) == NULL) goto err;\n\tj=i;\n\tm=0;\n\th=0;\n\twhile (j > 0)\n\t\t{\n\t\tm=((BN_BYTES*2) <= j)?(BN_BYTES*2):j;\n\t\tl=0;\n\t\tfor (;;)\n\t\t\t{\n\t\t\tc=a[j-m];\n\t\t\tif ((c >= '0') && (c <= '9')) k=c-'0';\n\t\t\telse if ((c >= 'a') && (c <= 'f')) k=c-'a'+10;\n\t\t\telse if ((c >= 'A') && (c <= 'F')) k=c-'A'+10;\n\t\t\telse k=0;\n\t\t\tl=(l<<4)|k;\n\t\t\tif (--m <= 0)\n\t\t\t\t{\n\t\t\t\tret->d[h++]=l;\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\tj-=(BN_BYTES*2);\n\t\t}\n\tret->top=h;\n\tbn_fix_top(ret);\n\tret->neg=neg;\n\t*bn=ret;\n\treturn(num);\nerr:\n\tif (*bn == NULL) BN_free(ret);\n\treturn(0);\n\t}"]