void PrintGtElemStr(GtElemStr const* gt_elem_str, char const* var_name, PrintUtilFormat format) { if (!var_name) { var_name = "<no name>"; } PRINT("%s (GtElemStr):\n", var_name); if (!gt_elem_str) { MAKE_INDENT(); PRINT("<null>\n"); return; } if (format == kPrintUtilAnnotated) { unsigned int i = 0; for (i = 0; i < sizeof(gt_elem_str->x) / sizeof(gt_elem_str->x[0]); i++) { MAKE_INDENT(); PRINT("x%u:\n", i); if (0 != PrintBuf((const void*)>_elem_str->x[i], sizeof(gt_elem_str->x[i]))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } } } else if (format == kPrintUtilUnannotated) { if (0 != PrintBuf((const void*)gt_elem_str, sizeof(*gt_elem_str))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } } else { MAKE_INDENT(); PRINT("<invalid>\n"); return; } }
void PrintFfElement(FiniteField const* ff, FfElement const* ff_element, char const* var_name, PrintUtilFormat format) { IppStatus sts; uint8_t ff_element_str[sizeof(Fq12ElemStr)]; int ipp_ff_element_size; if (!var_name) { var_name = "<no name>"; } if (!ff_element || !ff) { PRINT("%s (FfElement):\n", var_name); MAKE_INDENT(); PRINT("<null>\n"); return; } if (!ff_element->ipp_ff_elem || !ff->ipp_ff || (format != kPrintUtilUnannotated && format != kPrintUtilAnnotated)) { PRINT("%s (FfElement):\n", var_name); MAKE_INDENT(); PRINT("<invalid>\n"); return; } // get the data ipp_ff_element_size = ff_element->info.elementLen * sizeof(Ipp32u); sts = ippsGFpGetElementOctString(ff_element->ipp_ff_elem, (Ipp8u*)&ff_element_str, ipp_ff_element_size, ff->ipp_ff); if (ippStsNoErr != sts) { PRINT("%s (FfElement):\n", var_name); MAKE_INDENT(); PRINT("<invalid>\n"); return; } if (ipp_ff_element_size == sizeof(FqElemStr)) { PrintFqElemStr((const FqElemStr*)&ff_element_str, var_name); } else if (ipp_ff_element_size == sizeof(FpElemStr)) { PrintFpElemStr((const FpElemStr*)&ff_element_str, var_name); } else if (ipp_ff_element_size == sizeof(Fq2ElemStr)) { PrintFq2ElemStr((const Fq2ElemStr*)&ff_element_str, var_name, format); } else if (ipp_ff_element_size == sizeof(Fq6ElemStr)) { PrintFq6ElemStr((const Fq6ElemStr*)&ff_element_str, var_name, format); } else if (ipp_ff_element_size == sizeof(Fq6ElemStr)) { PrintFq12ElemStr((const Fq12ElemStr*)&ff_element_str, var_name, format); } else if (ipp_ff_element_size == sizeof(GtElemStr)) { PrintGtElemStr((const GtElemStr*)&ff_element_str, var_name, format); } else { PRINT("%s (FfElement):\n", var_name); MAKE_INDENT(); PRINT("<invalid>\n"); } }
static int PrintBuf(void const* buf, size_t size) { size_t curr_column = 0; size_t i = 0; if (!buf || size == 0) { return -1; } for (i = 0; i < size; i++) { if (curr_column == 0) { MAKE_INDENT(); curr_column += INDENT; } if (BYTE_LENGTH != PRINT("%.2x", ((unsigned char const*)buf)[i])) { return -1; } curr_column += BYTE_LENGTH; if (i < size - 1) { if ((curr_column + BYTE_LENGTH + strlen(SEPARATOR)) > WIDTH) { PRINT("\n"); curr_column = 0; } else { PRINT("%s", SEPARATOR); curr_column += (uint8_t)strlen(SEPARATOR); } } } PRINT("\n"); return 0; }
void PrintFqElemStr(FqElemStr const* fq_elem_str, char const* var_name) { if (!var_name) { var_name = "<no name>"; } PRINT("%s (FqElemStr):\n", var_name); if (!fq_elem_str) { MAKE_INDENT(); PRINT("<null>\n"); return; } if (0 != PrintBuf((const void*)fq_elem_str, sizeof(*fq_elem_str))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } }
void PrintBigNumStr(BigNumStr const* big_num_str, char const* var_name) { if (!var_name) { var_name = "<no name>"; } PRINT("%s (BigNumStr):\n", var_name); if (!big_num_str) { MAKE_INDENT(); PRINT("<null>\n"); return; } if (0 != PrintBuf((const void*)big_num_str, sizeof(*big_num_str))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } }
void PrintFq12ElemStr(Fq12ElemStr const* fq12_elem_str, char const* var_name, PrintUtilFormat format) { if (!var_name) { var_name = "<no name>"; } PRINT("%s (Fq12ElemStr):\n", var_name); if (!fq12_elem_str) { MAKE_INDENT(); PRINT("<null>\n"); return; } if (format == kPrintUtilAnnotated) { unsigned int i = 0; unsigned int j = 0; unsigned int k = 0; for (i = 0; i < sizeof(fq12_elem_str->a) / sizeof(fq12_elem_str->a[0]); i++) { for (j = 0; j < sizeof(fq12_elem_str->a[0]) / sizeof(fq12_elem_str->a[0].a[0]); j++) { for (k = 0; k < sizeof(fq12_elem_str->a[0].a[0]) / sizeof(fq12_elem_str->a[0].a[0].a[0]); k++) { MAKE_INDENT(); PRINT("a%u.%u.%u:\n", i, j, k); if (0 != PrintBuf((const void*)&fq12_elem_str->a[i].a[j].a[k], sizeof(fq12_elem_str->a[i].a[j].a[k]))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } } } } } else if (format == kPrintUtilUnannotated) { if (0 != PrintBuf((const void*)fq12_elem_str, sizeof(*fq12_elem_str))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } } else { MAKE_INDENT(); PRINT("<invalid>\n"); return; } }
void PrintBigNum(BigNum const* big_num, char const* var_name) { IppStatus sts = ippStsNoErr; unsigned char* buf = NULL; int ipp_word_buf_size; if (!var_name) { var_name = "<no name>"; } PRINT("%s (BigNum):\n", var_name); if (!big_num) { MAKE_INDENT(); PRINT("<null>\n"); return; } if (!big_num->ipp_bn) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } sts = ippsGetSize_BN(big_num->ipp_bn, &ipp_word_buf_size); if (ippStsNoErr != sts) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } do { buf = SAFE_ALLOC(ipp_word_buf_size * sizeof(Ipp32u)); if (!buf) { MAKE_INDENT(); PRINT("<invalid>\n"); break; } sts = ippsGetOctString_BN((Ipp8u*)buf, ipp_word_buf_size * sizeof(Ipp32u), big_num->ipp_bn); if (ippStsNoErr != sts) { MAKE_INDENT(); PRINT("<invalid>\n"); break; } if (0 != PrintBuf((const void*)buf, ipp_word_buf_size * sizeof(Ipp32u))) { MAKE_INDENT(); PRINT("<invalid>\n"); break; } } while (0); SAFE_FREE(buf); }
static void debug_dump_element_pads (GstIterator * pad_iter, GstPad * pad, GstElement * element, GstDebugGraphDetails details, GString * str, const gint indent, guint * num_pads, gchar * cluster_name, gchar ** first_pad_name) { GValue item = { 0, }; gboolean pads_done; const gchar *spc = MAKE_INDENT (indent); pads_done = FALSE; while (!pads_done) { switch (gst_iterator_next (pad_iter, &item)) { case GST_ITERATOR_OK: pad = g_value_get_object (&item); if (!*num_pads) { g_string_append_printf (str, "%ssubgraph cluster_%s {\n", spc, cluster_name); g_string_append_printf (str, "%s label=\"\";\n", spc); g_string_append_printf (str, "%s style=\"invis\";\n", spc); (*first_pad_name) = debug_dump_make_object_name (GST_OBJECT (pad)); } debug_dump_element_pad (pad, element, details, str, indent); (*num_pads)++; g_value_reset (&item); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (pad_iter); break; case GST_ITERATOR_ERROR: case GST_ITERATOR_DONE: pads_done = TRUE; break; } } if (*num_pads) { g_string_append_printf (str, "%s}\n\n", spc); } }
void PrintFq2ElemStr(Fq2ElemStr const* fq2_elem_str, char const* var_name, PrintUtilFormat format) { if (!var_name) { var_name = "<no name>"; } PRINT("%s (Fq2ElemStr):\n", var_name); if (!fq2_elem_str) { MAKE_INDENT(); PRINT("<null>\n"); return; } if (format == kPrintUtilAnnotated) { MAKE_INDENT(); PRINT("a0:\n"); if (0 != PrintBuf((const void*)&fq2_elem_str->a[0], sizeof(fq2_elem_str->a[0]))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } MAKE_INDENT(); PRINT("a1:\n"); if (0 != PrintBuf((const void*)&fq2_elem_str->a[1], sizeof(fq2_elem_str->a[1]))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } } else if (format == kPrintUtilUnannotated) { if (0 != PrintBuf((const void*)fq2_elem_str, sizeof(*fq2_elem_str))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } } else { MAKE_INDENT(); PRINT("<invalid>\n"); return; } }
void PrintG1ElemStr(G1ElemStr const* g1_elem_str, char const* var_name, PrintUtilFormat format) { if (!var_name) { var_name = "<no name>"; } PRINT("%s (G1ElemStr):\n", var_name); if (!g1_elem_str) { MAKE_INDENT(); PRINT("<null>\n"); return; } if (format == kPrintUtilAnnotated) { MAKE_INDENT(); PRINT("x:\n"); if (0 != PrintBuf((const void*)&g1_elem_str->x, sizeof(g1_elem_str->x))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } MAKE_INDENT(); PRINT("y:\n"); if (0 != PrintBuf((const void*)&g1_elem_str->y, sizeof(g1_elem_str->y))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } } else if (format == kPrintUtilUnannotated) { if (0 != PrintBuf((const void*)g1_elem_str, sizeof(*g1_elem_str))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } } else { MAKE_INDENT(); PRINT("<invalid>\n"); return; } }
/* * debug_dump_element: * @bin: the bin that should be analyzed * @out: file to write to * @indent: level of graph indentation * * Helper for gst_debug_bin_to_dot_file() to recursively dump a pipeline. */ static void debug_dump_element (GstBin * bin, GstDebugGraphDetails details, GString * str, const gint indent) { GstIterator *element_iter, *pad_iter; gboolean elements_done, pads_done; GValue item = { 0, }; GValue item2 = { 0, }; GstElement *element; GstPad *pad = NULL; guint src_pads, sink_pads; gchar *src_pad_name = NULL, *sink_pad_name = NULL; gchar *element_name; gchar *state_name = NULL; gchar *param_name = NULL; const gchar *spc = MAKE_INDENT (indent); element_iter = gst_bin_iterate_elements (bin); elements_done = FALSE; while (!elements_done) { switch (gst_iterator_next (element_iter, &item)) { case GST_ITERATOR_OK: element = g_value_get_object (&item); element_name = debug_dump_make_object_name (GST_OBJECT (element)); if (details & GST_DEBUG_GRAPH_SHOW_STATES) { state_name = debug_dump_get_element_state (GST_ELEMENT (element)); } if (details & GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS) { param_name = debug_dump_get_object_params (G_OBJECT (element), details, NULL); } /* elements */ g_string_append_printf (str, "%ssubgraph cluster_%s {\n", spc, element_name); g_string_append_printf (str, "%s fontname=\"Bitstream Vera Sans\";\n", spc); g_string_append_printf (str, "%s fontsize=\"8\";\n", spc); g_string_append_printf (str, "%s style=\"filled,rounded\";\n", spc); g_string_append_printf (str, "%s color=black;\n", spc); g_string_append_printf (str, "%s label=\"%s\\n%s%s%s\";\n", spc, G_OBJECT_TYPE_NAME (element), GST_OBJECT_NAME (element), (state_name ? state_name : ""), (param_name ? param_name : "") ); if (state_name) { g_free (state_name); state_name = NULL; } if (param_name) { g_free (param_name); param_name = NULL; } src_pads = sink_pads = 0; if ((pad_iter = gst_element_iterate_sink_pads (element))) { gchar *cluster_name = g_strdup_printf ("%s_sink", element_name); debug_dump_element_pads (pad_iter, pad, element, details, str, indent + 1, &sink_pads, cluster_name, &sink_pad_name); g_free (cluster_name); gst_iterator_free (pad_iter); } if ((pad_iter = gst_element_iterate_src_pads (element))) { gchar *cluster_name = g_strdup_printf ("%s_src", element_name); debug_dump_element_pads (pad_iter, pad, element, details, str, indent + 1, &src_pads, cluster_name, &src_pad_name); g_free (cluster_name); gst_iterator_free (pad_iter); } if (sink_pads && src_pads) { /* add invisible link from first sink to first src pad */ g_string_append_printf (str, "%s %s_%s -> %s_%s [style=\"invis\"];\n", spc, element_name, sink_pad_name, element_name, src_pad_name); } g_free (sink_pad_name); g_free (src_pad_name); g_free (element_name); sink_pad_name = src_pad_name = NULL; if (GST_IS_BIN (element)) { g_string_append_printf (str, "%s fillcolor=\"#ffffff\";\n", spc); /* recurse */ debug_dump_element (GST_BIN (element), details, str, indent + 1); } else { if (src_pads && !sink_pads) g_string_append_printf (str, "%s fillcolor=\"#ffaaaa\";\n", spc); else if (!src_pads && sink_pads) g_string_append_printf (str, "%s fillcolor=\"#aaaaff\";\n", spc); else if (src_pads && sink_pads) g_string_append_printf (str, "%s fillcolor=\"#aaffaa\";\n", spc); else g_string_append_printf (str, "%s fillcolor=\"#ffffff\";\n", spc); } g_string_append_printf (str, "%s}\n\n", spc); if ((pad_iter = gst_element_iterate_pads (element))) { pads_done = FALSE; while (!pads_done) { switch (gst_iterator_next (pad_iter, &item2)) { case GST_ITERATOR_OK: pad = g_value_get_object (&item2); if (gst_pad_is_linked (pad)) { if (gst_pad_get_direction (pad) == GST_PAD_SRC) { debug_dump_element_pad_link (pad, element, details, str, indent); } else { GstPad *peer_pad = gst_pad_get_peer (pad); if (peer_pad) { if (!GST_IS_GHOST_PAD (peer_pad) && GST_IS_PROXY_PAD (peer_pad)) { debug_dump_element_pad_link (peer_pad, NULL, details, str, indent); } gst_object_unref (peer_pad); } } } g_value_reset (&item2); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (pad_iter); break; case GST_ITERATOR_ERROR: case GST_ITERATOR_DONE: pads_done = TRUE; break; } } g_value_unset (&item2); gst_iterator_free (pad_iter); } g_value_reset (&item); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (element_iter); break; case GST_ITERATOR_ERROR: case GST_ITERATOR_DONE: elements_done = TRUE; break; } } g_value_unset (&item); gst_iterator_free (element_iter); }
static void debug_dump_element_pad_link (GstPad * pad, GstElement * element, GstDebugGraphDetails details, GString * str, const gint indent) { GstElement *peer_element; GstPad *peer_pad; GstCaps *caps, *peer_caps; gchar *media = NULL; gchar *media_src = NULL, *media_sink = NULL; gchar *pad_name, *element_name; gchar *peer_pad_name, *peer_element_name; const gchar *spc = MAKE_INDENT (indent); if ((peer_pad = gst_pad_get_peer (pad))) { if ((details & GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE) || (details & GST_DEBUG_GRAPH_SHOW_CAPS_DETAILS) ) { caps = gst_pad_get_current_caps (pad); if (!caps) caps = gst_pad_get_pad_template_caps (pad); peer_caps = gst_pad_get_current_caps (peer_pad); if (!peer_caps) peer_caps = gst_pad_get_pad_template_caps (peer_pad); media = debug_dump_describe_caps (caps, details); /* check if peer caps are different */ if (peer_caps && !gst_caps_is_equal (caps, peer_caps)) { gchar *tmp; tmp = debug_dump_describe_caps (peer_caps, details); if (gst_pad_get_direction (pad) == GST_PAD_SRC) { media_src = media; media_sink = tmp; } else { media_src = tmp; media_sink = media; } media = NULL; } gst_caps_unref (peer_caps); gst_caps_unref (caps); } pad_name = debug_dump_make_object_name (GST_OBJECT (pad)); if (element) { element_name = debug_dump_make_object_name (GST_OBJECT (element)); } else { element_name = g_strdup (""); } peer_pad_name = debug_dump_make_object_name (GST_OBJECT (peer_pad)); if ((peer_element = gst_pad_get_parent_element (peer_pad))) { peer_element_name = debug_dump_make_object_name (GST_OBJECT (peer_element)); } else { peer_element_name = g_strdup (""); } /* pad link */ if (media) { g_string_append_printf (str, "%s%s_%s -> %s_%s [label=\"%s\"]\n", spc, element_name, pad_name, peer_element_name, peer_pad_name, media); g_free (media); } else if (media_src && media_sink) { /* dot has some issues with placement of head and taillabels, * we need an empty label to make space */ g_string_append_printf (str, "%s%s_%s -> %s_%s [labeldistance=\"10\", labelangle=\"0\", " "label=\" \", " "taillabel=\"%s\", headlabel=\"%s\"]\n", spc, element_name, pad_name, peer_element_name, peer_pad_name, media_src, media_sink); g_free (media_src); g_free (media_sink); } else { g_string_append_printf (str, "%s%s_%s -> %s_%s\n", spc, element_name, pad_name, peer_element_name, peer_pad_name); } g_free (pad_name); g_free (element_name); g_free (peer_pad_name); g_free (peer_element_name); if (peer_element) gst_object_unref (peer_element); gst_object_unref (peer_pad); } }
static void debug_dump_element_pad (GstPad * pad, GstElement * element, GstDebugGraphDetails details, GString * str, const gint indent) { GstElement *target_element; GstPad *target_pad, *tmp_pad; GstPadDirection dir; gchar *element_name; gchar *target_element_name; const gchar *color_name; dir = gst_pad_get_direction (pad); element_name = debug_dump_make_object_name (GST_OBJECT (element)); if (GST_IS_GHOST_PAD (pad)) { color_name = (dir == GST_PAD_SRC) ? "#ffdddd" : ((dir == GST_PAD_SINK) ? "#ddddff" : "#ffffff"); /* output target-pad so that it belongs to this element */ if ((tmp_pad = gst_ghost_pad_get_target (GST_GHOST_PAD (pad)))) { if ((target_pad = gst_pad_get_peer (tmp_pad))) { gchar *pad_name, *target_pad_name; const gchar *spc = MAKE_INDENT (indent); if ((target_element = gst_pad_get_parent_element (target_pad))) { target_element_name = debug_dump_make_object_name (GST_OBJECT (target_element)); } else { target_element_name = g_strdup (""); } debug_dump_pad (target_pad, color_name, target_element_name, details, str, indent); /* src ghostpad relationship */ pad_name = debug_dump_make_object_name (GST_OBJECT (pad)); target_pad_name = debug_dump_make_object_name (GST_OBJECT (target_pad)); if (dir == GST_PAD_SRC) { g_string_append_printf (str, "%s%s_%s -> %s_%s [style=dashed, minlen=0]\n", spc, target_element_name, target_pad_name, element_name, pad_name); } else { g_string_append_printf (str, "%s%s_%s -> %s_%s [style=dashed, minlen=0]\n", spc, element_name, pad_name, target_element_name, target_pad_name); } g_free (target_pad_name); g_free (target_element_name); if (target_element) gst_object_unref (target_element); gst_object_unref (target_pad); g_free (pad_name); } gst_object_unref (tmp_pad); } } else { color_name = (dir == GST_PAD_SRC) ? "#ffaaaa" : ((dir == GST_PAD_SINK) ? "#aaaaff" : "#cccccc"); } /* pads */ debug_dump_pad (pad, color_name, element_name, details, str, indent); g_free (element_name); }
static void debug_dump_pad (GstPad * pad, const gchar * color_name, const gchar * element_name, GstDebugGraphDetails details, GString * str, const gint indent) { GstPadTemplate *pad_templ; GstPadPresence presence; gchar *pad_name, *param_name = NULL; const gchar *style_name; static const char *const ignore_propnames[] = { "parent", "direction", "template", "caps", NULL }; const gchar *spc = MAKE_INDENT (indent); pad_name = debug_dump_make_object_name (GST_OBJECT (pad)); /* pad availability */ style_name = "filled,solid"; if ((pad_templ = gst_pad_get_pad_template (pad))) { presence = GST_PAD_TEMPLATE_PRESENCE (pad_templ); gst_object_unref (pad_templ); if (presence == GST_PAD_SOMETIMES) { style_name = "filled,dotted"; } else if (presence == GST_PAD_REQUEST) { style_name = "filled,dashed"; } } param_name = debug_dump_get_object_params (G_OBJECT (pad), details, ignore_propnames); if (details & GST_DEBUG_GRAPH_SHOW_STATES) { gchar pad_flags[4]; const gchar *activation_mode = "-><"; const gchar *task_mode = ""; GstTask *task; GST_OBJECT_LOCK (pad); task = GST_PAD_TASK (pad); if (task) { switch (gst_task_get_state (task)) { case GST_TASK_STARTED: task_mode = "[T]"; break; case GST_TASK_PAUSED: task_mode = "[t]"; break; default: /* Invalid task state, ignoring */ break; } } GST_OBJECT_UNLOCK (pad); /* check if pad flags */ pad_flags[0] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKED) ? 'B' : 'b'; pad_flags[1] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FLUSHING) ? 'F' : 'f'; pad_flags[2] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKING) ? 'B' : 'b'; pad_flags[3] = '\0'; g_string_append_printf (str, "%s %s_%s [color=black, fillcolor=\"%s\", label=\"%s%s\\n[%c][%s]%s\", height=\"0.2\", style=\"%s\"];\n", spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad), (param_name ? param_name : ""), activation_mode[pad->mode], pad_flags, task_mode, style_name); } else { g_string_append_printf (str, "%s %s_%s [color=black, fillcolor=\"%s\", label=\"%s%s\", height=\"0.2\", style=\"%s\"];\n", spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad), (param_name ? param_name : ""), style_name); } g_free (param_name); g_free (pad_name); }
void PrintG2ElemStr(G2ElemStr const* g2_elem_str, char const* var_name, PrintUtilFormat format) { if (!var_name) { var_name = "<no name>"; } PRINT("%s (G2ElemStr):\n", var_name); if (!g2_elem_str) { MAKE_INDENT(); PRINT("<null>\n"); return; } if (format == kPrintUtilAnnotated) { MAKE_INDENT(); PRINT("x0:\n"); if (0 != PrintBuf((const void*)&g2_elem_str->x[0], sizeof(g2_elem_str->x[0]))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } MAKE_INDENT(); PRINT("x1:\n"); if (0 != PrintBuf((const void*)&g2_elem_str->x[1], sizeof(g2_elem_str->x[1]))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } MAKE_INDENT(); PRINT("y0:\n"); if (0 != PrintBuf((const void*)&g2_elem_str->y[0], sizeof(g2_elem_str->y[0]))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } MAKE_INDENT(); PRINT("y1:\n"); if (0 != PrintBuf((const void*)&g2_elem_str->y[1], sizeof(g2_elem_str->y[1]))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } } else if (format == kPrintUtilUnannotated) { if (0 != PrintBuf((const void*)g2_elem_str, sizeof(*g2_elem_str))) { MAKE_INDENT(); PRINT("<invalid>\n"); return; } } else { MAKE_INDENT(); PRINT("<invalid>\n"); return; } }
void PrintEcPoint(EcGroup const* g, EcPoint const* ec_point, char const* var_name, PrintUtilFormat format) { FiniteField fp; FfElement* fp_x = NULL; FfElement* fp_y = NULL; uint8_t ec_point_str[sizeof(G2ElemStr)]; if (!var_name) { var_name = "<no name>"; } if (!ec_point || !g) { PRINT("%s (EcPoint):\n", var_name); MAKE_INDENT(); PRINT("<null>\n"); return; } if (!ec_point->ipp_ec_pt || !g->ipp_ec) { PRINT("%s (EcPoint):\n", var_name); MAKE_INDENT(); PRINT("<invalid>\n"); return; } do { IppStatus sts = ippStsNoErr; int ipp_half_strlen; // get finite field sts = ippsGFpECGet(g->ipp_ec, (const IppsGFpState**)&(fp.ipp_ff), 0, 0, 0, 0, 0, 0, 0, 0); if (ippStsNoErr != sts) { PRINT("%s (EcPoint):\n", var_name); MAKE_INDENT(); PRINT("<invalid>\n"); break; } // create element X if (kEpidNoErr != NewFfElement(&fp, &fp_x)) { PRINT("%s (EcPoint):\n", var_name); MAKE_INDENT(); PRINT("<invalid>\n"); break; } // create element Y if (kEpidNoErr != NewFfElement(&fp, &fp_y)) { PRINT("%s (EcPoint):\n", var_name); MAKE_INDENT(); PRINT("<invalid>\n"); break; } ipp_half_strlen = fp_x->info.elementLen * sizeof(Ipp32u); // get elements from point sts = ippsGFpECGetPoint(ec_point->ipp_ec_pt, fp_x->ipp_ff_elem, fp_y->ipp_ff_elem, g->ipp_ec); // check return codes if (ippStsNoErr != sts) { PRINT("%s (EcPoint):\n", var_name); MAKE_INDENT(); PRINT("<invalid>\n"); break; } // get element X data sts = ippsGFpGetElementOctString(fp_x->ipp_ff_elem, (Ipp8u*)&ec_point_str, ipp_half_strlen, fp.ipp_ff); // check return codes if (ippStsNoErr != sts) { PRINT("%s (EcPoint):\n", var_name); MAKE_INDENT(); PRINT("<invalid>\n"); break; } // get element Y data sts = ippsGFpGetElementOctString(fp_y->ipp_ff_elem, (Ipp8u*)&ec_point_str + ipp_half_strlen, ipp_half_strlen, fp.ipp_ff); // check return codes if (ippStsNoErr != sts) { PRINT("%s (EcPoint):\n", var_name); MAKE_INDENT(); PRINT("<invalid>\n"); break; } if (2 * ipp_half_strlen == sizeof(G1ElemStr)) { PrintG1ElemStr((const G1ElemStr*)&ec_point_str, var_name, format); } else if (2 * ipp_half_strlen == sizeof(G2ElemStr)) { PrintG2ElemStr((const G2ElemStr*)&ec_point_str, var_name, format); } else { PRINT("%s (EcPoint):\n", var_name); MAKE_INDENT(); PRINT("<invalid>\n"); break; } } while (0); DeleteFfElement(&fp_x); DeleteFfElement(&fp_y); }