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
9 src/tools/openpgp-tool.c | 64 ++++++------------------------------------------
10 1 file changed, 8 insertions(+), 56 deletions(-)
12 diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c
13 index 505abd9..a7796e7 100644
14 --- a/src/tools/openpgp-tool.c
15 +++ b/src/tools/openpgp-tool.c
16 @@ -468,38 +468,6 @@ int do_verify(sc_card_t *card, char *type, char *pin)
20 - * Delete key, for Gnuk.
22 -int delete_key_gnuk(sc_card_t *card, u8 key_id)
24 - sc_context_t *ctx = card->ctx;
28 - /* Delete fingerprint */
29 - fprintf(stdout, "Delete fingerprints");
30 - r |= sc_put_data(card, 0xC6 + key_id, NULL, 0);
31 - /* Delete creation time */
32 - fprintf(stdout, "Delete creation time");
33 - r |= sc_put_data(card, 0xCD + key_id, NULL, 0);
35 - /* Rewrite Extended Header List */
36 - fprintf(stdout, "Rewrite Extended Header List");
39 - data = "\x4D\x02\xB6";
40 - else if (key_id == 2)
41 - data = "\x4D\x02\xB8";
42 - else if (key_id == 3)
43 - data = "\x4D\x02\xA4";
45 - return SC_ERROR_INVALID_ARGUMENTS;
47 - r |= sc_put_data(card, 0x4D, data, strlen(data) + 1);
52 * Delete key, for OpenPGP card.
53 * This function is not complete and is reserved for future version (> 2) of OpenPGP card.
55 @@ -547,32 +515,13 @@ int delete_key_openpgp(sc_card_t *card, u8 key_id)
57 /* TODO: Rewrite Extended Header List.
58 * Not support by OpenGPG v2 yet */
59 - LOG_FUNC_RETURN(ctx, r);
62 -int delete_key(sc_card_t *card, u8 key_id)
64 - sc_context_t *ctx = card->ctx;
67 - LOG_FUNC_CALLED(ctx);
69 - if (key_id < 1 || key_id > 3) {
70 - fprintf(stderr, "Invalid key ID %d", key_id);
71 - LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
74 - if (card->type == SC_CARD_TYPE_OPENPGP_GNUK)
75 - r = delete_key_gnuk(card, key_id);
77 - r = delete_key_openpgp(card, key_id);
79 - LOG_FUNC_RETURN(ctx, r);
83 int do_delete_key(sc_card_t *card, u8 key_id)
85 sc_context_t *ctx = card->ctx;
89 /* Currently, only Gnuk supports deleting keys */
90 @@ -586,13 +535,16 @@ int do_delete_key(sc_card_t *card, u8 key_id)
91 return SC_ERROR_INVALID_ARGUMENTS;
93 if (key_id == 1 || key_id == 'a') {
94 - r |= delete_key(card, 1);
95 + sc_format_path("B601", &path);
96 + r |= sc_delete_file(card, &path);
98 if (key_id == 2 || key_id == 'a') {
99 - r |= delete_key(card, 2);
100 + sc_format_path("B801", &path);
101 + r |= sc_delete_file(card, &path);
103 if (key_id == 3 || key_id == 'a') {
104 - r |= delete_key(card, 3);
105 + sc_format_path("A401", &path);
106 + r |= sc_delete_file(card, &path);