summaryrefslogtreecommitdiffstats
path: root/utils/opensc/patches/0021-OpenPGP-Don-t-reimplement-gnuk_delete_key-in-openpgp.patch
blob: c84ef8e97dbe2b9b596b27c70c24572a19ed0c4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
From 0fdbf868976172486af210accafbab163452ff78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nguy=E1=BB=85n=20H=E1=BB=93ng=20Qu=C3=A2n?=
 <ng.hong.quan@gmail.com>
Date: Sun, 3 Nov 2013 11:26:25 +0800
Subject: [PATCH 21/26] OpenPGP: Don't reimplement gnuk_delete_key in
 openpgp-tool.

---
 src/tools/openpgp-tool.c | 64 ++++++------------------------------------------
 1 file changed, 8 insertions(+), 56 deletions(-)

Index: opensc-20150513/src/tools/openpgp-tool.c
===================================================================
--- opensc-20150513.orig/src/tools/openpgp-tool.c
+++ opensc-20150513/src/tools/openpgp-tool.c
@@ -468,38 +468,6 @@ int do_verify(sc_card_t *card, char *typ
 }
 
 /**
- * Delete key, for Gnuk.
- **/
-int delete_key_gnuk(sc_card_t *card, u8 key_id)
-{
-	sc_context_t *ctx = card->ctx;
-	int r = SC_SUCCESS;
-	u8 *data = NULL;
-
-	/* Delete fingerprint */
-	fprintf(stdout, "Delete fingerprints");
-	r |= sc_put_data(card, 0xC6 + key_id, NULL, 0);
-	/* Delete creation time */
-	fprintf(stdout, "Delete creation time");
-	r |= sc_put_data(card, 0xCD + key_id, NULL, 0);
-
-	/* Rewrite Extended Header List */
-	fprintf(stdout, "Rewrite Extended Header List");
-
-	if (key_id == 1)
-		data = "\x4D\x02\xB6";
-	else if (key_id == 2)
-		data = "\x4D\x02\xB8";
-	else if (key_id == 3)
-		data = "\x4D\x02\xA4";
-	else
-		return SC_ERROR_INVALID_ARGUMENTS;
-
-	r |= sc_put_data(card, 0x4D, data, strlen(data) + 1);
-	return r;
-}
-
-/**
  * Delete key, for OpenPGP card.
  * This function is not complete and is reserved for future version (> 2) of OpenPGP card.
  **/
@@ -547,32 +515,13 @@ int delete_key_openpgp(sc_card_t *card,
 	}
 	/* TODO: Rewrite Extended Header List.
 	 * Not support by OpenGPG v2 yet */
-	LOG_FUNC_RETURN(ctx, r);
-}
-
-int delete_key(sc_card_t *card, u8 key_id)
-{
-	sc_context_t *ctx = card->ctx;
-	int r;
-
-	LOG_FUNC_CALLED(ctx);
-	/* Check key ID */
-	if (key_id < 1 || key_id > 3) {
-		fprintf(stderr, "Invalid key ID %d", key_id);
-		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
-	}
-
-	if (card->type == SC_CARD_TYPE_OPENPGP_GNUK)
-		r = delete_key_gnuk(card, key_id);
-	else
-		r = delete_key_openpgp(card, key_id);
-
-	LOG_FUNC_RETURN(ctx, r);
+	return r;
 }
 
 int do_delete_key(sc_card_t *card, u8 key_id)
 {
 	sc_context_t *ctx = card->ctx;
+	sc_path_t path;
 	int r = SC_SUCCESS;
 
 	/* Currently, only Gnuk supports deleting keys */
@@ -586,13 +535,16 @@ int do_delete_key(sc_card_t *card, u8 ke
 		return SC_ERROR_INVALID_ARGUMENTS;
 	}
 	if (key_id == 1 || key_id == 'a') {
-		r |= delete_key(card, 1);
+		sc_format_path("B601", &path);
+		r |= sc_delete_file(card, &path);
 	}
 	if (key_id == 2 || key_id == 'a') {
-		r |= delete_key(card, 2);
+		sc_format_path("B801", &path);
+		r |= sc_delete_file(card, &path);
 	}
 	if (key_id == 3 || key_id == 'a') {
-		r |= delete_key(card, 3);
+		sc_format_path("A401", &path);
+		r |= sc_delete_file(card, &path);
 	}
 	return r;
 }