int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)
{
    int ok = 0;
    BIGNUM *q = NULL;
    *ret = 0;
    q = BN_new();
    if (q == NULL)
        goto err;
    BN_set_word(q, 1);
    if (BN_cmp(pub_key, q) <= 0)
        *ret |= DH_CHECK_PUBKEY_TOO_SMALL;
    BN_copy(q, dh->p);
    BN_sub_word(q, 1);
    if (BN_cmp(pub_key, q) >= 0)
        *ret |= DH_CHECK_PUBKEY_TOO_LARGE;
    ok = 1;
 err:
    BN_free(q);
    return (ok);
}
['int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)\n{\n    int ok = 0;\n    BIGNUM *q = NULL;\n    *ret = 0;\n    q = BN_new();\n    if (q == NULL)\n        goto err;\n    BN_set_word(q, 1);\n    if (BN_cmp(pub_key, q) <= 0)\n        *ret |= DH_CHECK_PUBKEY_TOO_SMALL;\n    BN_copy(q, dh->p);\n    BN_sub_word(q, 1);\n    if (BN_cmp(pub_key, q) >= 0)\n        *ret |= DH_CHECK_PUBKEY_TOO_LARGE;\n    ok = 1;\n err:\n    BN_free(q);\n    return (ok);\n}', 'BIGNUM *BN_new(void)\n{\n    BIGNUM *ret;\n    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {\n        BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    ret->flags = BN_FLG_MALLOCED;\n    bn_check_top(ret);\n    return (ret);\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (num <= 0)\n        return NULL;\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)file;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}', 'int BN_set_word(BIGNUM *a, BN_ULONG w)\n{\n    bn_check_top(a);\n    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)\n        return (0);\n    a->neg = 0;\n    a->d[0] = w;\n    a->top = (w ? 1 : 0);\n    bn_check_top(a);\n    return (1);\n}', 'void BN_free(BIGNUM *a)\n{\n    if (a == NULL)\n        return;\n    bn_check_top(a);\n    if (!BN_get_flags(a, BN_FLG_STATIC_DATA))\n        bn_free_d(a);\n    if (a->flags & BN_FLG_MALLOCED)\n        OPENSSL_free(a);\n    else {\n#if OPENSSL_API_COMPAT < 0x00908000L\n        a->flags |= BN_FLG_FREE;\n#endif\n        a->d = NULL;\n    }\n}', 'int BN_get_flags(const BIGNUM *b, int n)\n{\n    return b->flags & n;\n}']