You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.6 KiB

  1. From 9acf5c1ad7d8a32b472203d3bd8860ea2cbde0e7 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Nguy=E1=BB=85n=20H=E1=BB=93ng=20Qu=C3=A2n?=
  3. <ng.hong.quan@gmail.com>
  4. Date: Sun, 3 Nov 2013 02:53:35 +0800
  5. Subject: [PATCH 20/26] OpenPGP: Don't use sc_log in openpgp-tool.
  6. ---
  7. src/tools/openpgp-tool.c | 21 +++++++++++----------
  8. 1 file changed, 11 insertions(+), 10 deletions(-)
  9. Index: opensc-20150513/src/tools/openpgp-tool.c
  10. ===================================================================
  11. --- opensc-20150513.orig/src/tools/openpgp-tool.c
  12. +++ opensc-20150513/src/tools/openpgp-tool.c
  13. @@ -414,8 +414,6 @@ int do_genkey(sc_card_t *card, u8 key_id
  14. sc_path_t path;
  15. sc_file_t *file;
  16. - LOG_FUNC_CALLED(card->ctx);
  17. -
  18. if (key_id < 1 || key_id > 3) {
  19. printf("Unknown key ID %d.\n", key_id);
  20. return 1;
  21. @@ -479,14 +477,14 @@ int delete_key_gnuk(sc_card_t *card, u8
  22. u8 *data = NULL;
  23. /* Delete fingerprint */
  24. - sc_log(ctx, "Delete fingerprints");
  25. + fprintf(stdout, "Delete fingerprints");
  26. r |= sc_put_data(card, 0xC6 + key_id, NULL, 0);
  27. /* Delete creation time */
  28. - sc_log(ctx, "Delete creation time");
  29. + fprintf(stdout, "Delete creation time");
  30. r |= sc_put_data(card, 0xCD + key_id, NULL, 0);
  31. /* Rewrite Extended Header List */
  32. - sc_log(ctx, "Rewrite Extended Header List");
  33. + fprintf(stdout, "Rewrite Extended Header List");
  34. if (key_id == 1)
  35. data = "\x4D\x02\xB6";
  36. @@ -534,15 +532,18 @@ int delete_key_openpgp(sc_card_t *card,
  37. /* Build APDU from binary array */
  38. r = sc_bytes2apdu(card->ctx, buf, len0, &apdu);
  39. if (r) {
  40. - sc_log(ctx, "Failed to build APDU");
  41. - LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
  42. + fprintf(stderr, "Failed to build APDU: %s\n", sc_strerror(r));
  43. + return r;
  44. }
  45. apdu.resp = rbuf;
  46. apdu.resplen = sizeof(rbuf);
  47. /* Send APDU to card */
  48. r = sc_transmit_apdu(card, &apdu);
  49. - LOG_TEST_RET(ctx, r, "Transmiting APDU failed");
  50. + if (r) {
  51. + fprintf(stderr, "Transmiting APDU failed: %s\n", sc_strerror(r));
  52. + return r;
  53. + }
  54. }
  55. /* TODO: Rewrite Extended Header List.
  56. * Not support by OpenGPG v2 yet */
  57. @@ -557,7 +558,7 @@ int delete_key(sc_card_t *card, u8 key_i
  58. LOG_FUNC_CALLED(ctx);
  59. /* Check key ID */
  60. if (key_id < 1 || key_id > 3) {
  61. - sc_log(ctx, "Invalid key ID %d", key_id);
  62. + fprintf(stderr, "Invalid key ID %d", key_id);
  63. LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  64. }
  65. @@ -649,7 +650,7 @@ int main(int argc, char **argv)
  66. (card->type != SC_CARD_TYPE_OPENPGP_V2) &&
  67. (card->type != SC_CARD_TYPE_OPENPGP_GNUK)) {
  68. util_error("not an OpenPGP card");
  69. - sc_log(card->ctx, "Card type %X", card->type);
  70. + fprintf(stderr, "Card type %X\n", card->type);
  71. exit_status = EXIT_FAILURE;
  72. goto out;
  73. }