SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username)
{
    int i;
    SRP_user_pwd *user;
    unsigned char digv[SHA_DIGEST_LENGTH];
    unsigned char digs[SHA_DIGEST_LENGTH];
    EVP_MD_CTX *ctxt = NULL;
    if (vb == NULL)
        return NULL;
    for (i = 0; i < sk_SRP_user_pwd_num(vb->users_pwd); i++) {
        user = sk_SRP_user_pwd_value(vb->users_pwd, i);
        if (strcmp(user->id, username) == 0)
            return user;
    }
    if ((vb->seed_key == NULL) ||
        (vb->default_g == NULL) || (vb->default_N == NULL))
        return NULL;
    if ((user = SRP_user_pwd_new()) == NULL)
        return NULL;
    SRP_user_pwd_set_gN(user, vb->default_g, vb->default_N);
    if (!SRP_user_pwd_set_ids(user, username, NULL))
        goto err;
    if (RAND_bytes(digv, SHA_DIGEST_LENGTH) <= 0)
        goto err;
    ctxt = EVP_MD_CTX_new();
    EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL);
    EVP_DigestUpdate(ctxt, vb->seed_key, strlen(vb->seed_key));
    EVP_DigestUpdate(ctxt, username, strlen(username));
    EVP_DigestFinal_ex(ctxt, digs, NULL);
    EVP_MD_CTX_free(ctxt);
    ctxt = NULL;
    if (SRP_user_pwd_set_sv_BN(user,
                               BN_bin2bn(digs, SHA_DIGEST_LENGTH, NULL),
                               BN_bin2bn(digv, SHA_DIGEST_LENGTH, NULL)))
        return user;
 err:
    EVP_MD_CTX_free(ctxt);
    SRP_user_pwd_free(user);
    return NULL;
}
['SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username)\n{\n    int i;\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    for (i = 0; i < sk_SRP_user_pwd_num(vb->users_pwd); i++) {\n        user = sk_SRP_user_pwd_value(vb->users_pwd, i);\n        if (strcmp(user->id, username) == 0)\n            return user;\n    }\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_bytes(digv, SHA_DIGEST_LENGTH) <= 0)\n        goto err;\n    ctxt = EVP_MD_CTX_new();\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    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}', 'DEFINE_STACK_OF(SRP_user_pwd)', 'int sk_num(const _STACK *st)\n{\n    if (st == NULL)\n        return -1;\n    return st->num;\n}', 'static SRP_user_pwd *SRP_user_pwd_new(void)\n{\n    SRP_user_pwd *ret = OPENSSL_malloc(sizeof(*ret));\n    if (ret == NULL)\n        return NULL;\n    ret->N = NULL;\n    ret->g = NULL;\n    ret->s = NULL;\n    ret->v = NULL;\n    ret->id = NULL;\n    ret->info = NULL;\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}', 'static void SRP_user_pwd_set_gN(SRP_user_pwd *vinfo, const BIGNUM *g,\n                                const BIGNUM *N)\n{\n    vinfo->N = N;\n    vinfo->g = g;\n}', 'static int SRP_user_pwd_set_ids(SRP_user_pwd *vinfo, const char *id,\n                                const char *info)\n{\n    if (id != NULL && NULL == (vinfo->id = OPENSSL_strdup(id)))\n        return 0;\n    return (info == NULL || NULL != (vinfo->info = OPENSSL_strdup(info)));\n}', 'char *CRYPTO_strdup(const char *str, const char* file, int line)\n{\n    char *ret;\n    if (str == NULL)\n        return NULL;\n    ret = CRYPTO_malloc(strlen(str) + 1, file, line);\n    if (ret != NULL)\n        strcpy(ret, str);\n    return ret;\n}', 'int RAND_bytes(unsigned char *buf, int num)\n{\n    const RAND_METHOD *meth = RAND_get_rand_method();\n    if (meth && meth->bytes)\n        return meth->bytes(buf, num);\n    return (-1);\n}', 'const RAND_METHOD *RAND_get_rand_method(void)\n{\n    if (!default_RAND_meth) {\n#ifndef OPENSSL_NO_ENGINE\n        ENGINE *e = ENGINE_get_default_RAND();\n        if (e) {\n            default_RAND_meth = ENGINE_get_RAND(e);\n            if (!default_RAND_meth) {\n                ENGINE_finish(e);\n                e = NULL;\n            }\n        }\n        if (e)\n            funct_ref = e;\n        else\n#endif\n            default_RAND_meth = RAND_OpenSSL();\n    }\n    return default_RAND_meth;\n}', 'void EVP_MD_CTX_free(EVP_MD_CTX *ctx)\n{\n    EVP_MD_CTX_reset(ctx);\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str)\n{\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']