ASN1_OBJECT *OBJ_nid2obj(int n)
{
    ADDED_OBJ ad, *adp;
    ASN1_OBJECT ob;
    if ((n >= 0) && (n < NUM_NID)) {
        if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
            OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);
            return (NULL);
        }
        return ((ASN1_OBJECT *)&(nid_objs[n]));
    } else if (added == NULL)
        return (NULL);
    else {
        ad.type = ADDED_NID;
        ad.obj = &ob;
        ob.nid = n;
        adp = lh_ADDED_OBJ_retrieve(added, &ad);
        if (adp != NULL)
            return (adp->obj);
        else {
            OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);
            return (NULL);
        }
    }
}
['X509_ALGOR *PKCS5_pbe2_set_scrypt(const EVP_CIPHER *cipher,\n                                  const unsigned char *salt, int saltlen,\n                                  unsigned char *aiv, uint64_t N, uint64_t r,\n                                  uint64_t p)\n{\n    X509_ALGOR *scheme = NULL, *kalg = NULL, *ret = NULL;\n    int alg_nid;\n    size_t keylen = 0;\n    EVP_CIPHER_CTX ctx;\n    unsigned char iv[EVP_MAX_IV_LENGTH];\n    PBE2PARAM *pbe2 = NULL;\n    ASN1_OBJECT *obj;\n    if (!cipher) {\n        ASN1err(ASN1_F_PKCS5_PBE2_SET_SCRYPT, ERR_R_PASSED_NULL_PARAMETER);\n        goto err;\n    }\n    if (EVP_PBE_scrypt(NULL, 0, NULL, 0, N, r, p, 0, NULL, 0) == 0) {\n        ASN1err(ASN1_F_PKCS5_PBE2_SET_SCRYPT,\n                ASN1_R_INVALID_SCRYPT_PARAMETERS);\n        goto err;\n    }\n    alg_nid = EVP_CIPHER_type(cipher);\n    if (alg_nid == NID_undef) {\n        ASN1err(ASN1_F_PKCS5_PBE2_SET_SCRYPT,\n                ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER);\n        goto err;\n    }\n    obj = OBJ_nid2obj(alg_nid);\n    pbe2 = PBE2PARAM_new();\n    if (pbe2 == NULL)\n        goto merr;\n    scheme = pbe2->encryption;\n    scheme->algorithm = obj;\n    scheme->parameter = ASN1_TYPE_new();\n    if (scheme->parameter == NULL)\n        goto merr;\n    if (EVP_CIPHER_iv_length(cipher)) {\n        if (aiv)\n            memcpy(iv, aiv, EVP_CIPHER_iv_length(cipher));\n        else if (RAND_bytes(iv, EVP_CIPHER_iv_length(cipher)) < 0)\n            goto err;\n    }\n    EVP_CIPHER_CTX_init(&ctx);\n    if (EVP_CipherInit_ex(&ctx, cipher, NULL, NULL, iv, 0) == 0)\n        goto err;\n    if (EVP_CIPHER_param_to_asn1(&ctx, scheme->parameter) < 0) {\n        ASN1err(ASN1_F_PKCS5_PBE2_SET_SCRYPT,\n                ASN1_R_ERROR_SETTING_CIPHER_PARAMS);\n        EVP_CIPHER_CTX_cleanup(&ctx);\n        goto err;\n    }\n    EVP_CIPHER_CTX_cleanup(&ctx);\n    if (alg_nid == NID_rc2_cbc)\n        keylen = EVP_CIPHER_key_length(cipher);\n    X509_ALGOR_free(pbe2->keyfunc);\n    pbe2->keyfunc = pkcs5_scrypt_set(salt, saltlen, keylen, N, r, p);\n    if (pbe2->keyfunc == NULL)\n        goto merr;\n    ret = X509_ALGOR_new();\n    if (ret == NULL)\n        goto merr;\n    ret->algorithm = OBJ_nid2obj(NID_pbes2);\n    if (ASN1_TYPE_pack_sequence(ASN1_ITEM_rptr(PBE2PARAM), pbe2,\n                                &ret->parameter) == NULL)\n        goto merr;\n    PBE2PARAM_free(pbe2);\n    pbe2 = NULL;\n    return ret;\n merr:\n    ASN1err(ASN1_F_PKCS5_PBE2_SET_SCRYPT, ERR_R_MALLOC_FAILURE);\n err:\n    PBE2PARAM_free(pbe2);\n    X509_ALGOR_free(kalg);\n    X509_ALGOR_free(ret);\n    return NULL;\n}', 'int EVP_CIPHER_type(const EVP_CIPHER *ctx)\n{\n    int nid;\n    ASN1_OBJECT *otmp;\n    nid = EVP_CIPHER_nid(ctx);\n    switch (nid) {\n    case NID_rc2_cbc:\n    case NID_rc2_64_cbc:\n    case NID_rc2_40_cbc:\n        return NID_rc2_cbc;\n    case NID_rc4:\n    case NID_rc4_40:\n        return NID_rc4;\n    case NID_aes_128_cfb128:\n    case NID_aes_128_cfb8:\n    case NID_aes_128_cfb1:\n        return NID_aes_128_cfb128;\n    case NID_aes_192_cfb128:\n    case NID_aes_192_cfb8:\n    case NID_aes_192_cfb1:\n        return NID_aes_192_cfb128;\n    case NID_aes_256_cfb128:\n    case NID_aes_256_cfb8:\n    case NID_aes_256_cfb1:\n        return NID_aes_256_cfb128;\n    case NID_des_cfb64:\n    case NID_des_cfb8:\n    case NID_des_cfb1:\n        return NID_des_cfb64;\n    case NID_des_ede3_cfb64:\n    case NID_des_ede3_cfb8:\n    case NID_des_ede3_cfb1:\n        return NID_des_cfb64;\n    default:\n        otmp = OBJ_nid2obj(nid);\n        if (OBJ_get0_data(otmp) == NULL)\n            nid = NID_undef;\n        ASN1_OBJECT_free(otmp);\n        return nid;\n    }\n}', 'void ASN1_OBJECT_free(ASN1_OBJECT *a)\n{\n    if (a == NULL)\n        return;\n    if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) {\n#ifndef CONST_STRICT\n        OPENSSL_free((void*)a->sn);\n        OPENSSL_free((void*)a->ln);\n#endif\n        a->sn = a->ln = NULL;\n    }\n    if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA) {\n        OPENSSL_free((void*)a->data);\n        a->data = NULL;\n        a->length = 0;\n    }\n    if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC)\n        OPENSSL_free(a);\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}', 'ASN1_OBJECT *OBJ_nid2obj(int n)\n{\n    ADDED_OBJ ad, *adp;\n    ASN1_OBJECT ob;\n    if ((n >= 0) && (n < NUM_NID)) {\n        if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {\n            OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);\n            return (NULL);\n        }\n        return ((ASN1_OBJECT *)&(nid_objs[n]));\n    } else if (added == NULL)\n        return (NULL);\n    else {\n        ad.type = ADDED_NID;\n        ad.obj = &ob;\n        ob.nid = n;\n        adp = lh_ADDED_OBJ_retrieve(added, &ad);\n        if (adp != NULL)\n            return (adp->obj);\n        else {\n            OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);\n            return (NULL);\n        }\n    }\n}']