Пример #1
0
static void sc_pkcs11_print_attr(int level, const char *file, unsigned int line,
			const char *function,
			const char *info, CK_ATTRIBUTE_PTR attr)
{
	struct fmap	*fm;
	const char *	value;

	fm = sc_pkcs11_map_ulong(level, p11_attr_names, attr->type);

	if (attr->pValue == NULL) {
		value = "<size inquiry>";
	} else {
		value = sc_pkcs11_print_value(level, fm,
			attr->pValue, attr->ulValueLen);
	}

	if (fm == NULL) {
		sc_do_log(context, level,
				file, line, function,
				"%s: Attribute 0x%x = %s\n",
				info, attr->type, value);
	} else {
		sc_do_log(context, level,
				file, line, function,
				"%s: %s = %s\n",
				info, fm->name, value);
	}
}
Пример #2
0
Файл: log.c Проект: DDvO/OpenSC
void _sc_debug_hex(sc_context_t *ctx, int type, const char *file, int line,
        const char *func, const char *label, const u8 *data, size_t len)
{
	size_t blen = len * 5 + 128;
	char *buf = malloc(blen);
	if (buf == NULL)
		return;

    sc_hex_dump(ctx, type, data, len, buf, blen);

    if (label)
        sc_do_log(ctx, type, file, line, func,
                "\n%s (%u byte%s):\n%s",
                label, (unsigned int) len, len==1?"":"s", buf);
    else
        sc_do_log(ctx, type, file, line, func,
                "%u byte%s:\n%s",
                (unsigned int) len, len==1?"":"s", buf);

	free(buf);
}
Пример #3
0
void sc_pkcs11_print_attrs(int level, const char *file, unsigned int line,
			const char *function,
			const char *info,
			CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
{
	if (ulCount == 0) {
		sc_do_log(context, level,
			file, line, function,
			"%s: empty template\n",
			info);
		return;
	}

	while (ulCount--)
		sc_pkcs11_print_attr(level, file, line, function,
				info, pTemplate++);

}
Пример #4
0
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)
{
    if (!f) {
        char buf[1800];
        if (data)
            sc_hex_dump(ctx, SC_LOG_DEBUG_NORMAL, data, len, buf, sizeof buf);
        else
            buf[0] = 0;
        sc_do_log(ctx, type, file, line, func,
                "\n%s (%u byte%s)%s%s",
                label, (unsigned int) len, len==1?"":"s", len==0?"":":\n", buf);
    } else {
        fprintf(f, "%s (%u byte%s)%s%s\n",
                label, (unsigned int) len, len==1?"":"s", len==0?"":":\n", sc_dump_hex(data, len));
    }
}
Пример #5
0
void sc_pkcs11_print_attrs(const char *file, unsigned int line,
			const char *function,
			const char *info,
			CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
{
	/* Don't bother with looking at this in detail if debugging
	 * is off */
	if (!context->debug)
		return;

	if (ulCount == 0) {
		sc_do_log(context, SC_LOG_TYPE_DEBUG,
			file, line, function,
			"%s: empty template\n",
			info);
		return;
	}

	while (ulCount--)
		sc_pkcs11_print_attr(file, line, function,
				info, pTemplate++);

}