test/ectest.c:288: error: BUFFER_OVERRUN_L3
  Offset: [1, +oo] Size: [0, 8388607] by call to `EC_POINT_set_compressed_coordinates_GFp`.
Showing all 20 steps of the trace


test/ectest.c:219:10: Call
217.           ABORT;
218.   
219.       if (!BN_hex2bn(&p, "17"))
                ^
220.           ABORT;
221.       if (!BN_hex2bn(&a, "1"))

crypto/bn/bn_print.c:124:1: Parameter `(*bn)->top`
  122.   }
  123.   
  124. > int BN_hex2bn(BIGNUM **bn, const char *a)
  125.   {
  126.       BIGNUM *ret = NULL;

test/ectest.c:288:10: Call
286.       if (!BN_hex2bn(&x, "D"))
287.           ABORT;
288.       if (!EC_POINT_set_compressed_coordinates_GFp(group, Q, x, 1, ctx))
                ^
289.           ABORT;
290.       if (EC_POINT_is_on_curve(group, Q, ctx) <= 0) {

crypto/ec/ec_oct.c:23:1: Parameter `x->top`
  21.   #include "ec_lcl.h"
  22.   
  23. > int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
  24.                                               EC_POINT *point, const BIGNUM *x,
  25.                                               int y_bit, BN_CTX *ctx)

crypto/ec/ec_oct.c:40:20: Call
  38.       if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) {
  39.           if (group->meth->field_type == NID_X9_62_prime_field)
  40.               return ec_GFp_simple_set_compressed_coordinates(group, point, x,
                           ^
  41.                                                               y_bit, ctx);
  42.           else

crypto/ec/ecp_oct.c:21:1: Parameter `x_->top`
    19.   #include "ec_lcl.h"
    20.   
    21. > int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group,
    22.                                                EC_POINT *point,
    23.                                                const BIGNUM *x_, int y_bit,

crypto/ec/ecp_oct.c:56:10: Call
    54.   
    55.       /* tmp1 := x^3 */
    56.       if (!BN_nnmod(x, x_, group->field, ctx))
                   ^
    57.           goto err;
    58.       if (group->meth->field_decode == 0) {

crypto/bn/bn_mod.c:13:1: Parameter `m->top`
      11.   #include "bn_lcl.h"
      12.   
      13. > int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
      14.   {
      15.       /*

crypto/bn/bn_mod.c:20:11: Call
      18.        */
      19.   
      20.       if (!(BN_mod(r, m, d, ctx)))
                      ^
      21.           return 0;
      22.       if (!r->neg)

crypto/bn/bn_div.c:140:1: Parameter `num->top`
        138.    * If 'dv' or 'rm' is NULL, the respective value is not returned.
        139.    */
        140. > int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
        141.              BN_CTX *ctx)
        142.   {

crypto/bn/bn_div.c:210:11: Call
        208.       sdiv->neg = 0;
        209.       norm_shift += BN_BITS2;
        210.       if (!(BN_lshift(snum, num, norm_shift)))
                         ^
        211.           goto err;
        212.       snum->neg = 0;

crypto/bn/bn_shift.c:81:1: <Offset trace>
79.   }
80.   
81. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
82.   {
83.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:81:1: Parameter `n`
          79.   }
          80.   
          81. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
          82.   {
          83.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:96:5: Assignment
          94.   
          95.       r->neg = a->neg;
          96.       nw = n / BN_BITS2;
                    ^
          97.       if (bn_wexpand(r, a->top + nw + 1) == NULL)
          98.           return (0);

crypto/bn/bn_shift.c:81:1: <Length trace>
79.   }
80.   
81. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
82.   {
83.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:81:1: Parameter `*r->d`
          79.   }
          80.   
          81. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
          82.   {
          83.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:97:9: Call
          95.       r->neg = a->neg;
          96.       nw = n / BN_BITS2;
          97.       if (bn_wexpand(r, a->top + nw + 1) == NULL)
                         ^
          98.           return (0);
          99.       lb = n % BN_BITS2;

crypto/bn/bn_lib.c:1016:1: Parameter `*a->d`
            1014.   }
            1015.   
            1016. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
            1017.   {
            1018.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_shift.c:102:5: Assignment
          100.       rb = BN_BITS2 - lb;
          101.       f = a->d;
          102.       t = r->d;
                     ^
          103.       t[a->top + nw] = 0;
          104.       if (lb == 0)

crypto/bn/bn_shift.c:110:13: Array access: Offset: [1, +oo] Size: [0, 8388607] by call to `EC_POINT_set_compressed_coordinates_GFp` 
          108.           for (i = a->top - 1; i >= 0; i--) {
          109.               l = f[i];
          110.               t[nw + i + 1] |= (l >> rb) & BN_MASK2;
                             ^
          111.               t[nw + i] = (l << lb) & BN_MASK2;
          112.           }

int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
{
    int i, nw, lb, rb;
    BN_ULONG *t, *f;
    BN_ULONG l;
    bn_check_top(r);
    bn_check_top(a);
    if (n < 0) {
        BNerr(BN_F_BN_LSHIFT, BN_R_INVALID_SHIFT);
        return 0;
    }
    r->neg = a->neg;
    nw = n / BN_BITS2;
    if (bn_wexpand(r, a->top + nw + 1) == NULL)
        return (0);
    lb = n % BN_BITS2;
    rb = BN_BITS2 - lb;
    f = a->d;
    t = r->d;
    t[a->top + nw] = 0;
    if (lb == 0)
        for (i = a->top - 1; i >= 0; i--)
            t[nw + i] = f[i];
    else
        for (i = a->top - 1; i >= 0; i--) {
            l = f[i];
            t[nw + i + 1] |= (l >> rb) & BN_MASK2;
            t[nw + i] = (l << lb) & BN_MASK2;
        }
    memset(t, 0, sizeof(*t) * nw);
    r->top = a->top + nw + 1;
    bn_correct_top(r);
    bn_check_top(r);
    return (1);
}
['static void prime_field_tests(void)\n{\n    BN_CTX *ctx = NULL;\n    BIGNUM *p, *a, *b;\n    EC_GROUP *group;\n    EC_GROUP *P_160 = NULL, *P_192 = NULL, *P_224 = NULL, *P_256 =\n        NULL, *P_384 = NULL, *P_521 = NULL;\n    EC_POINT *P, *Q, *R;\n    BIGNUM *x, *y, *z, *yplusone;\n    unsigned char buf[100];\n    size_t i, len;\n    int k;\n    ctx = BN_CTX_new();\n    if (!ctx)\n        ABORT;\n    p = BN_new();\n    a = BN_new();\n    b = BN_new();\n    if (!p || !a || !b)\n        ABORT;\n    if (!BN_hex2bn(&p, "17"))\n        ABORT;\n    if (!BN_hex2bn(&a, "1"))\n        ABORT;\n    if (!BN_hex2bn(&b, "1"))\n        ABORT;\n    group = EC_GROUP_new(EC_GFp_mont_method());\n    if (!group)\n        ABORT;\n    if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx))\n        ABORT;\n    {\n        EC_GROUP *tmp;\n        tmp = EC_GROUP_new(EC_GROUP_method_of(group));\n        if (!tmp)\n            ABORT;\n        if (!EC_GROUP_copy(tmp, group))\n            ABORT;\n        EC_GROUP_free(group);\n        group = tmp;\n    }\n    if (!EC_GROUP_get_curve_GFp(group, p, a, b, ctx))\n        ABORT;\n    fprintf(stdout,\n            "Curve defined by Weierstrass equation\\n     y^2 = x^3 + a*x + b  (mod 0x");\n    BN_print_fp(stdout, p);\n    fprintf(stdout, ")\\n     a = 0x");\n    BN_print_fp(stdout, a);\n    fprintf(stdout, "\\n     b = 0x");\n    BN_print_fp(stdout, b);\n    fprintf(stdout, "\\n");\n    P = EC_POINT_new(group);\n    Q = EC_POINT_new(group);\n    R = EC_POINT_new(group);\n    if (!P || !Q || !R)\n        ABORT;\n    if (!EC_POINT_set_to_infinity(group, P))\n        ABORT;\n    if (!EC_POINT_is_at_infinity(group, P))\n        ABORT;\n    buf[0] = 0;\n    if (!EC_POINT_oct2point(group, Q, buf, 1, ctx))\n        ABORT;\n    if (!EC_POINT_add(group, P, P, Q, ctx))\n        ABORT;\n    if (!EC_POINT_is_at_infinity(group, P))\n        ABORT;\n    x = BN_new();\n    y = BN_new();\n    z = BN_new();\n    yplusone = BN_new();\n    if (x == NULL || y == NULL || z == NULL || yplusone == NULL)\n        ABORT;\n    if (!BN_hex2bn(&x, "D"))\n        ABORT;\n    if (!EC_POINT_set_compressed_coordinates_GFp(group, Q, x, 1, ctx))\n        ABORT;\n    if (EC_POINT_is_on_curve(group, Q, ctx) <= 0) {\n        if (!EC_POINT_get_affine_coordinates_GFp(group, Q, x, y, ctx))\n            ABORT;\n        fprintf(stderr, "Point is not on curve: x = 0x");\n        BN_print_fp(stderr, x);\n        fprintf(stderr, ", y = 0x");\n        BN_print_fp(stderr, y);\n        fprintf(stderr, "\\n");\n        ABORT;\n    }\n    fprintf(stdout, "A cyclic subgroup:\\n");\n    k = 100;\n    do {\n        if (k-- == 0)\n            ABORT;\n        if (EC_POINT_is_at_infinity(group, P))\n            fprintf(stdout, "     point at infinity\\n");\n        else {\n            if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx))\n                ABORT;\n            fprintf(stdout, "     x = 0x");\n            BN_print_fp(stdout, x);\n            fprintf(stdout, ", y = 0x");\n            BN_print_fp(stdout, y);\n            fprintf(stdout, "\\n");\n        }\n        if (!EC_POINT_copy(R, P))\n            ABORT;\n        if (!EC_POINT_add(group, P, P, Q, ctx))\n            ABORT;\n    }\n    while (!EC_POINT_is_at_infinity(group, P));\n    if (!EC_POINT_add(group, P, Q, R, ctx))\n        ABORT;\n    if (!EC_POINT_is_at_infinity(group, P))\n        ABORT;\n    len =\n        EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED, buf,\n                           sizeof buf, ctx);\n    if (len == 0)\n        ABORT;\n    if (!EC_POINT_oct2point(group, P, buf, len, ctx))\n        ABORT;\n    if (0 != EC_POINT_cmp(group, P, Q, ctx))\n        ABORT;\n    fprintf(stdout, "Generator as octet string, compressed form:\\n     ");\n    for (i = 0; i < len; i++)\n        fprintf(stdout, "%02X", buf[i]);\n    len =\n        EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED, buf,\n                           sizeof buf, ctx);\n    if (len == 0)\n        ABORT;\n    if (!EC_POINT_oct2point(group, P, buf, len, ctx))\n        ABORT;\n    if (0 != EC_POINT_cmp(group, P, Q, ctx))\n        ABORT;\n    fprintf(stdout, "\\nGenerator as octet string, uncompressed form:\\n     ");\n    for (i = 0; i < len; i++)\n        fprintf(stdout, "%02X", buf[i]);\n    len =\n        EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof buf,\n                           ctx);\n    if (len == 0)\n        ABORT;\n    if (!EC_POINT_oct2point(group, P, buf, len, ctx))\n        ABORT;\n    if (0 != EC_POINT_cmp(group, P, Q, ctx))\n        ABORT;\n    fprintf(stdout, "\\nGenerator as octet string, hybrid form:\\n     ");\n    for (i = 0; i < len; i++)\n        fprintf(stdout, "%02X", buf[i]);\n    if (!EC_POINT_get_Jprojective_coordinates_GFp(group, R, x, y, z, ctx))\n        ABORT;\n    fprintf(stdout,\n            "\\nA representation of the inverse of that generator in\\nJacobian projective coordinates:\\n     X = 0x");\n    BN_print_fp(stdout, x);\n    fprintf(stdout, ", Y = 0x");\n    BN_print_fp(stdout, y);\n    fprintf(stdout, ", Z = 0x");\n    BN_print_fp(stdout, z);\n    fprintf(stdout, "\\n");\n    if (!EC_POINT_invert(group, P, ctx))\n        ABORT;\n    if (0 != EC_POINT_cmp(group, P, R, ctx))\n        ABORT;\n    if (!BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF"))\n        ABORT;\n    if (1 != BN_is_prime_ex(p, BN_prime_checks, ctx, NULL))\n        ABORT;\n    if (!BN_hex2bn(&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC"))\n        ABORT;\n    if (!BN_hex2bn(&b, "1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45"))\n        ABORT;\n    if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx))\n        ABORT;\n    if (!BN_hex2bn(&x, "4A96B5688EF573284664698968C38BB913CBFC82"))\n        ABORT;\n    if (!BN_hex2bn(&y, "23a628553168947d59dcc912042351377ac5fb32"))\n        ABORT;\n    if (!BN_add(yplusone, y, BN_value_one()))\n        ABORT;\n    if (EC_POINT_set_affine_coordinates_GFp(group, P, x, yplusone, ctx))\n        ABORT;\n    if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx))\n        ABORT;\n    if (EC_POINT_is_on_curve(group, P, ctx) <= 0)\n        ABORT;\n    if (!BN_hex2bn(&z, "0100000000000000000001F4C8F927AED3CA752257"))\n        ABORT;\n    if (!EC_GROUP_set_generator(group, P, z, BN_value_one()))\n        ABORT;\n    if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx))\n        ABORT;\n    fprintf(stdout, "\\nSEC2 curve secp160r1 -- Generator:\\n     x = 0x");\n    BN_print_fp(stdout, x);\n    fprintf(stdout, "\\n     y = 0x");\n    BN_print_fp(stdout, y);\n    fprintf(stdout, "\\n");\n    if (!BN_hex2bn(&z, "23a628553168947d59dcc912042351377ac5fb32"))\n        ABORT;\n    if (0 != BN_cmp(y, z))\n        ABORT;\n    fprintf(stdout, "verify degree ...");\n    if (EC_GROUP_get_degree(group) != 160)\n        ABORT;\n    fprintf(stdout, " ok\\n");\n    group_order_tests(group);\n    if ((P_160 = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL)\n        ABORT;\n    if (!EC_GROUP_copy(P_160, group))\n        ABORT;\n    if (!BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF"))\n        ABORT;\n    if (1 != BN_is_prime_ex(p, BN_prime_checks, ctx, NULL))\n        ABORT;\n    if (!BN_hex2bn(&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC"))\n        ABORT;\n    if (!BN_hex2bn(&b, "64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1"))\n        ABORT;\n    if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx))\n        ABORT;\n    if (!BN_hex2bn(&x, "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012"))\n        ABORT;\n    if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx))\n        ABORT;\n    if (EC_POINT_is_on_curve(group, P, ctx) <= 0)\n        ABORT;\n    if (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831"))\n        ABORT;\n    if (!EC_GROUP_set_generator(group, P, z, BN_value_one()))\n        ABORT;\n    if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx))\n        ABORT;\n    fprintf(stdout, "\\nNIST curve P-192 -- Generator:\\n     x = 0x");\n    BN_print_fp(stdout, x);\n    fprintf(stdout, "\\n     y = 0x");\n    BN_print_fp(stdout, y);\n    fprintf(stdout, "\\n");\n    if (!BN_hex2bn(&z, "07192B95FFC8DA78631011ED6B24CDD573F977A11E794811"))\n        ABORT;\n    if (0 != BN_cmp(y, z))\n        ABORT;\n    if (!BN_add(yplusone, y, BN_value_one()))\n        ABORT;\n    if (EC_POINT_set_affine_coordinates_GFp(group, P, x, yplusone, ctx))\n        ABORT;\n    fprintf(stdout, "verify degree ...");\n    if (EC_GROUP_get_degree(group) != 192)\n        ABORT;\n    fprintf(stdout, " ok\\n");\n    group_order_tests(group);\n    if ((P_192 = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL)\n        ABORT;\n    if (!EC_GROUP_copy(P_192, group))\n        ABORT;\n    if (!BN_hex2bn\n        (&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001"))\n        ABORT;\n    if (1 != BN_is_prime_ex(p, BN_prime_checks, ctx, NULL))\n        ABORT;\n    if (!BN_hex2bn\n        (&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE"))\n        ABORT;\n    if (!BN_hex2bn\n        (&b, "B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4"))\n        ABORT;\n    if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx))\n        ABORT;\n    if (!BN_hex2bn\n        (&x, "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21"))\n        ABORT;\n    if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 0, ctx))\n        ABORT;\n    if (EC_POINT_is_on_curve(group, P, ctx) <= 0)\n        ABORT;\n    if (!BN_hex2bn\n        (&z, "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D"))\n        ABORT;\n    if (!EC_GROUP_set_generator(group, P, z, BN_value_one()))\n        ABORT;\n    if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx))\n        ABORT;\n    fprintf(stdout, "\\nNIST curve P-224 -- Generator:\\n     x = 0x");\n    BN_print_fp(stdout, x);\n    fprintf(stdout, "\\n     y = 0x");\n    BN_print_fp(stdout, y);\n    fprintf(stdout, "\\n");\n    if (!BN_hex2bn\n        (&z, "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34"))\n        ABORT;\n    if (0 != BN_cmp(y, z))\n        ABORT;\n    if (!BN_add(yplusone, y, BN_value_one()))\n        ABORT;\n    if (EC_POINT_set_affine_coordinates_GFp(group, P, x, yplusone, ctx))\n        ABORT;\n    fprintf(stdout, "verify degree ...");\n    if (EC_GROUP_get_degree(group) != 224)\n        ABORT;\n    fprintf(stdout, " ok\\n");\n    group_order_tests(group);\n    if ((P_224 = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL)\n        ABORT;\n    if (!EC_GROUP_copy(P_224, group))\n        ABORT;\n    if (!BN_hex2bn\n        (&p,\n         "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF"))\n        ABORT;\n    if (1 != BN_is_prime_ex(p, BN_prime_checks, ctx, NULL))\n        ABORT;\n    if (!BN_hex2bn\n        (&a,\n         "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC"))\n        ABORT;\n    if (!BN_hex2bn\n        (&b,\n         "5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B"))\n        ABORT;\n    if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx))\n        ABORT;\n    if (!BN_hex2bn\n        (&x,\n         "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296"))\n        ABORT;\n    if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx))\n        ABORT;\n    if (EC_POINT_is_on_curve(group, P, ctx) <= 0)\n        ABORT;\n    if (!BN_hex2bn(&z, "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E"\n                   "84F3B9CAC2FC632551"))\n        ABORT;\n    if (!EC_GROUP_set_generator(group, P, z, BN_value_one()))\n        ABORT;\n    if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx))\n        ABORT;\n    fprintf(stdout, "\\nNIST curve P-256 -- Generator:\\n     x = 0x");\n    BN_print_fp(stdout, x);\n    fprintf(stdout, "\\n     y = 0x");\n    BN_print_fp(stdout, y);\n    fprintf(stdout, "\\n");\n    if (!BN_hex2bn\n        (&z,\n         "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5"))\n        ABORT;\n    if (0 != BN_cmp(y, z))\n        ABORT;\n    if (!BN_add(yplusone, y, BN_value_one()))\n        ABORT;\n    if (EC_POINT_set_affine_coordinates_GFp(group, P, x, yplusone, ctx))\n        ABORT;\n    fprintf(stdout, "verify degree ...");\n    if (EC_GROUP_get_degree(group) != 256)\n        ABORT;\n    fprintf(stdout, " ok\\n");\n    group_order_tests(group);\n    if ((P_256 = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL)\n        ABORT;\n    if (!EC_GROUP_copy(P_256, group))\n        ABORT;\n    if (!BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n                   "FFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF"))\n        ABORT;\n    if (1 != BN_is_prime_ex(p, BN_prime_checks, ctx, NULL))\n        ABORT;\n    if (!BN_hex2bn(&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n                   "FFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC"))\n        ABORT;\n    if (!BN_hex2bn(&b, "B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141"\n                   "120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF"))\n        ABORT;\n    if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx))\n        ABORT;\n    if (!BN_hex2bn(&x, "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B"\n                   "9859F741E082542A385502F25DBF55296C3A545E3872760AB7"))\n        ABORT;\n    if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx))\n        ABORT;\n    if (EC_POINT_is_on_curve(group, P, ctx) <= 0)\n        ABORT;\n    if (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n                   "FFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973"))\n        ABORT;\n    if (!EC_GROUP_set_generator(group, P, z, BN_value_one()))\n        ABORT;\n    if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx))\n        ABORT;\n    fprintf(stdout, "\\nNIST curve P-384 -- Generator:\\n     x = 0x");\n    BN_print_fp(stdout, x);\n    fprintf(stdout, "\\n     y = 0x");\n    BN_print_fp(stdout, y);\n    fprintf(stdout, "\\n");\n    if (!BN_hex2bn(&z, "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A14"\n                   "7CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F"))\n        ABORT;\n    if (0 != BN_cmp(y, z))\n        ABORT;\n    if (!BN_add(yplusone, y, BN_value_one()))\n        ABORT;\n    if (EC_POINT_set_affine_coordinates_GFp(group, P, x, yplusone, ctx))\n        ABORT;\n    fprintf(stdout, "verify degree ...");\n    if (EC_GROUP_get_degree(group) != 384)\n        ABORT;\n    fprintf(stdout, " ok\\n");\n    group_order_tests(group);\n    if ((P_384 = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL)\n        ABORT;\n    if (!EC_GROUP_copy(P_384, group))\n        ABORT;\n    if (!BN_hex2bn(&p, "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n                   "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n                   "FFFFFFFFFFFFFFFFFFFFFFFFFFFF"))\n        ABORT;\n    if (1 != BN_is_prime_ex(p, BN_prime_checks, ctx, NULL))\n        ABORT;\n    if (!BN_hex2bn(&a, "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n                   "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n                   "FFFFFFFFFFFFFFFFFFFFFFFFFFFC"))\n        ABORT;\n    if (!BN_hex2bn(&b, "051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B"\n                   "315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573"\n                   "DF883D2C34F1EF451FD46B503F00"))\n        ABORT;\n    if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx))\n        ABORT;\n    if (!BN_hex2bn(&x, "C6858E06B70404E9CD9E3ECB662395B4429C648139053F"\n                   "B521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B"\n                   "3C1856A429BF97E7E31C2E5BD66"))\n        ABORT;\n    if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 0, ctx))\n        ABORT;\n    if (EC_POINT_is_on_curve(group, P, ctx) <= 0)\n        ABORT;\n    if (!BN_hex2bn(&z, "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n                   "FFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5"\n                   "C9B8899C47AEBB6FB71E91386409"))\n        ABORT;\n    if (!EC_GROUP_set_generator(group, P, z, BN_value_one()))\n        ABORT;\n    if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx))\n        ABORT;\n    fprintf(stdout, "\\nNIST curve P-521 -- Generator:\\n     x = 0x");\n    BN_print_fp(stdout, x);\n    fprintf(stdout, "\\n     y = 0x");\n    BN_print_fp(stdout, y);\n    fprintf(stdout, "\\n");\n    if (!BN_hex2bn(&z, "11839296A789A3BC0045C8A5FB42C7D1BD998F54449579"\n                   "B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C"\n                   "7086A272C24088BE94769FD16650"))\n        ABORT;\n    if (0 != BN_cmp(y, z))\n        ABORT;\n    if (!BN_add(yplusone, y, BN_value_one()))\n        ABORT;\n    if (EC_POINT_set_affine_coordinates_GFp(group, P, x, yplusone, ctx))\n        ABORT;\n    fprintf(stdout, "verify degree ...");\n    if (EC_GROUP_get_degree(group) != 521)\n        ABORT;\n    fprintf(stdout, " ok\\n");\n    group_order_tests(group);\n    if ((P_521 = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL)\n        ABORT;\n    if (!EC_GROUP_copy(P_521, group))\n        ABORT;\n    if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx))\n        ABORT;\n    if (!EC_POINT_copy(Q, P))\n        ABORT;\n    if (EC_POINT_is_at_infinity(group, Q))\n        ABORT;\n    if (!EC_POINT_dbl(group, P, P, ctx))\n        ABORT;\n    if (EC_POINT_is_on_curve(group, P, ctx) <= 0)\n        ABORT;\n    if (!EC_POINT_invert(group, Q, ctx))\n        ABORT;\n    if (!EC_POINT_add(group, R, P, Q, ctx))\n        ABORT;\n    if (!EC_POINT_add(group, R, R, Q, ctx))\n        ABORT;\n    if (!EC_POINT_is_at_infinity(group, R))\n        ABORT;\n    {\n        const EC_POINT *points[4];\n        const BIGNUM *scalars[4];\n        BIGNUM *scalar3;\n        if (EC_POINT_is_at_infinity(group, Q))\n            ABORT;\n        points[0] = Q;\n        points[1] = Q;\n        points[2] = Q;\n        points[3] = Q;\n        if (!EC_GROUP_get_order(group, z, ctx))\n            ABORT;\n        if (!BN_add(y, z, BN_value_one()))\n            ABORT;\n        if (BN_is_odd(y))\n            ABORT;\n        if (!BN_rshift1(y, y))\n            ABORT;\n        scalars[0] = y;\n        scalars[1] = y;\n        fprintf(stdout, "combined multiplication ...");\n        fflush(stdout);\n        if (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx))\n            ABORT;\n        if (!EC_POINTs_mul(group, R, z, 2, points, scalars, ctx))\n            ABORT;\n        if (0 != EC_POINT_cmp(group, P, R, ctx))\n            ABORT;\n        if (0 != EC_POINT_cmp(group, R, Q, ctx))\n            ABORT;\n        fprintf(stdout, ".");\n        fflush(stdout);\n        if (!BN_pseudo_rand(y, BN_num_bits(y), 0, 0))\n            ABORT;\n        if (!BN_add(z, z, y))\n            ABORT;\n        BN_set_negative(z, 1);\n        scalars[0] = y;\n        scalars[1] = z;\n        if (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx))\n            ABORT;\n        if (!EC_POINT_is_at_infinity(group, P))\n            ABORT;\n        fprintf(stdout, ".");\n        fflush(stdout);\n        if (!BN_pseudo_rand(x, BN_num_bits(y) - 1, 0, 0))\n            ABORT;\n        if (!BN_add(z, x, y))\n            ABORT;\n        BN_set_negative(z, 1);\n        scalars[0] = x;\n        scalars[1] = y;\n        scalars[2] = z;\n        scalar3 = BN_new();\n        if (!scalar3)\n            ABORT;\n        BN_zero(scalar3);\n        scalars[3] = scalar3;\n        if (!EC_POINTs_mul(group, P, NULL, 4, points, scalars, ctx))\n            ABORT;\n        if (!EC_POINT_is_at_infinity(group, P))\n            ABORT;\n        fprintf(stdout, " ok\\n\\n");\n        BN_free(scalar3);\n    }\n    BN_CTX_free(ctx);\n    BN_free(p);\n    BN_free(a);\n    BN_free(b);\n    EC_GROUP_free(group);\n    EC_POINT_free(P);\n    EC_POINT_free(Q);\n    EC_POINT_free(R);\n    BN_free(x);\n    BN_free(y);\n    BN_free(z);\n    BN_free(yplusone);\n    EC_GROUP_free(P_160);\n    EC_GROUP_free(P_192);\n    EC_GROUP_free(P_224);\n    EC_GROUP_free(P_256);\n    EC_GROUP_free(P_384);\n    EC_GROUP_free(P_521);\n}', "int BN_hex2bn(BIGNUM **bn, const char *a)\n{\n    BIGNUM *ret = NULL;\n    BN_ULONG l = 0;\n    int neg = 0, h, m, i, j, k, c;\n    int num;\n    if ((a == NULL) || (*a == '\\0'))\n        return (0);\n    if (*a == '-') {\n        neg = 1;\n        a++;\n    }\n    for (i = 0; i <= (INT_MAX/4) && isxdigit((unsigned char)a[i]); i++)\n        continue;\n    if (i == 0 || i > INT_MAX/4)\n        goto err;\n    num = i + neg;\n    if (bn == NULL)\n        return (num);\n    if (*bn == NULL) {\n        if ((ret = BN_new()) == NULL)\n            return (0);\n    } else {\n        ret = *bn;\n        BN_zero(ret);\n    }\n    if (bn_expand(ret, i * 4) == NULL)\n        goto err;\n    j = i;\n    m = 0;\n    h = 0;\n    while (j > 0) {\n        m = ((BN_BYTES * 2) <= j) ? (BN_BYTES * 2) : j;\n        l = 0;\n        for (;;) {\n            c = a[j - m];\n            k = OPENSSL_hexchar2int(c);\n            if (k < 0)\n                k = 0;\n            l = (l << 4) | k;\n            if (--m <= 0) {\n                ret->d[h++] = l;\n                break;\n            }\n        }\n        j -= (BN_BYTES * 2);\n    }\n    ret->top = h;\n    bn_correct_top(ret);\n    ret->neg = neg;\n    *bn = ret;\n    bn_check_top(ret);\n    return (num);\n err:\n    if (*bn == NULL)\n        BN_free(ret);\n    return (0);\n}", 'int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,\n                                            EC_POINT *point, const BIGNUM *x,\n                                            int y_bit, BN_CTX *ctx)\n{\n    if (group->meth->point_set_compressed_coordinates == 0\n        && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {\n        ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP,\n              ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (group->meth != point->meth) {\n        ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP,\n              EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) {\n        if (group->meth->field_type == NID_X9_62_prime_field)\n            return ec_GFp_simple_set_compressed_coordinates(group, point, x,\n                                                            y_bit, ctx);\n        else\n#ifdef OPENSSL_NO_EC2M\n        {\n            ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP,\n                  EC_R_GF2M_NOT_SUPPORTED);\n            return 0;\n        }\n#else\n            return ec_GF2m_simple_set_compressed_coordinates(group, point, x,\n                                                             y_bit, ctx);\n#endif\n    }\n    return group->meth->point_set_compressed_coordinates(group, point, x,\n                                                         y_bit, ctx);\n}', 'int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group,\n                                             EC_POINT *point,\n                                             const BIGNUM *x_, int y_bit,\n                                             BN_CTX *ctx)\n{\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *tmp1, *tmp2, *x, *y;\n    int ret = 0;\n    ERR_clear_error();\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return 0;\n    }\n    y_bit = (y_bit != 0);\n    BN_CTX_start(ctx);\n    tmp1 = BN_CTX_get(ctx);\n    tmp2 = BN_CTX_get(ctx);\n    x = BN_CTX_get(ctx);\n    y = BN_CTX_get(ctx);\n    if (y == NULL)\n        goto err;\n    if (!BN_nnmod(x, x_, group->field, ctx))\n        goto err;\n    if (group->meth->field_decode == 0) {\n        if (!group->meth->field_sqr(group, tmp2, x_, ctx))\n            goto err;\n        if (!group->meth->field_mul(group, tmp1, tmp2, x_, ctx))\n            goto err;\n    } else {\n        if (!BN_mod_sqr(tmp2, x_, group->field, ctx))\n            goto err;\n        if (!BN_mod_mul(tmp1, tmp2, x_, group->field, ctx))\n            goto err;\n    }\n    if (group->a_is_minus3) {\n        if (!BN_mod_lshift1_quick(tmp2, x, group->field))\n            goto err;\n        if (!BN_mod_add_quick(tmp2, tmp2, x, group->field))\n            goto err;\n        if (!BN_mod_sub_quick(tmp1, tmp1, tmp2, group->field))\n            goto err;\n    } else {\n        if (group->meth->field_decode) {\n            if (!group->meth->field_decode(group, tmp2, group->a, ctx))\n                goto err;\n            if (!BN_mod_mul(tmp2, tmp2, x, group->field, ctx))\n                goto err;\n        } else {\n            if (!group->meth->field_mul(group, tmp2, group->a, x, ctx))\n                goto err;\n        }\n        if (!BN_mod_add_quick(tmp1, tmp1, tmp2, group->field))\n            goto err;\n    }\n    if (group->meth->field_decode) {\n        if (!group->meth->field_decode(group, tmp2, group->b, ctx))\n            goto err;\n        if (!BN_mod_add_quick(tmp1, tmp1, tmp2, group->field))\n            goto err;\n    } else {\n        if (!BN_mod_add_quick(tmp1, tmp1, group->b, group->field))\n            goto err;\n    }\n    if (!BN_mod_sqrt(y, tmp1, group->field, ctx)) {\n        unsigned long err = ERR_peek_last_error();\n        if (ERR_GET_LIB(err) == ERR_LIB_BN\n            && ERR_GET_REASON(err) == BN_R_NOT_A_SQUARE) {\n            ERR_clear_error();\n            ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,\n                  EC_R_INVALID_COMPRESSED_POINT);\n        } else\n            ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,\n                  ERR_R_BN_LIB);\n        goto err;\n    }\n    if (y_bit != BN_is_odd(y)) {\n        if (BN_is_zero(y)) {\n            int kron;\n            kron = BN_kronecker(x, group->field, ctx);\n            if (kron == -2)\n                goto err;\n            if (kron == 1)\n                ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,\n                      EC_R_INVALID_COMPRESSION_BIT);\n            else\n                ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,\n                      EC_R_INVALID_COMPRESSED_POINT);\n            goto err;\n        }\n        if (!BN_usub(y, group->field, y))\n            goto err;\n    }\n    if (y_bit != BN_is_odd(y)) {\n        ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,\n              ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx))\n        goto err;\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}', 'int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)\n{\n    if (!(BN_mod(r, m, d, ctx)))\n        return 0;\n    if (!r->neg)\n        return 1;\n    return (d->neg ? BN_sub : BN_add) (r, r, d);\n}', 'int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,\n           BN_CTX *ctx)\n{\n    int norm_shift, i, loop;\n    BIGNUM *tmp, wnum, *snum, *sdiv, *res;\n    BN_ULONG *resp, *wnump;\n    BN_ULONG d0, d1;\n    int num_n, div_n;\n    int no_branch = 0;\n    if ((num->top > 0 && num->d[num->top - 1] == 0) ||\n        (divisor->top > 0 && divisor->d[divisor->top - 1] == 0)) {\n        BNerr(BN_F_BN_DIV, BN_R_NOT_INITIALIZED);\n        return 0;\n    }\n    bn_check_top(num);\n    bn_check_top(divisor);\n    if ((BN_get_flags(num, BN_FLG_CONSTTIME) != 0)\n        || (BN_get_flags(divisor, BN_FLG_CONSTTIME) != 0)) {\n        no_branch = 1;\n    }\n    bn_check_top(dv);\n    bn_check_top(rm);\n    if (BN_is_zero(divisor)) {\n        BNerr(BN_F_BN_DIV, BN_R_DIV_BY_ZERO);\n        return (0);\n    }\n    if (!no_branch && BN_ucmp(num, divisor) < 0) {\n        if (rm != NULL) {\n            if (BN_copy(rm, num) == NULL)\n                return (0);\n        }\n        if (dv != NULL)\n            BN_zero(dv);\n        return (1);\n    }\n    BN_CTX_start(ctx);\n    tmp = BN_CTX_get(ctx);\n    snum = BN_CTX_get(ctx);\n    sdiv = BN_CTX_get(ctx);\n    if (dv == NULL)\n        res = BN_CTX_get(ctx);\n    else\n        res = dv;\n    if (sdiv == NULL || res == NULL || tmp == NULL || snum == NULL)\n        goto err;\n    norm_shift = BN_BITS2 - ((BN_num_bits(divisor)) % BN_BITS2);\n    if (!(BN_lshift(sdiv, divisor, norm_shift)))\n        goto err;\n    sdiv->neg = 0;\n    norm_shift += BN_BITS2;\n    if (!(BN_lshift(snum, num, norm_shift)))\n        goto err;\n    snum->neg = 0;\n    if (no_branch) {\n        if (snum->top <= sdiv->top + 1) {\n            if (bn_wexpand(snum, sdiv->top + 2) == NULL)\n                goto err;\n            for (i = snum->top; i < sdiv->top + 2; i++)\n                snum->d[i] = 0;\n            snum->top = sdiv->top + 2;\n        } else {\n            if (bn_wexpand(snum, snum->top + 1) == NULL)\n                goto err;\n            snum->d[snum->top] = 0;\n            snum->top++;\n        }\n    }\n    div_n = sdiv->top;\n    num_n = snum->top;\n    loop = num_n - div_n;\n    wnum.neg = 0;\n    wnum.d = &(snum->d[loop]);\n    wnum.top = div_n;\n    wnum.dmax = snum->dmax - loop;\n    d0 = sdiv->d[div_n - 1];\n    d1 = (div_n == 1) ? 0 : sdiv->d[div_n - 2];\n    wnump = &(snum->d[num_n - 1]);\n    res->neg = (num->neg ^ divisor->neg);\n    if (!bn_wexpand(res, (loop + 1)))\n        goto err;\n    res->top = loop - no_branch;\n    resp = &(res->d[loop - 1]);\n    if (!bn_wexpand(tmp, (div_n + 1)))\n        goto err;\n    if (!no_branch) {\n        if (BN_ucmp(&wnum, sdiv) >= 0) {\n            bn_clear_top2max(&wnum);\n            bn_sub_words(wnum.d, wnum.d, sdiv->d, div_n);\n            *resp = 1;\n        } else\n            res->top--;\n    }\n    resp++;\n    if (res->top == 0)\n        res->neg = 0;\n    else\n        resp--;\n    for (i = 0; i < loop - 1; i++, wnump--) {\n        BN_ULONG q, l0;\n# if defined(BN_DIV3W) && !defined(OPENSSL_NO_ASM)\n        BN_ULONG bn_div_3_words(BN_ULONG *, BN_ULONG, BN_ULONG);\n        q = bn_div_3_words(wnump, d1, d0);\n# else\n        BN_ULONG n0, n1, rem = 0;\n        n0 = wnump[0];\n        n1 = wnump[-1];\n        if (n0 == d0)\n            q = BN_MASK2;\n        else {\n#  ifdef BN_LLONG\n            BN_ULLONG t2;\n#   if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words)\n            q = (BN_ULONG)(((((BN_ULLONG) n0) << BN_BITS2) | n1) / d0);\n#   else\n            q = bn_div_words(n0, n1, d0);\n#   endif\n#   ifndef REMAINDER_IS_ALREADY_CALCULATED\n            rem = (n1 - q * d0) & BN_MASK2;\n#   endif\n            t2 = (BN_ULLONG) d1 *q;\n            for (;;) {\n                if (t2 <= ((((BN_ULLONG) rem) << BN_BITS2) | wnump[-2]))\n                    break;\n                q--;\n                rem += d0;\n                if (rem < d0)\n                    break;\n                t2 -= d1;\n            }\n#  else\n            BN_ULONG t2l, t2h;\n            q = bn_div_words(n0, n1, d0);\n#   ifndef REMAINDER_IS_ALREADY_CALCULATED\n            rem = (n1 - q * d0) & BN_MASK2;\n#   endif\n#   if defined(BN_UMULT_LOHI)\n            BN_UMULT_LOHI(t2l, t2h, d1, q);\n#   elif defined(BN_UMULT_HIGH)\n            t2l = d1 * q;\n            t2h = BN_UMULT_HIGH(d1, q);\n#   else\n            {\n                BN_ULONG ql, qh;\n                t2l = LBITS(d1);\n                t2h = HBITS(d1);\n                ql = LBITS(q);\n                qh = HBITS(q);\n                mul64(t2l, t2h, ql, qh);\n            }\n#   endif\n            for (;;) {\n                if ((t2h < rem) || ((t2h == rem) && (t2l <= wnump[-2])))\n                    break;\n                q--;\n                rem += d0;\n                if (rem < d0)\n                    break;\n                if (t2l < d1)\n                    t2h--;\n                t2l -= d1;\n            }\n#  endif\n        }\n# endif\n        l0 = bn_mul_words(tmp->d, sdiv->d, div_n, q);\n        tmp->d[div_n] = l0;\n        wnum.d--;\n        if (bn_sub_words(wnum.d, wnum.d, tmp->d, div_n + 1)) {\n            q--;\n            if (bn_add_words(wnum.d, wnum.d, sdiv->d, div_n))\n                (*wnump)++;\n        }\n        resp--;\n        *resp = q;\n    }\n    bn_correct_top(snum);\n    if (rm != NULL) {\n        int neg = num->neg;\n        BN_rshift(rm, snum, norm_shift);\n        if (!BN_is_zero(rm))\n            rm->neg = neg;\n        bn_check_top(rm);\n    }\n    if (no_branch)\n        bn_correct_top(res);\n    BN_CTX_end(ctx);\n    return (1);\n err:\n    bn_check_top(rm);\n    BN_CTX_end(ctx);\n    return (0);\n}', 'int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)\n{\n    int i, nw, lb, rb;\n    BN_ULONG *t, *f;\n    BN_ULONG l;\n    bn_check_top(r);\n    bn_check_top(a);\n    if (n < 0) {\n        BNerr(BN_F_BN_LSHIFT, BN_R_INVALID_SHIFT);\n        return 0;\n    }\n    r->neg = a->neg;\n    nw = n / BN_BITS2;\n    if (bn_wexpand(r, a->top + nw + 1) == NULL)\n        return (0);\n    lb = n % BN_BITS2;\n    rb = BN_BITS2 - lb;\n    f = a->d;\n    t = r->d;\n    t[a->top + nw] = 0;\n    if (lb == 0)\n        for (i = a->top - 1; i >= 0; i--)\n            t[nw + i] = f[i];\n    else\n        for (i = a->top - 1; i >= 0; i--) {\n            l = f[i];\n            t[nw + i + 1] |= (l >> rb) & BN_MASK2;\n            t[nw + i] = (l << lb) & BN_MASK2;\n        }\n    memset(t, 0, sizeof(*t) * nw);\n    r->top = a->top + nw + 1;\n    bn_correct_top(r);\n    bn_check_top(r);\n    return (1);\n}', 'BIGNUM *bn_wexpand(BIGNUM *a, int words)\n{\n    return (words <= a->dmax) ? a : bn_expand2(a, words);\n}']