static ASN1_STRING *encode_gost_algor_params(const EVP_PKEY *key)
{
    ASN1_STRING *params = ASN1_STRING_new();
    GOST_KEY_PARAMS *gkp = GOST_KEY_PARAMS_new();
    int pkey_param_nid = NID_undef;

    if (!params || !gkp) {
        GOSTerr(GOST_F_ENCODE_GOST_ALGOR_PARAMS, ERR_R_MALLOC_FAILURE);
        ASN1_STRING_free(params);
        params = NULL;
        goto err;
    }
    switch (EVP_PKEY_base_id(key)) {
    case NID_id_GostR3410_2001:
        pkey_param_nid =
            EC_GROUP_get_curve_name(EC_KEY_get0_group
                                    (EVP_PKEY_get0((EVP_PKEY *)key)));
        break;
    }
    gkp->key_params = OBJ_nid2obj(pkey_param_nid);
    gkp->hash_params = OBJ_nid2obj(NID_id_GostR3411_94_CryptoProParamSet);
    /*
     * gkp->cipher_params = OBJ_nid2obj(cipher_param_nid);
     */
    params->length = i2d_GOST_KEY_PARAMS(gkp, &params->data);
    if (params->length <= 0) {
        GOSTerr(GOST_F_ENCODE_GOST_ALGOR_PARAMS, ERR_R_MALLOC_FAILURE);
        ASN1_STRING_free(params);
        params = NULL;
        goto err;
    }
    params->type = V_ASN1_SEQUENCE;
 err:
    GOST_KEY_PARAMS_free(gkp);
    return params;
}