diff --git a/ccid/src/scutil.c b/ccid/src/scutil.c
index 704c6fd..56acadd 100644
--- a/ccid/src/scutil.c
+++ b/ccid/src/scutil.c
@@ -140,3 +140,25 @@ int build_apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu)
SC_FUNC_RETURN(ctx, SC_LOG_TYPE_VERBOSE, SC_SUCCESS);
}
+void _bin_log(sc_context_t *ctx, int type, const char *file, int line,
+ const char *func, const char *label, const u8 *data, size_t len,
+ FILE *f)
+{
+ char buf[1024];
+
+ if (data)
+ sc_hex_dump(ctx, data, len, buf, sizeof buf);
+ else
+ buf[0] = 0;
+ if (!f) {
+ sc_do_log(ctx, type, file, line, func,
+ "\n%s (%u byte%s):\n%s"
+ "======================================================================",
+ label, len, len==1?"":"s", buf);
+ } else {
+ fprintf(f, "%s (%u byte%s):\n%s"
+ "======================================================================\n",
+ label, len, len==1?"":"s", buf);
+ }
+}
+
diff --git a/ccid/src/scutil.h b/ccid/src/scutil.h
index 6734912..3306dee 100644
--- a/ccid/src/scutil.h
+++ b/ccid/src/scutil.h
@@ -26,5 +26,13 @@ int initialize(int reader_id, const char *cdriver, int verbose,
int build_apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu);
+#define bin_print(file, label, data, len) \
+ _bin_log(NULL, 0, NULL, 0, NULL, label, data, len, file)
+#define bin_log(ctx, label, data, len) \
+ _bin_log(ctx, SC_LOG_TYPE_DEBUG, __FILE__, __LINE__, __FUNCTION__, label, data, len, NULL)
+void _bin_log(sc_context_t *ctx, int type, const char *file, int line,
+ const char *func, const char *label, const u8 *data, size_t len,
+ FILE *f);
+
#endif
diff --git a/ccid/src/sm.c b/ccid/src/sm.c
index 181f1a5..9c5d40f 100644
--- a/ccid/src/sm.c
+++ b/ccid/src/sm.c
@@ -16,6 +16,7 @@
* You should have received a copy of the GNU General Public License along with
* ccid. If not, see .
*/
+#include "scutil.h"
#include "sm.h"
#include
#include
@@ -43,28 +44,6 @@ static const struct sc_asn1_entry c_sm_rapdu[] = {
{ NULL, 0, 0, 0, NULL, NULL }
};
-void _bin_log(sc_context_t *ctx, int type, const char *file, int line,
- const char *func, const char *label, const u8 *data, size_t len,
- FILE *f)
-{
- char buf[1024];
-
- if (data)
- sc_hex_dump(ctx, data, len, buf, sizeof buf);
- else
- buf[0] = 0;
- if (!f) {
- sc_do_log(ctx, type, file, line, func,
- "\n%s (%u byte%s):\n%s"
- "======================================================================",
- label, len, len==1?"":"s", buf);
- } else {
- fprintf(f, "%s (%u byte%s):\n%s"
- "======================================================================\n",
- label, len, len==1?"":"s", buf);
- }
-}
-
int
add_iso_pad(const u8 *data, size_t datalen, int block_size, u8 **padded)
{
diff --git a/ccid/src/sm.h b/ccid/src/sm.h
index 4e1b7ce..7c6d21a 100644
--- a/ccid/src/sm.h
+++ b/ccid/src/sm.h
@@ -53,14 +53,6 @@ int add_iso_pad(const u8 *data, size_t datalen, int block_size, u8 **padded);
int add_padding(const struct sm_ctx *ctx, const u8 *data, size_t datalen,
u8 **padded);
-#define bin_print(file, label, data, len) \
- _bin_log(NULL, 0, NULL, 0, NULL, label, data, len, file)
-#define bin_log(ctx, label, data, len) \
- _bin_log(ctx, SC_LOG_TYPE_DEBUG, __FILE__, __LINE__, __FUNCTION__, label, data, len, NULL)
-void _bin_log(sc_context_t *ctx, int type, const char *file, int line,
- const char *func, const char *label, const u8 *data, size_t len,
- FILE *f);
-
#ifdef __cplusplus
}
#endif