BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass)
{
    unsigned char dig[SHA_DIGEST_LENGTH];
    EVP_MD_CTX *ctxt;
    unsigned char *cs = NULL;
    BIGNUM *res = NULL;
    if ((s == NULL) || (user == NULL) || (pass == NULL))
        return NULL;
    ctxt = EVP_MD_CTX_new();
    if (ctxt == NULL)
        return NULL;
    if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)
        goto err;
    if (!EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL)
        || !EVP_DigestUpdate(ctxt, user, strlen(user))
        || !EVP_DigestUpdate(ctxt, ":", 1)
        || !EVP_DigestUpdate(ctxt, pass, strlen(pass))
        || !EVP_DigestFinal_ex(ctxt, dig, NULL)
        || !EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL))
        goto err;
    BN_bn2bin(s, cs);
    if (!EVP_DigestUpdate(ctxt, cs, BN_num_bytes(s)))
        goto err;
    if (!EVP_DigestUpdate(ctxt, dig, sizeof(dig))
        || !EVP_DigestFinal_ex(ctxt, dig, NULL))
        goto err;
    res = BN_bin2bn(dig, sizeof(dig), NULL);
 err:
    OPENSSL_free(cs);
    EVP_MD_CTX_free(ctxt);
    return res;
}
['BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass)\n{\n    unsigned char dig[SHA_DIGEST_LENGTH];\n    EVP_MD_CTX *ctxt;\n    unsigned char *cs = NULL;\n    BIGNUM *res = NULL;\n    if ((s == NULL) || (user == NULL) || (pass == NULL))\n        return NULL;\n    ctxt = EVP_MD_CTX_new();\n    if (ctxt == NULL)\n        return NULL;\n    if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)\n        goto err;\n    if (!EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL)\n        || !EVP_DigestUpdate(ctxt, user, strlen(user))\n        || !EVP_DigestUpdate(ctxt, ":", 1)\n        || !EVP_DigestUpdate(ctxt, pass, strlen(pass))\n        || !EVP_DigestFinal_ex(ctxt, dig, NULL)\n        || !EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL))\n        goto err;\n    BN_bn2bin(s, cs);\n    if (!EVP_DigestUpdate(ctxt, cs, BN_num_bytes(s)))\n        goto err;\n    if (!EVP_DigestUpdate(ctxt, dig, sizeof(dig))\n        || !EVP_DigestFinal_ex(ctxt, dig, NULL))\n        goto err;\n    res = BN_bin2bn(dig, sizeof(dig), NULL);\n err:\n    OPENSSL_free(cs);\n    EVP_MD_CTX_free(ctxt);\n    return res;\n}', 'EVP_MD_CTX *EVP_MD_CTX_new(void)\n{\n    return OPENSSL_zalloc(sizeof(EVP_MD_CTX));\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 (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\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    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'int BN_num_bits(const BIGNUM *a)\n{\n    int i = a->top - 1;\n    bn_check_top(a);\n    if (BN_is_zero(a))\n        return 0;\n    return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));\n}', 'int BN_is_zero(const BIGNUM *a)\n{\n    return a->top == 0;\n}', 'const EVP_MD *EVP_sha1(void)\n{\n    return (&sha1_md);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}', 'void EVP_MD_CTX_free(EVP_MD_CTX *ctx)\n{\n    EVP_MD_CTX_reset(ctx);\n    OPENSSL_free(ctx);\n}']