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.

112 lines
2.9 KiB

  1. From 0fdbf868976172486af210accafbab163452ff78 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 11:26:25 +0800
  5. Subject: [PATCH 21/26] OpenPGP: Don't reimplement gnuk_delete_key in
  6. openpgp-tool.
  7. ---
  8. src/tools/openpgp-tool.c | 64 ++++++------------------------------------------
  9. 1 file changed, 8 insertions(+), 56 deletions(-)
  10. diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c
  11. index 505abd9..a7796e7 100644
  12. --- a/src/tools/openpgp-tool.c
  13. +++ b/src/tools/openpgp-tool.c
  14. @@ -468,38 +468,6 @@ int do_verify(sc_card_t *card, char *type, char *pin)
  15. }
  16. /**
  17. - * Delete key, for Gnuk.
  18. - **/
  19. -int delete_key_gnuk(sc_card_t *card, u8 key_id)
  20. -{
  21. - sc_context_t *ctx = card->ctx;
  22. - int r = SC_SUCCESS;
  23. - u8 *data = NULL;
  24. -
  25. - /* Delete fingerprint */
  26. - fprintf(stdout, "Delete fingerprints");
  27. - r |= sc_put_data(card, 0xC6 + key_id, NULL, 0);
  28. - /* Delete creation time */
  29. - fprintf(stdout, "Delete creation time");
  30. - r |= sc_put_data(card, 0xCD + key_id, NULL, 0);
  31. -
  32. - /* Rewrite Extended Header List */
  33. - fprintf(stdout, "Rewrite Extended Header List");
  34. -
  35. - if (key_id == 1)
  36. - data = "\x4D\x02\xB6";
  37. - else if (key_id == 2)
  38. - data = "\x4D\x02\xB8";
  39. - else if (key_id == 3)
  40. - data = "\x4D\x02\xA4";
  41. - else
  42. - return SC_ERROR_INVALID_ARGUMENTS;
  43. -
  44. - r |= sc_put_data(card, 0x4D, data, strlen(data) + 1);
  45. - return r;
  46. -}
  47. -
  48. -/**
  49. * Delete key, for OpenPGP card.
  50. * This function is not complete and is reserved for future version (> 2) of OpenPGP card.
  51. **/
  52. @@ -547,32 +515,13 @@ int delete_key_openpgp(sc_card_t *card, u8 key_id)
  53. }
  54. /* TODO: Rewrite Extended Header List.
  55. * Not support by OpenGPG v2 yet */
  56. - LOG_FUNC_RETURN(ctx, r);
  57. -}
  58. -
  59. -int delete_key(sc_card_t *card, u8 key_id)
  60. -{
  61. - sc_context_t *ctx = card->ctx;
  62. - int r;
  63. -
  64. - LOG_FUNC_CALLED(ctx);
  65. - /* Check key ID */
  66. - if (key_id < 1 || key_id > 3) {
  67. - fprintf(stderr, "Invalid key ID %d", key_id);
  68. - LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  69. - }
  70. -
  71. - if (card->type == SC_CARD_TYPE_OPENPGP_GNUK)
  72. - r = delete_key_gnuk(card, key_id);
  73. - else
  74. - r = delete_key_openpgp(card, key_id);
  75. -
  76. - LOG_FUNC_RETURN(ctx, r);
  77. + return r;
  78. }
  79. int do_delete_key(sc_card_t *card, u8 key_id)
  80. {
  81. sc_context_t *ctx = card->ctx;
  82. + sc_path_t path;
  83. int r = SC_SUCCESS;
  84. /* Currently, only Gnuk supports deleting keys */
  85. @@ -586,13 +535,16 @@ int do_delete_key(sc_card_t *card, u8 key_id)
  86. return SC_ERROR_INVALID_ARGUMENTS;
  87. }
  88. if (key_id == 1 || key_id == 'a') {
  89. - r |= delete_key(card, 1);
  90. + sc_format_path("B601", &path);
  91. + r |= sc_delete_file(card, &path);
  92. }
  93. if (key_id == 2 || key_id == 'a') {
  94. - r |= delete_key(card, 2);
  95. + sc_format_path("B801", &path);
  96. + r |= sc_delete_file(card, &path);
  97. }
  98. if (key_id == 3 || key_id == 'a') {
  99. - r |= delete_key(card, 3);
  100. + sc_format_path("A401", &path);
  101. + r |= sc_delete_file(card, &path);
  102. }
  103. return r;
  104. }
  105. --
  106. 2.1.3