[opensc-devel] textual output of return codes
Hello, I would like to commit the attached patch. It enables the textual output of SC_ERROR return codes in debug messages. Any objections? Regards Andre Index: src/pkcs11/misc.c === --- src/pkcs11/misc.c (revision 4939) +++ src/pkcs11/misc.c (working copy) @@ -56,7 +56,7 @@ static CK_RV sc_to_cryptoki_error_common(int rc) { - sc_debug(context, SC_LOG_DEBUG_NORMAL, "opensc error: %s (%d)\n", sc_strerror(rc), rc); + sc_debug(context, SC_LOG_DEBUG_NORMAL, "libopensc return value: %d (%s)\n", rc, sc_strerror(rc)); switch (rc) { case SC_SUCCESS: return CKR_OK; Index: src/libopensc/errors.c === --- src/libopensc/errors.c (revision 4939) +++ src/libopensc/errors.c (working copy) @@ -116,7 +116,7 @@ "Unknown error", "PKCS#15 compatible smart card not found", }; - const char *no_errors = "No errors"; + const char *no_errors = "Success"; const int misc_base = -SC_ERROR_UNKNOWN; const char **errors = NULL; int count = 0, err_base = 0; Index: src/libopensc/log.h === --- src/libopensc/log.h (revision 4939) +++ src/libopensc/log.h (working copy) @@ -65,14 +65,21 @@ #define SC_FUNC_RETURN(ctx, level, r) do { \ int _ret = r; \ - sc_do_log(ctx, level, __FILE__, __LINE__, __FUNCTION__, "returning with: %d\n", _ret); \ + if (_ret <= 0) { \ + sc_do_log(ctx, level, __FILE__, __LINE__, __FUNCTION__, \ + "returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \ + } else { \ + sc_do_log(ctx, level, __FILE__, __LINE__, __FUNCTION__, \ + "returning with: %d\n", _ret); \ + } \ return _ret; \ } while(0) #define SC_TEST_RET(ctx, level, r, text) do { \ int _ret = (r); \ if (_ret < 0) { \ - sc_do_log(ctx, level, __FILE__, __LINE__, __FUNCTION__, "%s: %s\n", (text), sc_strerror(_ret)); \ + sc_do_log(ctx, level, __FILE__, __LINE__, __FUNCTION__, \ + "%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \ return _ret; \ } \ } while(0) ___ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel
[opensc-devel] fix for r4874, r4902
Hello Douglas, please can you review the attached patch. It fixes some problems in r4874 and f4902. Thanks Index: src/libopensc/pkcs15-pubkey.c === --- src/libopensc/pkcs15-pubkey.c (revision 4939) +++ src/libopensc/pkcs15-pubkey.c (working copy) @@ -516,7 +516,7 @@ * x and y are same size, and field_length = sizeof(x) in bits. */ /* TODO: -DEE support more then uncompressed */ key->field_length = (ecpoint_len - 1)/2 * 8; - if (ecpoint_data); + if (ecpoint_data) free (ecpoint_data); return r; @@ -774,12 +774,13 @@ goto out; } - len = read(f, tagbuf, sizeof(tagbuf)); /* get tag and length */ - if (len < 0) { + r = read(f, tagbuf, sizeof(tagbuf)); /* get tag and length */ + if (r < 2) { sc_debug(ctx, SC_LOG_DEBUG_NORMAL,"Problem with \"%s\"\n",filename); r = SC_ERROR_DATA_OBJECT_NOT_FOUND; goto out; } + len = r; body = tagbuf; if (sc_asn1_read_tag(&body, 0xf, &cla_out, &tag_out, &bodylen) != SC_SUCCESS) { @@ -797,8 +798,8 @@ memcpy(rbuf, tagbuf, len); /* copy first or only part */ if (rbuflen > len) { /* read rest of file */ - len = read(f, rbuf + sizeof(tagbuf), rbuflen - sizeof(tagbuf)); - if (len != rbuflen - sizeof(tagbuf)) { + r = read(f, rbuf + len, rbuflen - len); + if (r < (int)(rbuflen - len)) { r = SC_ERROR_INVALID_ASN1_OBJECT; free (rbuf); rbuf = NULL; ___ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel
[opensc-devel] reader max_x_size
Hello Andreas, some time ago, you have changed the comments on reader max_x_sizes in opensc.conf [1]: "Some reader drivers have limitations, so you need to set these values. For usb devices check the properties with lsusb -vv for dwMaxIFSD." Can you remember why pointing the user to dwMaxIFSD? AFAIK this value is of relevance only for T=1 protocol. But T=1 is capable of transmitting a single APDU in multiple parts, where each part can have a size of up to dwMaxIFSD. In the result T=1 can easily handle APDU:s of every size and therefore the above hint is misleading. I would like to remove these lines in opensc.conf. Any objections? Regards Andre [1] http://www.opensc-project.org/opensc/changeset/3124/ ___ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel