BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
{
    bn_check_top(b);
    if (a == b)
        return a;
    if (bn_wexpand(a, b->top) == NULL)
        return NULL;
    if (b->top > 0)
        memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);
    a->top = b->top;
    a->neg = b->neg;
    bn_check_top(a);
    return a;
}
['static int ssl_srp_cb(SSL *s, int *ad, void *arg)\n{\n    int ret = SSL3_AL_FATAL;\n    char *username;\n    SRP_user_pwd *user = NULL;\n    username = SSL_get_srp_username(s);\n    if (username == NULL) {\n        *ad = SSL_AD_INTERNAL_ERROR;\n        goto err;\n    }\n    user = SRP_VBASE_get1_by_user(vbase, username);\n    if (user == NULL) {\n        *ad = SSL_AD_INTERNAL_ERROR;\n        goto err;\n    }\n    if (SSL_set_srp_server_param(s, user->N, user->g, user->s, user->v,\n                                 user->info) <= 0) {\n        *ad = SSL_AD_INTERNAL_ERROR;\n        goto err;\n    }\n    ret = 0;\n err:\n    SRP_user_pwd_free(user);\n    return ret;\n}', 'SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username)\n{\n    SRP_user_pwd *user;\n    unsigned char digv[SHA_DIGEST_LENGTH];\n    unsigned char digs[SHA_DIGEST_LENGTH];\n    EVP_MD_CTX *ctxt = NULL;\n    if (vb == NULL)\n        return NULL;\n    if ((user = find_user(vb, username)) != NULL)\n        return srp_user_pwd_dup(user);\n    if ((vb->seed_key == NULL) ||\n        (vb->default_g == NULL) || (vb->default_N == NULL))\n        return NULL;\n    if ((user = SRP_user_pwd_new()) == NULL)\n        return NULL;\n    SRP_user_pwd_set_gN(user, vb->default_g, vb->default_N);\n    if (!SRP_user_pwd_set_ids(user, username, NULL))\n        goto err;\n    if (RAND_priv_bytes(digv, SHA_DIGEST_LENGTH) <= 0)\n        goto err;\n    ctxt = EVP_MD_CTX_new();\n    if (ctxt == NULL\n        || !EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL)\n        || !EVP_DigestUpdate(ctxt, vb->seed_key, strlen(vb->seed_key))\n        || !EVP_DigestUpdate(ctxt, username, strlen(username))\n        || !EVP_DigestFinal_ex(ctxt, digs, NULL))\n        goto err;\n    EVP_MD_CTX_free(ctxt);\n    ctxt = NULL;\n    if (SRP_user_pwd_set_sv_BN(user,\n                               BN_bin2bn(digs, SHA_DIGEST_LENGTH, NULL),\n                               BN_bin2bn(digv, SHA_DIGEST_LENGTH, NULL)))\n        return user;\n err:\n    EVP_MD_CTX_free(ctxt);\n    SRP_user_pwd_free(user);\n    return NULL;\n}', 'static SRP_user_pwd *srp_user_pwd_dup(SRP_user_pwd *src)\n{\n    SRP_user_pwd *ret;\n    if (src == NULL)\n        return NULL;\n    if ((ret = SRP_user_pwd_new()) == NULL)\n        return NULL;\n    SRP_user_pwd_set_gN(ret, src->g, src->N);\n    if (!SRP_user_pwd_set_ids(ret, src->id, src->info)\n        || !SRP_user_pwd_set_sv_BN(ret, BN_dup(src->s), BN_dup(src->v))) {\n            SRP_user_pwd_free(ret);\n            return NULL;\n    }\n    return ret;\n}', 'int SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g,\n                             BIGNUM *sa, BIGNUM *v, char *info)\n{\n    if (N != NULL) {\n        if (s->srp_ctx.N != NULL) {\n            if (!BN_copy(s->srp_ctx.N, N)) {\n                BN_free(s->srp_ctx.N);\n                s->srp_ctx.N = NULL;\n            }\n        } else\n            s->srp_ctx.N = BN_dup(N);\n    }\n    if (g != NULL) {\n        if (s->srp_ctx.g != NULL) {\n            if (!BN_copy(s->srp_ctx.g, g)) {\n                BN_free(s->srp_ctx.g);\n                s->srp_ctx.g = NULL;\n            }\n        } else\n            s->srp_ctx.g = BN_dup(g);\n    }\n    if (sa != NULL) {\n        if (s->srp_ctx.s != NULL) {\n            if (!BN_copy(s->srp_ctx.s, sa)) {\n                BN_free(s->srp_ctx.s);\n                s->srp_ctx.s = NULL;\n            }\n        } else\n            s->srp_ctx.s = BN_dup(sa);\n    }\n    if (v != NULL) {\n        if (s->srp_ctx.v != NULL) {\n            if (!BN_copy(s->srp_ctx.v, v)) {\n                BN_free(s->srp_ctx.v);\n                s->srp_ctx.v = NULL;\n            }\n        } else\n            s->srp_ctx.v = BN_dup(v);\n    }\n    if (info != NULL) {\n        if (s->srp_ctx.info)\n            OPENSSL_free(s->srp_ctx.info);\n        if ((s->srp_ctx.info = BUF_strdup(info)) == NULL)\n            return -1;\n    }\n    if (!(s->srp_ctx.N) ||\n        !(s->srp_ctx.g) || !(s->srp_ctx.s) || !(s->srp_ctx.v))\n        return -1;\n    return 1;\n}', 'BIGNUM *BN_dup(const BIGNUM *a)\n{\n    BIGNUM *t;\n    if (a == NULL)\n        return NULL;\n    bn_check_top(a);\n    t = BN_get_flags(a, BN_FLG_SECURE) ? BN_secure_new() : BN_new();\n    if (t == NULL)\n        return NULL;\n    if (!BN_copy(t, a)) {\n        BN_free(t);\n        return NULL;\n    }\n    bn_check_top(t);\n    return t;\n}', 'BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)\n{\n    bn_check_top(b);\n    if (a == b)\n        return a;\n    if (bn_wexpand(a, b->top) == NULL)\n        return NULL;\n    if (b->top > 0)\n        memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);\n    a->top = b->top;\n    a->neg = b->neg;\n    bn_check_top(a);\n    return a;\n}', 'BIGNUM *bn_wexpand(BIGNUM *a, int words)\n{\n    return (words <= a->dmax) ? a : bn_expand2(a, words);\n}']