Browse Source

opensc: update source, refresh patches

Also import two new GnuK-related patches.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle 9 years ago
parent
commit
764c55e013
29 changed files with 361 additions and 303 deletions
  1. 2
    2
      utils/opensc/Makefile
  2. 30
    32
      utils/opensc/patches/0001-OpenPGP-Detect-and-support-Gnuk-Token.patch
  3. 11
    13
      utils/opensc/patches/0002-OpenPGP-Add-Gnuk-in-pkcs15-emulation-layer.patch
  4. 5
    7
      utils/opensc/patches/0003-OpenPGP-Include-private-DO-to-filesystem-at-driver-i.patch
  5. 8
    10
      utils/opensc/patches/0004-PKCS15-OpenPGP-Declare-DATA-objects.patch
  6. 14
    16
      utils/opensc/patches/0005-OpenPGP-Support-erasing-reset-card.patch
  7. 7
    9
      utils/opensc/patches/0006-openpgp-tool-Support-deleting-key-in-Gnuk.patch
  8. 5
    7
      utils/opensc/patches/0007-OpenPGP-Correct-building-Extended-Header-List-when-i.patch
  9. 6
    8
      utils/opensc/patches/0008-OpenPGP-Read-some-empty-DOs-from-Gnuk.patch
  10. 5
    7
      utils/opensc/patches/0009-PKCS15-OpenPGP-Do-not-show-empty-DO-in-pkcs15-emu_in.patch
  11. 11
    13
      utils/opensc/patches/0010-PKCS15-OpenPGP-Allow-to-store-data-to-pkcs15-data-ob.patch
  12. 8
    10
      utils/opensc/patches/0011-OpenPGP-Provide-enough-buffer-to-read-pubkey-from-Gn.patch
  13. 8
    10
      utils/opensc/patches/0012-OpenPGP-Support-write-certificate-for-Gnuk.patch
  14. 5
    7
      utils/opensc/patches/0013-pkcs15-openpgp-Change-to-sc_put_data-instead-of-sc_u.patch
  15. 6
    8
      utils/opensc/patches/0014-OpenPGP-Overcome-the-restriction-of-even-data-length.patch
  16. 7
    9
      utils/opensc/patches/0015-OpenPGP-Delete-key-as-file-for-Gnuk.patch
  17. 7
    9
      utils/opensc/patches/0016-OpenPGP-Correct-parameter-checking.patch
  18. 6
    8
      utils/opensc/patches/0017-OpenPGP-Make-code-neater.patch
  19. 6
    8
      utils/opensc/patches/0018-Move-declaration-to-top-of-block.patch
  20. 14
    16
      utils/opensc/patches/0019-OpenPGP-Make-indentation-consistent-space-tab.patch
  21. 8
    10
      utils/opensc/patches/0020-OpenPGP-Don-t-use-sc_log-in-openpgp-tool.patch
  22. 7
    9
      utils/opensc/patches/0021-OpenPGP-Don-t-reimplement-gnuk_delete_key-in-openpgp.patch
  23. 6
    8
      utils/opensc/patches/0022-OpenPGP-Use-directly-binary-array-of-APDUs-for-ERASE.patch
  24. 35
    37
      utils/opensc/patches/0023-OpenPGP-Rename-private-blob-type-to-avoid-confusing-.patch
  25. 7
    9
      utils/opensc/patches/0024-OpenPGP-Fix-crash-after-accessing-inexistent-file.patch
  26. 10
    12
      utils/opensc/patches/0025-Replace-hardcode.patch
  27. 7
    9
      utils/opensc/patches/0026-hardcode-defines-for-DO-s.patch
  28. 82
    0
      utils/opensc/patches/0027-OpenPGP-Remove-unused-variables-and-fix-type-cast.patch
  29. 28
    0
      utils/opensc/patches/0028-openpgp-tool-Fix-wrong-operator.patch

+ 2
- 2
utils/opensc/Makefile View File

@@ -8,7 +8,7 @@
8 8
 include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=opensc
11
-PKG_VERSION:=20141126
11
+PKG_VERSION:=20150513
12 12
 PKG_RELEASE:=1
13 13
 PKG_LICENSE:=LGPL-2.1+
14 14
 PKG_LICENSE_FILES:=COPYING
@@ -19,7 +19,7 @@ PKG_RELEASE=$(PKG_SOURCE_VERSION)
19 19
 PKG_SOURCE_PROTO:=git
20 20
 PKG_SOURCE_URL:=https://github.com/OpenSC/OpenSC.git
21 21
 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
22
-PKG_SOURCE_VERSION:=8aadbbd678730dbafb819382da553439887499fd
22
+PKG_SOURCE_VERSION:=a09ca246a797230c14bc33a34f2dddc4a4dbff40
23 23
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
24 24
 PKG_BUILD_DEPENDS:=+libpcsclite
25 25
 PKG_FIXUP:=libtool

+ 30
- 32
utils/opensc/patches/0001-OpenPGP-Detect-and-support-Gnuk-Token.patch View File

@@ -11,11 +11,11 @@ http://www.fsij.org/gnuk/
11 11
  src/tools/openpgp-tool.c     |  7 ++++-
12 12
  3 files changed, 55 insertions(+), 14 deletions(-)
13 13
 
14
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
15
-index 6774fe1..c785a55 100644
16
---- a/src/libopensc/card-openpgp.c
17
-+++ b/src/libopensc/card-openpgp.c
18
-@@ -43,6 +43,7 @@
14
+Index: opensc-20150513/src/libopensc/card-openpgp.c
15
+===================================================================
16
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
17
++++ opensc-20150513/src/libopensc/card-openpgp.c
18
+@@ -45,6 +45,7 @@
19 19
  static struct sc_atr_table pgp_atrs[] = {
20 20
  	{ "3b:fa:13:00:ff:81:31:80:45:00:31:c1:73:c0:01:00:00:90:00:b1", NULL, "OpenPGP card v1.0/1.1", SC_CARD_TYPE_OPENPGP_V1, 0, NULL },
21 21
  	{ "3b:da:18:ff:81:b1:fe:75:1f:03:00:31:c5:73:c0:01:40:00:90:00:0c", NULL, "CryptoStick v1.2 (OpenPGP v2.0)", SC_CARD_TYPE_OPENPGP_V2, 0, NULL },
@@ -23,16 +23,16 @@ index 6774fe1..c785a55 100644
23 23
  	{ NULL, NULL, NULL, 0, 0, NULL }
24 24
  };
25 25
  
26
-@@ -307,6 +308,8 @@ pgp_init(sc_card_t *card)
26
+@@ -309,6 +310,8 @@ pgp_init(sc_card_t *card)
27 27
  	int		r;
28
- 	struct blob 	*child = NULL;
28
+ 	struct blob	*child = NULL;
29 29
  
30 30
 +	LOG_FUNC_CALLED(card->ctx);
31 31
 +
32 32
  	priv = calloc (1, sizeof *priv);
33 33
  	if (!priv)
34 34
  		return SC_ERROR_OUT_OF_MEMORY;
35
-@@ -315,11 +318,11 @@ pgp_init(sc_card_t *card)
35
+@@ -317,11 +320,11 @@ pgp_init(sc_card_t *card)
36 36
  	card->cla = 0x00;
37 37
  
38 38
  	/* set pointer to correct list of card objects */
@@ -46,7 +46,7 @@ index 6774fe1..c785a55 100644
46 46
  				? OPENPGP_CARD_2_0 : OPENPGP_CARD_1_1;
47 47
  
48 48
  	/* select application "OpenPGP" */
49
-@@ -428,7 +431,8 @@ pgp_get_card_features(sc_card_t *card)
49
+@@ -436,7 +439,8 @@ pgp_get_card_features(sc_card_t *card)
50 50
  		if ((pgp_get_blob(card, blob73, 0x00c0, &blob) >= 0) &&
51 51
  		    (blob->data != NULL) && (blob->len > 0)) {
52 52
  			/* in v2.0 bit 0x04 in first byte means "algorithm attributes changeable */
@@ -56,7 +56,7 @@ index 6774fe1..c785a55 100644
56 56
  				priv->ext_caps |= EXT_CAP_ALG_ATTR_CHANGEABLE;
57 57
  			/* bit 0x08 in first byte means "support for private use DOs" */
58 58
  			if (blob->data[0] & 0x08)
59
-@@ -445,7 +449,8 @@ pgp_get_card_features(sc_card_t *card)
59
+@@ -453,7 +457,8 @@ pgp_get_card_features(sc_card_t *card)
60 60
  				priv->ext_caps |= EXT_CAP_GET_CHALLENGE;
61 61
  			}
62 62
  			/* in v2.0 bit 0x80 in first byte means "support Secure Messaging" */
@@ -66,7 +66,7 @@ index 6774fe1..c785a55 100644
66 66
  				priv->ext_caps |= EXT_CAP_SM;
67 67
  
68 68
  			if ((priv->bcd_version >= OPENPGP_CARD_2_0) && (blob->len >= 10)) {
69
-@@ -1057,12 +1062,18 @@ static int
69
+@@ -1065,12 +1070,18 @@ static int
70 70
  pgp_get_pubkey(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len)
71 71
  {
72 72
  	sc_apdu_t	apdu;
@@ -86,7 +86,7 @@ index 6774fe1..c785a55 100644
86 86
  	apdu.lc = 2;
87 87
  	apdu.data = ushort2bebytes(idbuf, tag);
88 88
  	apdu.datalen = 2;
89
-@@ -1154,6 +1165,7 @@ pgp_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t buf_len)
89
+@@ -1162,6 +1173,7 @@ pgp_put_data(sc_card_t *card, unsigned i
90 90
  	u8 ins = 0xDA;
91 91
  	u8 p1 = tag >> 8;
92 92
  	u8 p2 = tag & 0xFF;
@@ -94,7 +94,7 @@ index 6774fe1..c785a55 100644
94 94
  	int r;
95 95
  
96 96
  	LOG_FUNC_CALLED(card->ctx);
97
-@@ -1195,13 +1207,17 @@ pgp_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t buf_len)
97
+@@ -1203,13 +1215,17 @@ pgp_put_data(sc_card_t *card, unsigned i
98 98
  
99 99
  	/* Build APDU */
100 100
  	if (buf != NULL && buf_len > 0) {
@@ -114,7 +114,7 @@ index 6774fe1..c785a55 100644
114 114
  		apdu.datalen = buf_len;
115 115
  		apdu.lc = buf_len;
116 116
  	}
117
-@@ -1328,6 +1344,7 @@ pgp_compute_signature(sc_card_t *card, const u8 *data,
117
+@@ -1336,6 +1352,7 @@ pgp_compute_signature(sc_card_t *card, c
118 118
  	struct pgp_priv_data	*priv = DRVDATA(card);
119 119
  	sc_security_env_t	*env = &priv->sec_env;
120 120
  	sc_apdu_t		apdu;
@@ -122,7 +122,7 @@ index 6774fe1..c785a55 100644
122 122
  	int			r;
123 123
  
124 124
  	LOG_FUNC_CALLED(card->ctx);
125
-@@ -1336,14 +1353,19 @@ pgp_compute_signature(sc_card_t *card, const u8 *data,
125
+@@ -1344,14 +1361,19 @@ pgp_compute_signature(sc_card_t *card, c
126 126
  		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
127 127
  				"invalid operation");
128 128
  
@@ -144,7 +144,7 @@ index 6774fe1..c785a55 100644
144 144
  		break;
145 145
  	case 0x01:
146 146
  	default:
147
-@@ -1352,7 +1374,7 @@ pgp_compute_signature(sc_card_t *card, const u8 *data,
147
+@@ -1360,7 +1382,7 @@ pgp_compute_signature(sc_card_t *card, c
148 148
  	}
149 149
  
150 150
  	apdu.lc = data_len;
@@ -153,7 +153,7 @@ index 6774fe1..c785a55 100644
153 153
  	apdu.datalen = data_len;
154 154
  	apdu.le = ((outlen >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : outlen;
155 155
  	apdu.resp    = out;
156
-@@ -1376,6 +1398,7 @@ pgp_decipher(sc_card_t *card, const u8 *in, size_t inlen,
156
+@@ -1384,6 +1406,7 @@ pgp_decipher(sc_card_t *card, const u8 *
157 157
  	struct pgp_priv_data	*priv = DRVDATA(card);
158 158
  	sc_security_env_t	*env = &priv->sec_env;
159 159
  	sc_apdu_t	apdu;
@@ -161,7 +161,7 @@ index 6774fe1..c785a55 100644
161 161
  	u8		*temp = NULL;
162 162
  	int		r;
163 163
  
164
-@@ -1400,7 +1423,7 @@ pgp_decipher(sc_card_t *card, const u8 *in, size_t inlen,
164
+@@ -1408,7 +1431,7 @@ pgp_decipher(sc_card_t *card, const u8 *
165 165
  	case 0x01: /* Decryption key */
166 166
  	case 0x02: /* authentication key */
167 167
  		/* PSO DECIPHER */
@@ -170,7 +170,7 @@ index 6774fe1..c785a55 100644
170 170
  		break;
171 171
  	case 0x00: /* signature key */
172 172
  	default:
173
-@@ -1409,8 +1432,13 @@ pgp_decipher(sc_card_t *card, const u8 *in, size_t inlen,
173
+@@ -1417,8 +1440,13 @@ pgp_decipher(sc_card_t *card, const u8 *
174 174
  				"invalid key reference");
175 175
  	}
176 176
  
@@ -185,7 +185,7 @@ index 6774fe1..c785a55 100644
185 185
  	apdu.datalen = inlen;
186 186
  	apdu.le = ((outlen >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : outlen;
187 187
  	apdu.resp = out;
188
-@@ -1794,6 +1822,11 @@ static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_in
188
+@@ -1802,6 +1830,11 @@ static int pgp_gen_key(sc_card_t *card,
189 189
  		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
190 190
  	}
191 191
  
@@ -197,7 +197,7 @@ index 6774fe1..c785a55 100644
197 197
  	/* Set attributes for new-generated key */
198 198
  	r = pgp_update_new_algo_attr(card, key_info);
199 199
  	LOG_TEST_RET(card->ctx, r, "Cannot set attributes for new-generated key");
200
-@@ -1801,7 +1834,9 @@ static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_in
200
+@@ -1809,7 +1842,9 @@ static int pgp_gen_key(sc_card_t *card,
201 201
  	/* Test whether we will need extended APDU. 1900 is an
202 202
  	 * arbitrary modulus length which for sure fits into a short APDU.
203 203
  	 * This idea is borrowed from GnuPG code.  */
@@ -208,10 +208,10 @@ index 6774fe1..c785a55 100644
208 208
  		/* We won't store to apdu variable yet, because it will be reset in
209 209
  		 * sc_format_apdu() */
210 210
  		apdu_le = card->max_recv_size;
211
-diff --git a/src/libopensc/cards.h b/src/libopensc/cards.h
212
-index 7be6667..a3f3634 100644
213
---- a/src/libopensc/cards.h
214
-+++ b/src/libopensc/cards.h
211
+Index: opensc-20150513/src/libopensc/cards.h
212
+===================================================================
213
+--- opensc-20150513.orig/src/libopensc/cards.h
214
++++ opensc-20150513/src/libopensc/cards.h
215 215
 @@ -105,6 +105,7 @@ enum {
216 216
  	SC_CARD_TYPE_OPENPGP_BASE = 9000,
217 217
  	SC_CARD_TYPE_OPENPGP_V1,
@@ -220,10 +220,10 @@ index 7be6667..a3f3634 100644
220 220
  
221 221
  	/* jcop driver */
222 222
  	SC_CARD_TYPE_JCOP_BASE = 10000,
223
-diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c
224
-index f42e6d6..a24a395 100644
225
---- a/src/tools/openpgp-tool.c
226
-+++ b/src/tools/openpgp-tool.c
223
+Index: opensc-20150513/src/tools/openpgp-tool.c
224
+===================================================================
225
+--- opensc-20150513.orig/src/tools/openpgp-tool.c
226
++++ opensc-20150513/src/tools/openpgp-tool.c
227 227
 @@ -33,6 +33,7 @@
228 228
  #include "libopensc/cards.h"
229 229
  #include "libopensc/cardctl.h"
@@ -232,7 +232,7 @@ index f42e6d6..a24a395 100644
232 232
  #include "util.h"
233 233
  #include "libopensc/log.h"
234 234
  
235
-@@ -396,6 +397,8 @@ int do_genkey(sc_card_t *card, u8 key_id, unsigned int key_len)
235
+@@ -396,6 +397,8 @@ int do_genkey(sc_card_t *card, u8 key_id
236 236
  	sc_path_t path;
237 237
  	sc_file_t *file;
238 238
  
@@ -253,6 +253,3 @@ index f42e6d6..a24a395 100644
253 253
  		exit_status = EXIT_FAILURE;
254 254
  		goto out;
255 255
  	}
256
-2.1.3
257
-

+ 11
- 13
utils/opensc/patches/0002-OpenPGP-Add-Gnuk-in-pkcs15-emulation-layer.patch View File

@@ -9,11 +9,11 @@ Subject: [PATCH 02/26] OpenPGP: Add Gnuk in pkcs15 emulation layer.
9 9
  src/libopensc/pkcs15-syn.c     | 1 +
10 10
  2 files changed, 5 insertions(+), 2 deletions(-)
11 11
 
12
-diff --git a/src/libopensc/pkcs15-openpgp.c b/src/libopensc/pkcs15-openpgp.c
13
-index 4daaa98..fdf720a 100644
14
---- a/src/libopensc/pkcs15-openpgp.c
15
-+++ b/src/libopensc/pkcs15-openpgp.c
16
-@@ -151,7 +151,8 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
12
+Index: opensc-20150513/src/libopensc/pkcs15-openpgp.c
13
+===================================================================
14
+--- opensc-20150513.orig/src/libopensc/pkcs15-openpgp.c
15
++++ opensc-20150513/src/libopensc/pkcs15-openpgp.c
16
+@@ -153,7 +153,8 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card
17 17
  	u8		c4data[10];
18 18
  	u8		c5data[70];
19 19
  	int		r, i;
@@ -23,7 +23,7 @@ index 4daaa98..fdf720a 100644
23 23
  	sc_path_t path;
24 24
  	sc_file_t *file;
25 25
  
26
-@@ -363,7 +364,8 @@ failed:	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Failed to initialize OpenPGP e
26
+@@ -365,7 +366,8 @@ failed:	sc_debug(card->ctx, SC_LOG_DEBUG
27 27
  
28 28
  static int openpgp_detect_card(sc_pkcs15_card_t *p15card)
29 29
  {
@@ -33,11 +33,11 @@ index 4daaa98..fdf720a 100644
33 33
  		return SC_SUCCESS;
34 34
  	else
35 35
  		return SC_ERROR_WRONG_CARD;
36
-diff --git a/src/libopensc/pkcs15-syn.c b/src/libopensc/pkcs15-syn.c
37
-index ffbf642..d2c086c 100644
38
---- a/src/libopensc/pkcs15-syn.c
39
-+++ b/src/libopensc/pkcs15-syn.c
40
-@@ -115,6 +115,7 @@ int sc_pkcs15_is_emulation_only(sc_card_t *card)
36
+Index: opensc-20150513/src/libopensc/pkcs15-syn.c
37
+===================================================================
38
+--- opensc-20150513.orig/src/libopensc/pkcs15-syn.c
39
++++ opensc-20150513/src/libopensc/pkcs15-syn.c
40
+@@ -117,6 +117,7 @@ int sc_pkcs15_is_emulation_only(sc_card_
41 41
  		case SC_CARD_TYPE_GEMSAFEV1_PTEID:
42 42
  		case SC_CARD_TYPE_OPENPGP_V1:
43 43
  		case SC_CARD_TYPE_OPENPGP_V2:
@@ -45,6 +45,3 @@ index ffbf642..d2c086c 100644
45 45
  		case SC_CARD_TYPE_SC_HSM:
46 46
  		case SC_CARD_TYPE_DNIE_BASE:
47 47
  		case SC_CARD_TYPE_DNIE_BLANK:
48
-2.1.3
49
-

+ 5
- 7
utils/opensc/patches/0003-OpenPGP-Include-private-DO-to-filesystem-at-driver-i.patch View File

@@ -12,11 +12,11 @@ leading to that we cannot read their data later, even if we verified PIN.
12 12
  src/libopensc/card-openpgp.c | 2 +-
13 13
  1 file changed, 1 insertion(+), 1 deletion(-)
14 14
 
15
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
16
-index c785a55..1cc3923 100644
17
---- a/src/libopensc/card-openpgp.c
18
-+++ b/src/libopensc/card-openpgp.c
19
-@@ -357,7 +357,7 @@ pgp_init(sc_card_t *card)
15
+Index: opensc-20150513/src/libopensc/card-openpgp.c
16
+===================================================================
17
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
18
++++ opensc-20150513/src/libopensc/card-openpgp.c
19
+@@ -365,7 +365,7 @@ pgp_init(sc_card_t *card)
20 20
  
21 21
  	/* Populate MF - add matching blobs listed in the pgp_objects table. */
22 22
  	for (info = priv->pgp_objects; (info != NULL) && (info->id > 0); info++) {
@@ -25,6 +25,3 @@ index c785a55..1cc3923 100644
25 25
  		    (info->get_fn != NULL)) {
26 26
  			child = pgp_new_blob(card, priv->mf, info->id, sc_file_new());
27 27
  
28
-2.1.3
29
-

+ 8
- 10
utils/opensc/patches/0004-PKCS15-OpenPGP-Declare-DATA-objects.patch View File

@@ -10,11 +10,11 @@ This object is used by TrueCrypt.
10 10
  src/libopensc/pkcs15-openpgp.c | 35 +++++++++++++++++++++++++++++++++++
11 11
  1 file changed, 35 insertions(+)
12 12
 
13
-diff --git a/src/libopensc/pkcs15-openpgp.c b/src/libopensc/pkcs15-openpgp.c
14
-index fdf720a..fea2805 100644
15
---- a/src/libopensc/pkcs15-openpgp.c
16
-+++ b/src/libopensc/pkcs15-openpgp.c
17
-@@ -32,6 +32,7 @@
13
+Index: opensc-20150513/src/libopensc/pkcs15-openpgp.c
14
+===================================================================
15
+--- opensc-20150513.orig/src/libopensc/pkcs15-openpgp.c
16
++++ opensc-20150513/src/libopensc/pkcs15-openpgp.c
17
+@@ -34,6 +34,7 @@
18 18
  #include "log.h"
19 19
  
20 20
  int sc_pkcs15emu_openpgp_init_ex(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *);
@@ -22,7 +22,7 @@ index fdf720a..fea2805 100644
22 22
  
23 23
  
24 24
  #define	PGP_USER_PIN_FLAGS	(SC_PKCS15_PIN_FLAG_CASE_SENSITIVE \
25
-@@ -41,6 +42,8 @@ int sc_pkcs15emu_openpgp_init_ex(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *);
25
+@@ -43,6 +44,8 @@ int sc_pkcs15emu_openpgp_init_ex(sc_pkcs
26 26
  				| SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED \
27 27
  				| SC_PKCS15_PIN_FLAG_SO_PIN)
28 28
  
@@ -31,7 +31,7 @@ index fdf720a..fea2805 100644
31 31
  typedef struct _pgp_pin_cfg {
32 32
  	const char	*label;
33 33
  	int		reference;
34
-@@ -355,6 +358,9 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
34
+@@ -357,6 +360,9 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card
35 35
  			goto failed;
36 36
  	}
37 37
  
@@ -41,7 +41,7 @@ index fdf720a..fea2805 100644
41 41
  	return 0;
42 42
  
43 43
  failed:	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Failed to initialize OpenPGP emulation: %s\n",
44
-@@ -362,6 +368,35 @@ failed:	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Failed to initialize OpenPGP e
44
+@@ -364,6 +370,35 @@ failed:	sc_debug(card->ctx, SC_LOG_DEBUG
45 45
  	return r;
46 46
  }
47 47
  
@@ -77,6 +77,3 @@ index fdf720a..fea2805 100644
77 77
  static int openpgp_detect_card(sc_pkcs15_card_t *p15card)
78 78
  {
79 79
  	if (p15card->card->type == SC_CARD_TYPE_OPENPGP_V1 || p15card->card->type == SC_CARD_TYPE_OPENPGP_V2
80
-2.1.3
81
-

+ 14
- 16
utils/opensc/patches/0005-OpenPGP-Support-erasing-reset-card.patch View File

@@ -10,11 +10,11 @@ Command: openpgp-tool --erase
10 10
  src/tools/openpgp-tool.c     | 22 ++++++++++++++-
11 11
  2 files changed, 85 insertions(+), 1 deletion(-)
12 12
 
13
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
14
-index 1cc3923..7349876 100644
15
---- a/src/libopensc/card-openpgp.c
16
-+++ b/src/libopensc/card-openpgp.c
17
-@@ -2195,6 +2195,66 @@ out:
13
+Index: opensc-20150513/src/libopensc/card-openpgp.c
14
+===================================================================
15
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
16
++++ opensc-20150513/src/libopensc/card-openpgp.c
17
+@@ -2206,6 +2206,66 @@ out:
18 18
  
19 19
  #endif /* ENABLE_OPENSSL */
20 20
  
@@ -81,7 +81,7 @@ index 1cc3923..7349876 100644
81 81
  /* ABI: card ctl: perform special card-specific operations */
82 82
  static int pgp_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr)
83 83
  {
84
-@@ -2219,6 +2279,10 @@ static int pgp_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr)
84
+@@ -2232,6 +2292,10 @@ static int pgp_card_ctl(sc_card_t *card,
85 85
  		LOG_FUNC_RETURN(card->ctx, r);
86 86
  		break;
87 87
  #endif /* ENABLE_OPENSSL */
@@ -92,12 +92,12 @@ index 1cc3923..7349876 100644
92 92
  	}
93 93
  
94 94
  	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
95
-diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c
96
-index a24a395..de1c9d4 100644
97
---- a/src/tools/openpgp-tool.c
98
-+++ b/src/tools/openpgp-tool.c
95
+Index: opensc-20150513/src/tools/openpgp-tool.c
96
+===================================================================
97
+--- opensc-20150513.orig/src/tools/openpgp-tool.c
98
++++ opensc-20150513/src/tools/openpgp-tool.c
99 99
 @@ -78,6 +78,7 @@ static int opt_pin = 0;
100
- static char *pin = NULL;
100
+ static const char *pin = NULL;
101 101
  static int opt_dump_do = 0;
102 102
  static u8 do_dump_idx;
103 103
 +static int opt_erase = 0;
@@ -120,7 +120,7 @@ index a24a395..de1c9d4 100644
120 120
  	"Verify PIN (CHV1, CHV2, CHV3...)",
121 121
  	"PIN string",
122 122
  /* d */ "Dump private data object number <arg> (i.e. PRIVATE-DO-<arg>)"
123
-@@ -232,7 +235,7 @@ static int decode_options(int argc, char **argv)
123
+@@ -232,7 +235,7 @@ static int decode_options(int argc, char
124 124
  {
125 125
  	int c;
126 126
  
@@ -129,7 +129,7 @@ index a24a395..de1c9d4 100644
129 129
  		switch (c) {
130 130
  		case 'r':
131 131
  			opt_reader = optarg;
132
-@@ -296,6 +299,8 @@ static int decode_options(int argc, char **argv)
132
+@@ -294,6 +297,8 @@ static int decode_options(int argc, char
133 133
  			do_dump_idx = optarg[0] - '0';
134 134
  			opt_dump_do++;
135 135
  			actions++;
@@ -138,7 +138,7 @@ index a24a395..de1c9d4 100644
138 138
  			break;
139 139
  		default:
140 140
  			util_print_usage_and_die(app_name, options, option_help, NULL);
141
-@@ -452,6 +457,18 @@ int do_verify(sc_card_t *card, char *type, char *pin)
141
+@@ -452,6 +457,18 @@ int do_verify(sc_card_t *card, char *typ
142 142
  	return r;
143 143
  }
144 144
  
@@ -167,6 +167,3 @@ index a24a395..de1c9d4 100644
167 167
  out:
168 168
  	sc_unlock(card);
169 169
  	sc_disconnect_card(card);
170
-2.1.3
171
-

+ 7
- 9
utils/opensc/patches/0006-openpgp-tool-Support-deleting-key-in-Gnuk.patch View File

@@ -8,10 +8,10 @@ Subject: [PATCH 06/26] openpgp-tool: Support deleting key in Gnuk.
8 8
  src/tools/openpgp-tool.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++
9 9
  1 file changed, 142 insertions(+)
10 10
 
11
-diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c
12
-index de1c9d4..374819a 100644
13
---- a/src/tools/openpgp-tool.c
14
-+++ b/src/tools/openpgp-tool.c
11
+Index: opensc-20150513/src/tools/openpgp-tool.c
12
+===================================================================
13
+--- opensc-20150513.orig/src/tools/openpgp-tool.c
14
++++ opensc-20150513/src/tools/openpgp-tool.c
15 15
 @@ -41,6 +41,7 @@
16 16
  #define	OPT_PRETTY	257
17 17
  #define	OPT_VERIFY	258
@@ -20,7 +20,7 @@ index de1c9d4..374819a 100644
20 20
  
21 21
  /* define structures */
22 22
  struct ef_name_map {
23
-@@ -79,6 +80,7 @@ static char *pin = NULL;
23
+@@ -79,6 +80,7 @@ static const char *pin = NULL;
24 24
  static int opt_dump_do = 0;
25 25
  static u8 do_dump_idx;
26 26
  static int opt_erase = 0;
@@ -44,7 +44,7 @@ index de1c9d4..374819a 100644
44 44
  /* d */ "Dump private data object number <arg> (i.e. PRIVATE-DO-<arg>)"
45 45
  };
46 46
  
47
-@@ -302,6 +306,14 @@ static int decode_options(int argc, char **argv)
47
+@@ -300,6 +304,14 @@ static int decode_options(int argc, char
48 48
  		case 'E':
49 49
  			opt_erase++;
50 50
  			break;
@@ -59,7 +59,7 @@ index de1c9d4..374819a 100644
59 59
  		default:
60 60
  			util_print_usage_and_die(app_name, options, option_help, NULL);
61 61
  		}
62
-@@ -457,6 +469,133 @@ int do_verify(sc_card_t *card, char *type, char *pin)
62
+@@ -457,6 +469,133 @@ int do_verify(sc_card_t *card, char *typ
63 63
  	return r;
64 64
  }
65 65
  
@@ -203,6 +203,3 @@ index de1c9d4..374819a 100644
203 203
  	if (opt_erase)
204 204
  		exit_status != do_erase(card);
205 205
  
206
-2.1.3
207
-

+ 5
- 7
utils/opensc/patches/0007-OpenPGP-Correct-building-Extended-Header-List-when-i.patch View File

@@ -9,11 +9,11 @@ Subject: [PATCH 07/26] OpenPGP: Correct building Extended Header List when
9 9
  src/libopensc/card-openpgp.c | 2 +-
10 10
  1 file changed, 1 insertion(+), 1 deletion(-)
11 11
 
12
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
13
-index 7349876..91c311b 100644
14
---- a/src/libopensc/card-openpgp.c
15
-+++ b/src/libopensc/card-openpgp.c
16
-@@ -1977,7 +1977,7 @@ pgp_build_extended_header_list(sc_card_t *card, sc_cardctl_openpgp_keystore_info
12
+Index: opensc-20150513/src/libopensc/card-openpgp.c
13
+===================================================================
14
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
15
++++ opensc-20150513/src/libopensc/card-openpgp.c
16
+@@ -1988,7 +1988,7 @@ pgp_build_extended_header_list(sc_card_t
17 17
  	u8 *p = NULL;
18 18
  	u8 *components[] = {key_info->e, key_info->p, key_info->q, key_info->n};
19 19
  	size_t componentlens[] = {key_info->e_len, key_info->p_len, key_info->q_len, key_info->n_len};
@@ -22,6 +22,3 @@ index 7349876..91c311b 100644
22 22
  	char *componentnames[] = {
23 23
  		"public exponent",
24 24
  		"prime p",
25
-2.1.3
26
-

+ 6
- 8
utils/opensc/patches/0008-OpenPGP-Read-some-empty-DOs-from-Gnuk.patch View File

@@ -10,11 +10,11 @@ So, we will consider them exist in driver.
10 10
  src/libopensc/card-openpgp.c | 25 +++++++++++++++++++++++++
11 11
  1 file changed, 25 insertions(+)
12 12
 
13
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
14
-index 91c311b..e7b25c0 100644
15
---- a/src/libopensc/card-openpgp.c
16
-+++ b/src/libopensc/card-openpgp.c
17
-@@ -815,6 +815,23 @@ pgp_get_blob(sc_card_t *card, struct blob *blob, unsigned int id,
13
+Index: opensc-20150513/src/libopensc/card-openpgp.c
14
+===================================================================
15
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
16
++++ opensc-20150513/src/libopensc/card-openpgp.c
17
+@@ -823,6 +823,23 @@ pgp_get_blob(sc_card_t *card, struct blo
18 18
  		}
19 19
  	}
20 20
  
@@ -38,7 +38,7 @@ index 91c311b..e7b25c0 100644
38 38
  	return SC_ERROR_FILE_NOT_FOUND;
39 39
  }
40 40
  
41
-@@ -1149,6 +1166,14 @@ pgp_get_data(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len)
41
+@@ -1157,6 +1174,14 @@ pgp_get_data(sc_card_t *card, unsigned i
42 42
  	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
43 43
  
44 44
  	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
@@ -53,6 +53,3 @@ index 91c311b..e7b25c0 100644
53 53
  	LOG_TEST_RET(card->ctx, r, "Card returned error");
54 54
  
55 55
  	LOG_FUNC_RETURN(card->ctx, apdu.resplen);
56
-2.1.3
57
-

+ 5
- 7
utils/opensc/patches/0009-PKCS15-OpenPGP-Do-not-show-empty-DO-in-pkcs15-emu_in.patch View File

@@ -9,11 +9,11 @@ Subject: [PATCH 09/26] PKCS15-OpenPGP: Do not show empty DO in pkcs15
9 9
  src/libopensc/pkcs15-openpgp.c | 18 ++++++++++++++++++
10 10
  1 file changed, 18 insertions(+)
11 11
 
12
-diff --git a/src/libopensc/pkcs15-openpgp.c b/src/libopensc/pkcs15-openpgp.c
13
-index fea2805..51a2032 100644
14
---- a/src/libopensc/pkcs15-openpgp.c
15
-+++ b/src/libopensc/pkcs15-openpgp.c
16
-@@ -381,16 +381,34 @@ sc_pkcs15emu_openpgp_add_data(sc_pkcs15_card_t *p15card)
12
+Index: opensc-20150513/src/libopensc/pkcs15-openpgp.c
13
+===================================================================
14
+--- opensc-20150513.orig/src/libopensc/pkcs15-openpgp.c
15
++++ opensc-20150513/src/libopensc/pkcs15-openpgp.c
16
+@@ -383,16 +383,34 @@ sc_pkcs15emu_openpgp_add_data(sc_pkcs15_
17 17
  		sc_pkcs15_object_t dat_obj;
18 18
  		char name[8];
19 19
  		char path[9];
@@ -48,6 +48,3 @@ index fea2805..51a2032 100644
48 48
  		sc_log(ctx, "Add %s data object", name);
49 49
  		r = sc_pkcs15emu_add_data_object(p15card, &dat_obj, &dat_info);
50 50
  	}
51
-2.1.3
52
-

+ 11
- 13
utils/opensc/patches/0010-PKCS15-OpenPGP-Allow-to-store-data-to-pkcs15-data-ob.patch View File

@@ -11,11 +11,11 @@ Only one DO is supported now.
11 11
  src/pkcs15init/pkcs15-openpgp.c | 38 +++++++++++++++++++++++++++++++++++++-
12 12
  2 files changed, 38 insertions(+), 2 deletions(-)
13 13
 
14
-diff --git a/src/libopensc/pkcs15-openpgp.c b/src/libopensc/pkcs15-openpgp.c
15
-index 51a2032..4cc1c39 100644
16
---- a/src/libopensc/pkcs15-openpgp.c
17
-+++ b/src/libopensc/pkcs15-openpgp.c
18
-@@ -393,7 +393,7 @@ sc_pkcs15emu_openpgp_add_data(sc_pkcs15_card_t *p15card)
14
+Index: opensc-20150513/src/libopensc/pkcs15-openpgp.c
15
+===================================================================
16
+--- opensc-20150513.orig/src/libopensc/pkcs15-openpgp.c
17
++++ opensc-20150513/src/libopensc/pkcs15-openpgp.c
18
+@@ -395,7 +395,7 @@ sc_pkcs15emu_openpgp_add_data(sc_pkcs15_
19 19
  		 */
20 20
  		r = read_file(p15card->card, path, content, sizeof(content));
21 21
  		if (r <= 0 ) {
@@ -24,11 +24,11 @@ index 51a2032..4cc1c39 100644
24 24
  			/* Skip */
25 25
  			continue;
26 26
  		}
27
-diff --git a/src/pkcs15init/pkcs15-openpgp.c b/src/pkcs15init/pkcs15-openpgp.c
28
-index f3a4962..1455580 100755
29
---- a/src/pkcs15init/pkcs15-openpgp.c
30
-+++ b/src/pkcs15init/pkcs15-openpgp.c
31
-@@ -236,13 +236,16 @@ static int openpgp_emu_update_tokeninfo(sc_profile_t *profile, sc_pkcs15_card_t
27
+Index: opensc-20150513/src/pkcs15init/pkcs15-openpgp.c
28
+===================================================================
29
+--- opensc-20150513.orig/src/pkcs15init/pkcs15-openpgp.c
30
++++ opensc-20150513/src/pkcs15init/pkcs15-openpgp.c
31
+@@ -236,13 +236,16 @@ static int openpgp_emu_update_tokeninfo(
32 32
  }
33 33
  
34 34
  static int openpgp_store_data(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
@@ -46,7 +46,7 @@ index f3a4962..1455580 100755
46 46
  	int r;
47 47
  
48 48
  	LOG_FUNC_CALLED(card->ctx);
49
-@@ -282,6 +285,39 @@ static int openpgp_store_data(struct sc_pkcs15_card *p15card, struct sc_profile
49
+@@ -282,6 +285,39 @@ static int openpgp_store_data(struct sc_
50 50
  			                     content->len, 0);
51 51
  		break;
52 52
  
@@ -86,6 +86,3 @@ index f3a4962..1455580 100755
86 86
  	default:
87 87
  		r = SC_ERROR_NOT_IMPLEMENTED;
88 88
  	}
89
-2.1.3
90
-

+ 8
- 10
utils/opensc/patches/0011-OpenPGP-Provide-enough-buffer-to-read-pubkey-from-Gn.patch View File

@@ -9,11 +9,11 @@ Subject: [PATCH 11/26] OpenPGP: Provide enough buffer to read pubkey from
9 9
  src/libopensc/card-openpgp.c | 28 +++++++++++++++++++++++-----
10 10
  1 file changed, 23 insertions(+), 5 deletions(-)
11 11
 
12
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
13
-index e7b25c0..1913eca 100644
14
---- a/src/libopensc/card-openpgp.c
15
-+++ b/src/libopensc/card-openpgp.c
16
-@@ -263,7 +263,12 @@ static struct do_info		pgp2_objects[] = {	/* OpenPGP card spec 2.0 */
12
+Index: opensc-20150513/src/libopensc/card-openpgp.c
13
+===================================================================
14
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
15
++++ opensc-20150513/src/libopensc/card-openpgp.c
16
+@@ -265,7 +265,12 @@ static struct do_info		pgp2_objects[] =
17 17
  
18 18
  /* The DO holding X.509 certificate is constructed but does not contain child DO.
19 19
   * We should notice this when building fake file system later. */
@@ -27,7 +27,7 @@ index e7b25c0..1913eca 100644
27 27
  
28 28
  #define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
29 29
  struct pgp_priv_data {
30
-@@ -731,6 +736,14 @@ pgp_read_blob(sc_card_t *card, struct blob *blob)
30
+@@ -739,6 +744,14 @@ pgp_read_blob(sc_card_t *card, struct bl
31 31
  		u8 	buffer[2048];
32 32
  		size_t	buf_len = (card->caps & SC_CARD_CAP_APDU_EXT)
33 33
  				  ? sizeof(buffer) : 256;
@@ -42,7 +42,7 @@ index e7b25c0..1913eca 100644
42 42
  		int	r = blob->info->get_fn(card, blob->id, buffer, buf_len);
43 43
  
44 44
  		if (r < 0) {	/* an error occurred */
45
-@@ -1828,6 +1841,7 @@ static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_in
45
+@@ -1836,6 +1849,7 @@ static int pgp_gen_key(sc_card_t *card,
46 46
  	u8 apdu_case;
47 47
  	u8 *apdu_data;
48 48
  	size_t apdu_le;
@@ -50,7 +50,7 @@ index e7b25c0..1913eca 100644
50 50
  	int r = SC_SUCCESS;
51 51
  
52 52
  	LOG_FUNC_CALLED(card->ctx);
53
-@@ -1868,23 +1882,27 @@ static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_in
53
+@@ -1876,23 +1890,27 @@ static int pgp_gen_key(sc_card_t *card,
54 54
  		apdu_case = SC_APDU_CASE_4_EXT;
55 55
  	}
56 56
  	else {
@@ -82,6 +82,3 @@ index e7b25c0..1913eca 100644
82 82
  
83 83
  	/* Send */
84 84
  	sc_log(card->ctx, "Waiting for the card to generate key...");
85
-2.1.3
86
-

+ 8
- 10
utils/opensc/patches/0012-OpenPGP-Support-write-certificate-for-Gnuk.patch View File

@@ -8,11 +8,11 @@ Subject: [PATCH 12/26] OpenPGP: Support write certificate for Gnuk.
8 8
  src/libopensc/card-openpgp.c | 158 +++++++++++++++++++++++++++++++++----------
9 9
  1 file changed, 123 insertions(+), 35 deletions(-)
10 10
 
11
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
12
-index 1913eca..7cea84f 100644
13
---- a/src/libopensc/card-openpgp.c
14
-+++ b/src/libopensc/card-openpgp.c
15
-@@ -727,6 +727,8 @@ pgp_iterate_blobs(struct blob *blob, int level, void (*func)())
11
+Index: opensc-20150513/src/libopensc/card-openpgp.c
12
+===================================================================
13
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
14
++++ opensc-20150513/src/libopensc/card-openpgp.c
15
+@@ -735,6 +735,8 @@ pgp_iterate_blobs(struct blob *blob, int
16 16
  static int
17 17
  pgp_read_blob(sc_card_t *card, struct blob *blob)
18 18
  {
@@ -21,7 +21,7 @@ index 1913eca..7cea84f 100644
21 21
  	if (blob->data != NULL)
22 22
  		return SC_SUCCESS;
23 23
  	if (blob->info == NULL)
24
-@@ -737,6 +739,11 @@ pgp_read_blob(sc_card_t *card, struct blob *blob)
24
+@@ -745,6 +747,11 @@ pgp_read_blob(sc_card_t *card, struct bl
25 25
  		size_t	buf_len = (card->caps & SC_CARD_CAP_APDU_EXT)
26 26
  				  ? sizeof(buffer) : 256;
27 27
  
@@ -33,7 +33,7 @@ index 1913eca..7cea84f 100644
33 33
  		/* Buffer length for Gnuk pubkey */
34 34
  		if (card->type == SC_CARD_TYPE_OPENPGP_GNUK &&
35 35
  		    (blob->id == 0xa400 || blob->id == 0xb600 || blob->id == 0xb800
36
-@@ -1192,49 +1199,75 @@ pgp_get_data(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len)
36
+@@ -1200,49 +1207,75 @@ pgp_get_data(sc_card_t *card, unsigned i
37 37
  	LOG_FUNC_RETURN(card->ctx, apdu.resplen);
38 38
  }
39 39
  
@@ -143,7 +143,7 @@ index 1913eca..7cea84f 100644
143 143
  
144 144
  	/* Extended Header list (004D DO) needs a variant of PUT DATA command */
145 145
  	if (tag == 0x004D) {
146
-@@ -1260,15 +1293,70 @@ pgp_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t buf_len)
146
+@@ -1268,15 +1301,70 @@ pgp_put_data(sc_card_t *card, unsigned i
147 147
  		apdu.lc = buf_len;
148 148
  	}
149 149
  	else {
@@ -215,6 +215,3 @@ index 1913eca..7cea84f 100644
215 215
  	/* Instruct more in case of error */
216 216
  	if (r == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED) {
217 217
  		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Please verify PIN first.");
218
-2.1.3
219
-

+ 5
- 7
utils/opensc/patches/0013-pkcs15-openpgp-Change-to-sc_put_data-instead-of-sc_u.patch View File

@@ -9,11 +9,11 @@ Subject: [PATCH 13/26] pkcs15-openpgp: Change to sc_put_data instead of
9 9
  src/pkcs15init/pkcs15-openpgp.c | 5 ++---
10 10
  1 file changed, 2 insertions(+), 3 deletions(-)
11 11
 
12
-diff --git a/src/pkcs15init/pkcs15-openpgp.c b/src/pkcs15init/pkcs15-openpgp.c
13
-index 1455580..be1291e 100755
14
---- a/src/pkcs15init/pkcs15-openpgp.c
15
-+++ b/src/pkcs15init/pkcs15-openpgp.c
16
-@@ -279,10 +279,9 @@ static int openpgp_store_data(struct sc_pkcs15_card *p15card, struct sc_profile
12
+Index: opensc-20150513/src/pkcs15init/pkcs15-openpgp.c
13
+===================================================================
14
+--- opensc-20150513.orig/src/pkcs15init/pkcs15-openpgp.c
15
++++ opensc-20150513/src/pkcs15init/pkcs15-openpgp.c
16
+@@ -279,10 +279,9 @@ static int openpgp_store_data(struct sc_
17 17
  		r = sc_select_file(card, path, &file);
18 18
  		LOG_TEST_RET(card->ctx, r, "Cannot select cert file");
19 19
  		r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
@@ -26,6 +26,3 @@ index 1455580..be1291e 100755
26 26
  		break;
27 27
  
28 28
  	case SC_PKCS15_TYPE_DATA_OBJECT:
29
-2.1.3
30
-

+ 6
- 8
utils/opensc/patches/0014-OpenPGP-Overcome-the-restriction-of-even-data-length.patch View File

@@ -10,11 +10,11 @@ When write certificate with odd length to Gnuk, we add zero padding to make it e
10 10
  src/libopensc/card-openpgp.c | 20 ++++++++++++++++++--
11 11
  1 file changed, 18 insertions(+), 2 deletions(-)
12 12
 
13
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
14
-index 7cea84f..7a77a71 100644
15
---- a/src/libopensc/card-openpgp.c
16
-+++ b/src/libopensc/card-openpgp.c
17
-@@ -1208,6 +1208,10 @@ static int gnuk_write_certificate(sc_card_t *card, const u8 *buf, size_t length)
13
+Index: opensc-20150513/src/libopensc/card-openpgp.c
14
+===================================================================
15
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
16
++++ opensc-20150513/src/libopensc/card-openpgp.c
17
+@@ -1216,6 +1216,10 @@ static int gnuk_write_certificate(sc_car
18 18
  	sc_apdu_t apdu;
19 19
  	u8 *part;
20 20
  	size_t plen;
@@ -25,7 +25,7 @@ index 7cea84f..7a77a71 100644
25 25
  	int r = SC_SUCCESS;
26 26
  
27 27
  	LOG_FUNC_CALLED(ctx);
28
-@@ -1238,8 +1242,20 @@ static int gnuk_write_certificate(sc_card_t *card, const u8 *buf, size_t length)
28
+@@ -1246,8 +1250,20 @@ static int gnuk_write_certificate(sc_car
29 29
  			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xD6, i, 0);
30 30
  		}
31 31
  		apdu.flags |= SC_APDU_FLAGS_CHAINING;
@@ -48,6 +48,3 @@ index 7cea84f..7a77a71 100644
48 48
  
49 49
  		r = sc_transmit_apdu(card, &apdu);
50 50
  		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
51
-2.1.3
52
-

+ 7
- 9
utils/opensc/patches/0015-OpenPGP-Delete-key-as-file-for-Gnuk.patch View File

@@ -8,11 +8,11 @@ Subject: [PATCH 15/26] OpenPGP: Delete key as file, for Gnuk.
8 8
  src/libopensc/card-openpgp.c | 51 +++++++++++++++++++++++++++++++++++++++++++-
9 9
  1 file changed, 50 insertions(+), 1 deletion(-)
10 10
 
11
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
12
-index 7a77a71..4d0500d 100644
13
---- a/src/libopensc/card-openpgp.c
14
-+++ b/src/libopensc/card-openpgp.c
15
-@@ -2435,6 +2435,44 @@ static int pgp_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr)
11
+Index: opensc-20150513/src/libopensc/card-openpgp.c
12
+===================================================================
13
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
14
++++ opensc-20150513/src/libopensc/card-openpgp.c
15
+@@ -2448,6 +2448,44 @@ static int pgp_card_ctl(sc_card_t *card,
16 16
  	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
17 17
  }
18 18
  
@@ -57,7 +57,7 @@ index 7a77a71..4d0500d 100644
57 57
  /* ABI: DELETE FILE */
58 58
  static int
59 59
  pgp_delete_file(sc_card_t *card, const sc_path_t *path)
60
-@@ -2442,6 +2480,7 @@ pgp_delete_file(sc_card_t *card, const sc_path_t *path)
60
+@@ -2455,6 +2493,7 @@ pgp_delete_file(sc_card_t *card, const s
61 61
  	struct pgp_priv_data *priv = DRVDATA(card);
62 62
  	struct blob *blob;
63 63
  	sc_file_t *file;
@@ -65,7 +65,7 @@ index 7a77a71..4d0500d 100644
65 65
  	int r;
66 66
  
67 67
  	LOG_FUNC_CALLED(card->ctx);
68
-@@ -2457,10 +2496,20 @@ pgp_delete_file(sc_card_t *card, const sc_path_t *path)
68
+@@ -2470,10 +2509,20 @@ pgp_delete_file(sc_card_t *card, const s
69 69
  	if (blob == priv->mf)
70 70
  		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
71 71
  
@@ -87,6 +87,3 @@ index 7a77a71..4d0500d 100644
87 87
  	else {
88 88
  		/* call pgp_put_data() with zero-sized NULL-buffer to zap the DO contents */
89 89
  		r = pgp_put_data(card, file->id, NULL, 0);
90
-2.1.3
91
-

+ 7
- 9
utils/opensc/patches/0016-OpenPGP-Correct-parameter-checking.patch View File

@@ -8,11 +8,11 @@ Subject: [PATCH 16/26] OpenPGP: Correct parameter checking.
8 8
  src/libopensc/card-openpgp.c | 9 +++++++--
9 9
  1 file changed, 7 insertions(+), 2 deletions(-)
10 10
 
11
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
12
-index 4d0500d..beeee83 100644
13
---- a/src/libopensc/card-openpgp.c
14
-+++ b/src/libopensc/card-openpgp.c
15
-@@ -1223,6 +1223,8 @@ static int gnuk_write_certificate(sc_card_t *card, const u8 *buf, size_t length)
11
+Index: opensc-20150513/src/libopensc/card-openpgp.c
12
+===================================================================
13
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
14
++++ opensc-20150513/src/libopensc/card-openpgp.c
15
+@@ -1231,6 +1231,8 @@ static int gnuk_write_certificate(sc_car
16 16
  		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
17 17
  		/* Check response */
18 18
  		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
@@ -21,7 +21,7 @@ index 4d0500d..beeee83 100644
21 21
  		LOG_FUNC_RETURN(card->ctx, length);
22 22
  	}
23 23
  
24
-@@ -2446,6 +2448,11 @@ gnuk_delete_key(sc_card_t *card, u8 key_id)
24
+@@ -2459,6 +2461,11 @@ gnuk_delete_key(sc_card_t *card, u8 key_
25 25
  
26 26
  	LOG_FUNC_CALLED(ctx);
27 27
  
@@ -33,7 +33,7 @@ index 4d0500d..beeee83 100644
33 33
  	/* Delete fingerprint */
34 34
  	sc_log(ctx, "Delete fingerprints");
35 35
  	r = pgp_put_data(card, 0xC6 + key_id, NULL, 0);
36
-@@ -2464,8 +2471,6 @@ gnuk_delete_key(sc_card_t *card, u8 key_id)
36
+@@ -2477,8 +2484,6 @@ gnuk_delete_key(sc_card_t *card, u8 key_
37 37
  		data = "\x4D\x02\xB8";
38 38
  	else if (key_id == 3)
39 39
  		data = "\x4D\x02\xA4";
@@ -42,6 +42,3 @@ index 4d0500d..beeee83 100644
42 42
  
43 43
  	r = pgp_put_data(card, 0x4D, data, strlen(data) + 1);
44 44
  
45
-2.1.3
46
-

+ 6
- 8
utils/opensc/patches/0017-OpenPGP-Make-code-neater.patch View File

@@ -8,11 +8,11 @@ Subject: [PATCH 17/26] OpenPGP: Make code neater
8 8
  src/libopensc/card-openpgp.c | 8 ++------
9 9
  1 file changed, 2 insertions(+), 6 deletions(-)
10 10
 
11
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
12
-index beeee83..ca0d01b 100644
13
---- a/src/libopensc/card-openpgp.c
14
-+++ b/src/libopensc/card-openpgp.c
15
-@@ -1222,10 +1222,7 @@ static int gnuk_write_certificate(sc_card_t *card, const u8 *buf, size_t length)
11
+Index: opensc-20150513/src/libopensc/card-openpgp.c
12
+===================================================================
13
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
14
++++ opensc-20150513/src/libopensc/card-openpgp.c
15
+@@ -1230,10 +1230,7 @@ static int gnuk_write_certificate(sc_car
16 16
  		r = sc_transmit_apdu(card, &apdu);
17 17
  		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
18 18
  		/* Check response */
@@ -24,7 +24,7 @@ index beeee83..ca0d01b 100644
24 24
  	}
25 25
  
26 26
  	/* Ref: gnuk_put_binary_libusb.py and gnuk_token.py in Gnuk source tree */
27
-@@ -1262,8 +1259,7 @@ static int gnuk_write_certificate(sc_card_t *card, const u8 *buf, size_t length)
27
+@@ -1270,8 +1267,7 @@ static int gnuk_write_certificate(sc_car
28 28
  		r = sc_transmit_apdu(card, &apdu);
29 29
  		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
30 30
  		/* Check response */
@@ -34,6 +34,3 @@ index beeee83..ca0d01b 100644
34 34
  
35 35
  		/* To next part */
36 36
  		i++;
37
-2.1.3
38
-

+ 6
- 8
utils/opensc/patches/0018-Move-declaration-to-top-of-block.patch View File

@@ -8,11 +8,11 @@ Subject: [PATCH 18/26] Move declaration to top of block.
8 8
  src/libopensc/card-openpgp.c | 3 ++-
9 9
  1 file changed, 2 insertions(+), 1 deletion(-)
10 10
 
11
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
12
-index ca0d01b..037ef73 100644
13
---- a/src/libopensc/card-openpgp.c
14
-+++ b/src/libopensc/card-openpgp.c
15
-@@ -738,6 +738,7 @@ pgp_read_blob(sc_card_t *card, struct blob *blob)
11
+Index: opensc-20150513/src/libopensc/card-openpgp.c
12
+===================================================================
13
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
14
++++ opensc-20150513/src/libopensc/card-openpgp.c
15
+@@ -746,6 +746,7 @@ pgp_read_blob(sc_card_t *card, struct bl
16 16
  		u8 	buffer[2048];
17 17
  		size_t	buf_len = (card->caps & SC_CARD_CAP_APDU_EXT)
18 18
  				  ? sizeof(buffer) : 256;
@@ -20,7 +20,7 @@ index ca0d01b..037ef73 100644
20 20
  
21 21
  		/* Buffer length for certificate */
22 22
  		if (blob->id == DO_CERT && priv->max_cert_size > 0) {
23
-@@ -751,7 +752,7 @@ pgp_read_blob(sc_card_t *card, struct blob *blob)
23
+@@ -759,7 +760,7 @@ pgp_read_blob(sc_card_t *card, struct bl
24 24
  			buf_len = MAXLEN_RESP_PUBKEY_GNUK;
25 25
  		}
26 26
  
@@ -29,6 +29,3 @@ index ca0d01b..037ef73 100644
29 29
  
30 30
  		if (r < 0) {	/* an error occurred */
31 31
  			blob->status = r;
32
-2.1.3
33
-

+ 14
- 16
utils/opensc/patches/0019-OpenPGP-Make-indentation-consistent-space-tab.patch View File

@@ -9,11 +9,11 @@ Subject: [PATCH 19/26] OpenPGP: Make indentation consistent (space -> tab).
9 9
  src/tools/openpgp-tool.c     | 56 ++++++++++++++++++++++----------------------
10 10
  2 files changed, 39 insertions(+), 39 deletions(-)
11 11
 
12
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
13
-index 037ef73..ae40940 100644
14
---- a/src/libopensc/card-openpgp.c
15
-+++ b/src/libopensc/card-openpgp.c
16
-@@ -192,12 +192,12 @@ static struct do_info		pgp1_objects[] = {	/* OpenPGP card spec 1.1 */
12
+Index: opensc-20150513/src/libopensc/card-openpgp.c
13
+===================================================================
14
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
15
++++ opensc-20150513/src/libopensc/card-openpgp.c
16
+@@ -194,12 +194,12 @@ static struct do_info		pgp1_objects[] =
17 17
  	{ 0x5f35, SIMPLE,      READ_ALWAYS | WRITE_PIN3,  NULL,               sc_put_data },
18 18
  	{ 0x5f50, SIMPLE,      READ_ALWAYS | WRITE_PIN3,  sc_get_data,        sc_put_data },
19 19
  	{ 0x7f49, CONSTRUCTED, READ_ALWAYS | WRITE_NEVER, NULL,               NULL        },
@@ -32,7 +32,7 @@ index 037ef73..ae40940 100644
32 32
  	{ 0, 0, 0, NULL, NULL },
33 33
  };
34 34
  
35
-@@ -253,11 +253,11 @@ static struct do_info		pgp2_objects[] = {	/* OpenPGP card spec 2.0 */
35
+@@ -255,11 +255,11 @@ static struct do_info		pgp2_objects[] =
36 36
  	/* The 0xA401, 0xB601, 0xB801 are just symbolic, it does not represent any real DO.
37 37
  	 * However, their R/W access condition may block the process of importing key in pkcs15init.
38 38
  	 * So we set their accesses condition as WRITE_PIN3 (writable). */
@@ -49,10 +49,10 @@ index 037ef73..ae40940 100644
49 49
  	{ 0, 0, 0, NULL, NULL },
50 50
  };
51 51
  
52
-diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c
53
-index 374819a..a0334ca 100644
54
---- a/src/tools/openpgp-tool.c
55
-+++ b/src/tools/openpgp-tool.c
52
+Index: opensc-20150513/src/tools/openpgp-tool.c
53
+===================================================================
54
+--- opensc-20150513.orig/src/tools/openpgp-tool.c
55
++++ opensc-20150513/src/tools/openpgp-tool.c
56 56
 @@ -37,11 +37,11 @@
57 57
  #include "util.h"
58 58
  #include "libopensc/log.h"
@@ -70,7 +70,7 @@ index 374819a..a0334ca 100644
70 70
  
71 71
  /* define structures */
72 72
  struct ef_name_map {
73
-@@ -142,10 +142,10 @@ static const struct ef_name_map openpgp_data[] = {
73
+@@ -142,10 +142,10 @@ static const struct ef_name_map openpgp_
74 74
  static void show_version(void)
75 75
  {
76 76
  	fprintf(stderr,
@@ -85,7 +85,7 @@ index 374819a..a0334ca 100644
85 85
  }
86 86
  
87 87
  
88
-@@ -176,16 +176,16 @@ static char *prettify_language(char *str)
88
+@@ -176,16 +176,16 @@ static char *prettify_language(char *str
89 89
  {
90 90
  	if (str != NULL) {
91 91
  		switch (strlen(str)) {
@@ -121,7 +121,7 @@ index 374819a..a0334ca 100644
121 121
  		}
122 122
  	}
123 123
  	return NULL;
124
-@@ -218,7 +218,7 @@ static void display_data(const struct ef_name_map *mapping, char *value)
124
+@@ -218,7 +218,7 @@ static void display_data(const struct ef
125 125
  				char *envvar;
126 126
  
127 127
  				envvar = malloc(strlen(mapping->env_name) +
@@ -130,7 +130,7 @@ index 374819a..a0334ca 100644
130 130
  				if (envvar != NULL) {
131 131
  					strcpy(envvar, mapping->env_name);
132 132
  					strcat(envvar, "=");
133
-@@ -346,20 +346,20 @@ static int do_userinfo(sc_card_t *card)
133
+@@ -344,20 +344,20 @@ static int do_userinfo(sc_card_t *card)
134 134
  		if (!count)
135 135
  			continue;
136 136
  
@@ -177,6 +177,3 @@ index 374819a..a0334ca 100644
177 177
  		return EXIT_FAILURE;
178 178
  	}
179 179
  
180
-2.1.3
181
-

+ 8
- 10
utils/opensc/patches/0020-OpenPGP-Don-t-use-sc_log-in-openpgp-tool.patch View File

@@ -8,11 +8,11 @@ Subject: [PATCH 20/26] OpenPGP: Don't use sc_log in openpgp-tool.
8 8
  src/tools/openpgp-tool.c | 21 +++++++++++----------
9 9
  1 file changed, 11 insertions(+), 10 deletions(-)
10 10
 
11
-diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c
12
-index a0334ca..505abd9 100644
13
---- a/src/tools/openpgp-tool.c
14
-+++ b/src/tools/openpgp-tool.c
15
-@@ -414,8 +414,6 @@ int do_genkey(sc_card_t *card, u8 key_id, unsigned int key_len)
11
+Index: opensc-20150513/src/tools/openpgp-tool.c
12
+===================================================================
13
+--- opensc-20150513.orig/src/tools/openpgp-tool.c
14
++++ opensc-20150513/src/tools/openpgp-tool.c
15
+@@ -414,8 +414,6 @@ int do_genkey(sc_card_t *card, u8 key_id
16 16
  	sc_path_t path;
17 17
  	sc_file_t *file;
18 18
  
@@ -21,7 +21,7 @@ index a0334ca..505abd9 100644
21 21
  	if (key_id < 1 || key_id > 3) {
22 22
  		printf("Unknown key ID %d.\n", key_id);
23 23
  		return 1;
24
-@@ -479,14 +477,14 @@ int delete_key_gnuk(sc_card_t *card, u8 key_id)
24
+@@ -479,14 +477,14 @@ int delete_key_gnuk(sc_card_t *card, u8
25 25
  	u8 *data = NULL;
26 26
  
27 27
  	/* Delete fingerprint */
@@ -39,7 +39,7 @@ index a0334ca..505abd9 100644
39 39
  
40 40
  	if (key_id == 1)
41 41
  		data = "\x4D\x02\xB6";
42
-@@ -534,15 +532,18 @@ int delete_key_openpgp(sc_card_t *card, u8 key_id)
42
+@@ -534,15 +532,18 @@ int delete_key_openpgp(sc_card_t *card,
43 43
  		/* Build APDU from binary array */
44 44
  		r = sc_bytes2apdu(card->ctx, buf, len0, &apdu);
45 45
  		if (r) {
@@ -61,7 +61,7 @@ index a0334ca..505abd9 100644
61 61
  	}
62 62
  	/* TODO: Rewrite Extended Header List.
63 63
  	 * Not support by OpenGPG v2 yet */
64
-@@ -557,7 +558,7 @@ int delete_key(sc_card_t *card, u8 key_id)
64
+@@ -557,7 +558,7 @@ int delete_key(sc_card_t *card, u8 key_i
65 65
  	LOG_FUNC_CALLED(ctx);
66 66
  	/* Check key ID */
67 67
  	if (key_id < 1 || key_id > 3) {
@@ -79,6 +79,3 @@ index a0334ca..505abd9 100644
79 79
  		exit_status = EXIT_FAILURE;
80 80
  		goto out;
81 81
  	}
82
-2.1.3
83
-

+ 7
- 9
utils/opensc/patches/0021-OpenPGP-Don-t-reimplement-gnuk_delete_key-in-openpgp.patch View File

@@ -9,11 +9,11 @@ Subject: [PATCH 21/26] OpenPGP: Don't reimplement gnuk_delete_key in
9 9
  src/tools/openpgp-tool.c | 64 ++++++------------------------------------------
10 10
  1 file changed, 8 insertions(+), 56 deletions(-)
11 11
 
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)
12
+Index: opensc-20150513/src/tools/openpgp-tool.c
13
+===================================================================
14
+--- opensc-20150513.orig/src/tools/openpgp-tool.c
15
++++ opensc-20150513/src/tools/openpgp-tool.c
16
+@@ -468,38 +468,6 @@ int do_verify(sc_card_t *card, char *typ
17 17
  }
18 18
  
19 19
  /**
@@ -52,7 +52,7 @@ index 505abd9..a7796e7 100644
52 52
   * Delete key, for OpenPGP card.
53 53
   * This function is not complete and is reserved for future version (> 2) of OpenPGP card.
54 54
   **/
55
-@@ -547,32 +515,13 @@ int delete_key_openpgp(sc_card_t *card, u8 key_id)
55
+@@ -547,32 +515,13 @@ int delete_key_openpgp(sc_card_t *card,
56 56
  	}
57 57
  	/* TODO: Rewrite Extended Header List.
58 58
  	 * Not support by OpenGPG v2 yet */
@@ -87,7 +87,7 @@ index 505abd9..a7796e7 100644
87 87
  	int r = SC_SUCCESS;
88 88
  
89 89
  	/* Currently, only Gnuk supports deleting keys */
90
-@@ -586,13 +535,16 @@ int do_delete_key(sc_card_t *card, u8 key_id)
90
+@@ -586,13 +535,16 @@ int do_delete_key(sc_card_t *card, u8 ke
91 91
  		return SC_ERROR_INVALID_ARGUMENTS;
92 92
  	}
93 93
  	if (key_id == 1 || key_id == 'a') {
@@ -107,6 +107,3 @@ index 505abd9..a7796e7 100644
107 107
  	}
108 108
  	return r;
109 109
  }
110
-2.1.3
111
-

+ 6
- 8
utils/opensc/patches/0022-OpenPGP-Use-directly-binary-array-of-APDUs-for-ERASE.patch View File

@@ -10,11 +10,11 @@ I used a string presentation before and it needed an extra conversion step.
10 10
  src/libopensc/card-openpgp.c | 47 +++++++++++++++++++++++---------------------
11 11
  1 file changed, 25 insertions(+), 22 deletions(-)
12 12
 
13
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
14
-index ae40940..724fe73 100644
15
---- a/src/libopensc/card-openpgp.c
16
-+++ b/src/libopensc/card-openpgp.c
17
-@@ -2347,24 +2347,27 @@ out:
13
+Index: opensc-20150513/src/libopensc/card-openpgp.c
14
+===================================================================
15
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
16
++++ opensc-20150513/src/libopensc/card-openpgp.c
17
+@@ -2358,24 +2358,27 @@ out:
18 18
  static int pgp_erase_card(sc_card_t *card)
19 19
  {
20 20
  	sc_context_t *ctx = card->ctx;
@@ -56,7 +56,7 @@ index ae40940..724fe73 100644
56 56
  
57 57
  	LOG_FUNC_CALLED(ctx);
58 58
  
59
-@@ -2376,17 +2379,17 @@ static int pgp_erase_card(sc_card_t *card)
59
+@@ -2387,17 +2390,17 @@ static int pgp_erase_card(sc_card_t *car
60 60
  	sc_log(ctx, "Card is OpenPGP v2. Erase card.");
61 61
  
62 62
  	/* Iterate over 10 commands above */
@@ -82,6 +82,3 @@ index ae40940..724fe73 100644
82 82
  		if (r) {
83 83
  			sc_log(ctx, "Failed to build APDU");
84 84
  			LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
85
-2.1.3
86
-

+ 35
- 37
utils/opensc/patches/0023-OpenPGP-Rename-private-blob-type-to-avoid-confusing-.patch View File

@@ -11,11 +11,11 @@ type.
11 11
  src/libopensc/card-openpgp.c | 96 ++++++++++++++++++++++----------------------
12 12
  1 file changed, 49 insertions(+), 47 deletions(-)
13 13
 
14
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
15
-index 724fe73..ca3173c 100644
16
---- a/src/libopensc/card-openpgp.c
17
-+++ b/src/libopensc/card-openpgp.c
18
-@@ -111,9 +111,9 @@ enum _card_state {
14
+Index: opensc-20150513/src/libopensc/card-openpgp.c
15
+===================================================================
16
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
17
++++ opensc-20150513/src/libopensc/card-openpgp.c
18
+@@ -113,9 +113,9 @@ enum _card_state {
19 19
  	CARD_STATE_ACTIVATED      = 0x05
20 20
  };
21 21
  
@@ -28,7 +28,7 @@ index 724fe73..ca3173c 100644
28 28
  	struct do_info *info;
29 29
  
30 30
  	sc_file_t *	file;
31
-@@ -122,8 +122,8 @@ struct blob {
31
+@@ -124,8 +124,8 @@ struct blob {
32 32
  
33 33
  	unsigned char *	data;
34 34
  	unsigned int	len;
@@ -39,7 +39,7 @@ index 724fe73..ca3173c 100644
39 39
  
40 40
  struct do_info {
41 41
  	unsigned int	id;		/* ID of the DO in question */
42
-@@ -141,12 +141,12 @@ struct do_info {
42
+@@ -143,12 +143,12 @@ struct do_info {
43 43
  
44 44
  static int		pgp_get_card_features(sc_card_t *card);
45 45
  static int		pgp_finish(sc_card_t *card);
@@ -57,7 +57,7 @@ index 724fe73..ca3173c 100644
57 57
  static int		pgp_get_pubkey(sc_card_t *, unsigned int,
58 58
  				u8 *, size_t);
59 59
  static int		pgp_get_pubkey_pem(sc_card_t *, unsigned int,
60
-@@ -272,8 +272,8 @@ static struct do_info		pgp2_objects[] = {	/* OpenPGP card spec 2.0 */
60
+@@ -274,8 +274,8 @@ static struct do_info		pgp2_objects[] =
61 61
  
62 62
  #define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
63 63
  struct pgp_priv_data {
@@ -68,16 +68,16 @@ index 724fe73..ca3173c 100644
68 68
  
69 69
  	enum _version		bcd_version;
70 70
  	struct do_info		*pgp_objects;
71
-@@ -311,7 +311,7 @@ pgp_init(sc_card_t *card)
71
+@@ -313,7 +313,7 @@ pgp_init(sc_card_t *card)
72 72
  	sc_file_t	*file = NULL;
73 73
  	struct do_info	*info;
74 74
  	int		r;
75
--	struct blob 	*child = NULL;
76
-+	pgp_blob_t 	*child = NULL;
75
+-	struct blob	*child = NULL;
76
++	pgp_blob_t	*child = NULL;
77 77
  
78 78
  	LOG_FUNC_CALLED(card->ctx);
79 79
  
80
-@@ -389,7 +389,7 @@ pgp_get_card_features(sc_card_t *card)
80
+@@ -397,7 +397,7 @@ pgp_get_card_features(sc_card_t *card)
81 81
  	unsigned char *hist_bytes = card->atr.value;
82 82
  	size_t atr_len = card->atr.len;
83 83
  	size_t i = 0;
@@ -86,7 +86,7 @@ index 724fe73..ca3173c 100644
86 86
  
87 87
  	/* parse card capabilities from historical bytes */
88 88
  	while ((i < atr_len) && (hist_bytes[i] != 0x73))
89
-@@ -526,7 +526,7 @@ pgp_finish(sc_card_t *card)
89
+@@ -534,7 +534,7 @@ pgp_finish(sc_card_t *card)
90 90
  
91 91
  /* internal: fill a blob's data */
92 92
  static int
@@ -95,7 +95,7 @@ index 724fe73..ca3173c 100644
95 95
  {
96 96
  	if (blob->data)
97 97
  		free(blob->data);
98
-@@ -620,16 +620,16 @@ pgp_attach_acl(sc_card_t *card, sc_file_t *file, struct do_info *info)
98
+@@ -628,16 +628,16 @@ pgp_attach_acl(sc_card_t *card, sc_file_
99 99
  }
100 100
  
101 101
  /* internal: append a blob to the list of children of a given parent blob */
@@ -116,7 +116,7 @@ index 724fe73..ca3173c 100644
116 116
  		struct pgp_priv_data *priv = DRVDATA (card);
117 117
  		struct do_info *info;
118 118
  
119
-@@ -643,7 +643,7 @@ pgp_new_blob(sc_card_t *card, struct blob *parent, unsigned int file_id,
119
+@@ -651,7 +651,7 @@ pgp_new_blob(sc_card_t *card, struct blo
120 120
  		blob->parent = parent;
121 121
  
122 122
  		if (parent != NULL) {
@@ -125,7 +125,7 @@ index 724fe73..ca3173c 100644
125 125
  
126 126
  			/* set file's path = parent's path + file's id */
127 127
  			blob->file->path = parent->file->path;
128
-@@ -681,11 +681,11 @@ pgp_new_blob(sc_card_t *card, struct blob *parent, unsigned int file_id,
128
+@@ -689,11 +689,11 @@ pgp_new_blob(sc_card_t *card, struct blo
129 129
  
130 130
  /* internal: free a blob including its content */
131 131
  static void
@@ -139,7 +139,7 @@ index 724fe73..ca3173c 100644
139 139
  
140 140
  			/* remove blob from list of parent's children */
141 141
  			for (p = &blob->parent->files; *p != NULL && *p != blob; p = &(*p)->next)
142
-@@ -705,14 +705,14 @@ pgp_free_blob(struct blob *blob)
142
+@@ -713,14 +713,14 @@ pgp_free_blob(struct blob *blob)
143 143
  
144 144
  /* internal: iterate through the blob tree, calling a function for each blob */
145 145
  static void
@@ -157,7 +157,7 @@ index 724fe73..ca3173c 100644
157 157
  
158 158
  				pgp_iterate_blobs(child, level-1, func);
159 159
  				child = next;
160
-@@ -725,7 +725,7 @@ pgp_iterate_blobs(struct blob *blob, int level, void (*func)())
160
+@@ -733,7 +733,7 @@ pgp_iterate_blobs(struct blob *blob, int
161 161
  
162 162
  /* internal: read a blob's contents from card */
163 163
  static int
@@ -166,7 +166,7 @@ index 724fe73..ca3173c 100644
166 166
  {
167 167
  	struct pgp_priv_data *priv = DRVDATA (card);
168 168
  
169
-@@ -772,7 +772,7 @@ pgp_read_blob(sc_card_t *card, struct blob *blob)
169
+@@ -780,7 +780,7 @@ pgp_read_blob(sc_card_t *card, struct bl
170 170
   * The OpenPGP card has a TLV encoding according ASN.1 BER-encoding rules.
171 171
   */
172 172
  static int
@@ -175,7 +175,7 @@ index 724fe73..ca3173c 100644
175 175
  {
176 176
  	const u8	*in;
177 177
  	int		r;
178
-@@ -789,7 +789,7 @@ pgp_enumerate_blob(sc_card_t *card, struct blob *blob)
178
+@@ -797,7 +797,7 @@ pgp_enumerate_blob(sc_card_t *card, stru
179 179
  		unsigned int	cla, tag, tmptag;
180 180
  		size_t		len;
181 181
  		const u8	*data = in;
@@ -184,7 +184,7 @@ index 724fe73..ca3173c 100644
184 184
  
185 185
  		r = sc_asn1_read_tag(&data, blob->len - (in - blob->data),
186 186
  					&cla, &tag, &len);
187
-@@ -819,10 +819,10 @@ pgp_enumerate_blob(sc_card_t *card, struct blob *blob)
187
+@@ -827,10 +827,10 @@ pgp_enumerate_blob(sc_card_t *card, stru
188 188
  
189 189
  /* internal: find a blob by ID below a given parent, filling its contents when necessary */
190 190
  static int
@@ -198,7 +198,7 @@ index 724fe73..ca3173c 100644
198 198
  	int			r;
199 199
  
200 200
  	if ((r = pgp_enumerate_blob(card, blob)) < 0)
201
-@@ -858,10 +858,10 @@ pgp_get_blob(sc_card_t *card, struct blob *blob, unsigned int id,
201
+@@ -866,10 +866,10 @@ pgp_get_blob(sc_card_t *card, struct blo
202 202
  
203 203
  /* Internal: search recursively for a blob by ID below a given root */
204 204
  static int
@@ -212,7 +212,7 @@ index 724fe73..ca3173c 100644
212 212
  	int			r;
213 213
  
214 214
  	if ((r = pgp_get_blob(card, root, id, ret)) == 0)
215
-@@ -883,11 +883,11 @@ pgp_seek_blob(sc_card_t *card, struct blob *root, unsigned int id,
215
+@@ -891,11 +891,11 @@ pgp_seek_blob(sc_card_t *card, struct bl
216 216
  }
217 217
  
218 218
  /* internal: find a blob by tag - pgp_seek_blob with optimizations */
@@ -226,7 +226,7 @@ index 724fe73..ca3173c 100644
226 226
  	int r;
227 227
  
228 228
  	/* Check if current selected blob is which we want to test*/
229
-@@ -941,7 +941,7 @@ static int
229
+@@ -949,7 +949,7 @@ static int
230 230
  pgp_select_file(sc_card_t *card, const sc_path_t *path, sc_file_t **ret)
231 231
  {
232 232
  	struct pgp_priv_data *priv = DRVDATA(card);
@@ -235,7 +235,7 @@ index 724fe73..ca3173c 100644
235 235
  	unsigned int	path_start = 0;
236 236
  	unsigned int	n;
237 237
  	sc_path_t dummy_path;
238
-@@ -1022,7 +1022,7 @@ static int
238
+@@ -1030,7 +1030,7 @@ static int
239 239
  pgp_list_files(sc_card_t *card, u8 *buf, size_t buflen)
240 240
  {
241 241
  	struct pgp_priv_data *priv = DRVDATA(card);
@@ -244,7 +244,7 @@ index 724fe73..ca3173c 100644
244 244
  	unsigned int	k;
245 245
  	int		r;
246 246
  
247
-@@ -1058,7 +1058,7 @@ pgp_read_binary(sc_card_t *card, unsigned int idx,
247
+@@ -1066,7 +1066,7 @@ pgp_read_binary(sc_card_t *card, unsigne
248 248
  		u8 *buf, size_t count, unsigned long flags)
249 249
  {
250 250
  	struct pgp_priv_data *priv = DRVDATA(card);
@@ -253,7 +253,7 @@ index 724fe73..ca3173c 100644
253 253
  	int		r;
254 254
  
255 255
  	LOG_FUNC_CALLED(card->ctx);
256
-@@ -1134,7 +1134,7 @@ static int
256
+@@ -1142,7 +1142,7 @@ static int
257 257
  pgp_get_pubkey_pem(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len)
258 258
  {
259 259
  	struct pgp_priv_data *priv = DRVDATA(card);
@@ -262,7 +262,7 @@ index 724fe73..ca3173c 100644
262 262
  	sc_pkcs15_pubkey_t pubkey;
263 263
  	u8		*data;
264 264
  	size_t		len;
265
-@@ -1329,7 +1329,7 @@ static int
265
+@@ -1337,7 +1337,7 @@ static int
266 266
  pgp_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t buf_len)
267 267
  {
268 268
  	struct pgp_priv_data *priv = DRVDATA(card);
@@ -271,7 +271,7 @@ index 724fe73..ca3173c 100644
271 271
  	struct do_info *dinfo = NULL;
272 272
  	int r;
273 273
  
274
-@@ -1603,7 +1603,7 @@ static int
274
+@@ -1611,7 +1611,7 @@ static int
275 275
  pgp_update_new_algo_attr(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info)
276 276
  {
277 277
  	struct pgp_priv_data *priv = DRVDATA(card);
@@ -280,7 +280,7 @@ index 724fe73..ca3173c 100644
280 280
  	unsigned int old_modulus_len;     /* Measured in bit */
281 281
  	unsigned int old_exponent_len;
282 282
  	const unsigned int tag = 0x00C0 | key_info->keytype;
283
-@@ -1708,7 +1708,7 @@ pgp_calculate_and_store_fingerprint(sc_card_t *card, time_t ctime,
283
+@@ -1716,7 +1716,7 @@ pgp_calculate_and_store_fingerprint(sc_c
284 284
  	u8 *p; /* Use this pointer to set fp_buffer content */
285 285
  	size_t pk_packet_len;
286 286
  	unsigned int tag;
@@ -289,7 +289,7 @@ index 724fe73..ca3173c 100644
289 289
  	u8 *newdata;
290 290
  	int r;
291 291
  
292
-@@ -1797,7 +1797,7 @@ pgp_update_pubkey_blob(sc_card_t *card, u8* modulus, size_t modulus_len,
292
+@@ -1805,7 +1805,7 @@ pgp_update_pubkey_blob(sc_card_t *card,
293 293
                         u8* exponent, size_t exponent_len, u8 key_id)
294 294
  {
295 295
  	struct pgp_priv_data *priv = DRVDATA(card);
@@ -298,7 +298,7 @@ index 724fe73..ca3173c 100644
298 298
  	unsigned int blob_id;
299 299
  	sc_pkcs15_pubkey_t pubkey;
300 300
  	u8 *data = NULL;
301
-@@ -1939,6 +1939,8 @@ static int pgp_update_card_algorithms(sc_card_t *card, sc_cardctl_openpgp_keygen
301
+@@ -1947,6 +1947,8 @@ static int pgp_update_card_algorithms(sc
302 302
   **/
303 303
  static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info)
304 304
  {
@@ -307,7 +307,7 @@ index 724fe73..ca3173c 100644
307 307
  	sc_apdu_t apdu;
308 308
  	/* Temporary variables to hold APDU params */
309 309
  	u8 apdu_case;
310
-@@ -2132,7 +2134,7 @@ pgp_build_extended_header_list(sc_card_t *card, sc_cardctl_openpgp_keystore_info
310
+@@ -2143,7 +2145,7 @@ pgp_build_extended_header_list(sc_card_t
311 311
  	};
312 312
  	size_t comp_to_add = 3;
313 313
  	size_t req_e_len = 0;     /* The exponent length specified in Algorithm Attributes */
@@ -316,7 +316,7 @@ index 724fe73..ca3173c 100644
316 316
  	u8 i;
317 317
  	int r;
318 318
  
319
-@@ -2483,7 +2485,7 @@ static int
319
+@@ -2496,7 +2498,7 @@ static int
320 320
  pgp_delete_file(sc_card_t *card, const sc_path_t *path)
321 321
  {
322 322
  	struct pgp_priv_data *priv = DRVDATA(card);
@@ -325,7 +325,7 @@ index 724fe73..ca3173c 100644
325 325
  	sc_file_t *file;
326 326
  	u8 key_id;
327 327
  	int r;
328
-@@ -2533,7 +2535,7 @@ pgp_update_binary(sc_card_t *card, unsigned int idx,
328
+@@ -2546,7 +2548,7 @@ pgp_update_binary(sc_card_t *card, unsig
329 329
  		  const u8 *buf, size_t count, unsigned long flags)
330 330
  {
331 331
  	struct pgp_priv_data *priv = DRVDATA(card);
@@ -334,6 +334,3 @@ index 724fe73..ca3173c 100644
334 334
  	int r = SC_SUCCESS;
335 335
  
336 336
  	LOG_FUNC_CALLED(card->ctx);
337
-2.1.3
338
-

+ 7
- 9
utils/opensc/patches/0024-OpenPGP-Fix-crash-after-accessing-inexistent-file.patch View File

@@ -8,11 +8,11 @@ Subject: [PATCH 24/26] OpenPGP: Fix crash after accessing inexistent file.
8 8
  src/libopensc/card-openpgp.c | 3 ---
9 9
  1 file changed, 3 deletions(-)
10 10
 
11
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
12
-index ca3173c..94c69ae 100644
13
---- a/src/libopensc/card-openpgp.c
14
-+++ b/src/libopensc/card-openpgp.c
15
-@@ -973,7 +973,6 @@ pgp_select_file(sc_card_t *card, const sc_path_t *path, sc_file_t **ret)
11
+Index: opensc-20150513/src/libopensc/card-openpgp.c
12
+===================================================================
13
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
14
++++ opensc-20150513/src/libopensc/card-openpgp.c
15
+@@ -981,7 +981,6 @@ pgp_select_file(sc_card_t *card, const s
16 16
  			 * So we set its size to be the same as max certificate size the card supports. */
17 17
  			(*ret)->size = priv->max_cert_size;
18 18
  		}
@@ -20,7 +20,7 @@ index ca3173c..94c69ae 100644
20 20
  		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
21 21
  	}
22 22
  
23
-@@ -990,7 +989,6 @@ pgp_select_file(sc_card_t *card, const sc_path_t *path, sc_file_t **ret)
23
+@@ -998,7 +997,6 @@ pgp_select_file(sc_card_t *card, const s
24 24
  		/* This file ID is refered when importing key&certificate via pkcs15init, like above.
25 25
  		 * We pretend to successfully find this inexistent file. */
26 26
  		if (id == 0x4402 || id == 0x5f48) {
@@ -28,7 +28,7 @@ index ca3173c..94c69ae 100644
28 28
  			if (ret == NULL)
29 29
  				/* No need to return file */
30 30
  				LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
31
-@@ -1002,7 +1000,6 @@ pgp_select_file(sc_card_t *card, const sc_path_t *path, sc_file_t **ret)
31
+@@ -1010,7 +1008,6 @@ pgp_select_file(sc_card_t *card, const s
32 32
  		}
33 33
  
34 34
  		if (r < 0) {	/* failure */
@@ -36,6 +36,3 @@ index ca3173c..94c69ae 100644
36 36
  			LOG_FUNC_RETURN(card->ctx, r);
37 37
  		}
38 38
  	}
39
-2.1.3
40
-

+ 10
- 12
utils/opensc/patches/0025-Replace-hardcode.patch View File

@@ -8,11 +8,11 @@ Subject: [PATCH 25/26] Replace hardcode.
8 8
  src/libopensc/card-openpgp.c | 72 +++++++++++++++++++++++++-------------------
9 9
  1 file changed, 41 insertions(+), 31 deletions(-)
10 10
 
11
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
12
-index 94c69ae..1e6e338 100644
13
---- a/src/libopensc/card-openpgp.c
14
-+++ b/src/libopensc/card-openpgp.c
15
-@@ -152,6 +152,24 @@ static int		pgp_get_pubkey(sc_card_t *, unsigned int,
11
+Index: opensc-20150513/src/libopensc/card-openpgp.c
12
+===================================================================
13
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
14
++++ opensc-20150513/src/libopensc/card-openpgp.c
15
+@@ -154,6 +154,24 @@ static int		pgp_get_pubkey(sc_card_t *,
16 16
  static int		pgp_get_pubkey_pem(sc_card_t *, unsigned int,
17 17
  				u8 *, size_t);
18 18
  
@@ -37,7 +37,7 @@ index 94c69ae..1e6e338 100644
37 37
  static struct do_info		pgp1_objects[] = {	/* OpenPGP card spec 1.1 */
38 38
  	{ 0x004f, SIMPLE,      READ_ALWAYS | WRITE_NEVER, NULL,               NULL        },
39 39
  	{ 0x005b, SIMPLE,      READ_ALWAYS | WRITE_PIN3,  NULL,               sc_put_data },
40
-@@ -192,12 +210,12 @@ static struct do_info		pgp1_objects[] = {	/* OpenPGP card spec 1.1 */
40
+@@ -194,12 +212,12 @@ static struct do_info		pgp1_objects[] =
41 41
  	{ 0x5f35, SIMPLE,      READ_ALWAYS | WRITE_PIN3,  NULL,               sc_put_data },
42 42
  	{ 0x5f50, SIMPLE,      READ_ALWAYS | WRITE_PIN3,  sc_get_data,        sc_put_data },
43 43
  	{ 0x7f49, CONSTRUCTED, READ_ALWAYS | WRITE_NEVER, NULL,               NULL        },
@@ -56,7 +56,7 @@ index 94c69ae..1e6e338 100644
56 56
  	{ 0, 0, 0, NULL, NULL },
57 57
  };
58 58
  
59
-@@ -246,30 +264,21 @@ static struct do_info		pgp2_objects[] = {	/* OpenPGP card spec 2.0 */
59
+@@ -248,30 +266,21 @@ static struct do_info		pgp2_objects[] =
60 60
  	{ 0x5f52, SIMPLE,      READ_ALWAYS | WRITE_NEVER, sc_get_data,        NULL        },
61 61
  	/* The 7F21 is constructed DO in spec, but in practice, its content can be retrieved
62 62
  	 * as simple DO (no need to parse TLV). */
@@ -94,7 +94,7 @@ index 94c69ae..1e6e338 100644
94 94
  #define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
95 95
  struct pgp_priv_data {
96 96
  	pgp_blob_t *		mf;
97
-@@ -747,8 +756,9 @@ pgp_read_blob(sc_card_t *card, pgp_blob_t *blob)
97
+@@ -755,8 +764,9 @@ pgp_read_blob(sc_card_t *card, pgp_blob_
98 98
  
99 99
  		/* Buffer length for Gnuk pubkey */
100 100
  		if (card->type == SC_CARD_TYPE_OPENPGP_GNUK &&
@@ -106,7 +106,7 @@ index 94c69ae..1e6e338 100644
106 106
  			buf_len = MAXLEN_RESP_PUBKEY_GNUK;
107 107
  		}
108 108
  
109
-@@ -1804,11 +1814,11 @@ pgp_update_pubkey_blob(sc_card_t *card, u8* modulus, size_t modulus_len,
109
+@@ -1812,11 +1822,11 @@ pgp_update_pubkey_blob(sc_card_t *card,
110 110
  	LOG_FUNC_CALLED(card->ctx);
111 111
  
112 112
  	if (key_id == SC_OPENPGP_KEY_SIGN)
@@ -121,7 +121,7 @@ index 94c69ae..1e6e338 100644
121 121
  	else {
122 122
  		sc_log(card->ctx, "Unknown key id %X.", key_id);
123 123
  		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
124
-@@ -2501,17 +2511,17 @@ pgp_delete_file(sc_card_t *card, const sc_path_t *path)
124
+@@ -2514,17 +2524,17 @@ pgp_delete_file(sc_card_t *card, const s
125 125
  		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
126 126
  
127 127
  	if (card->type != SC_CARD_TYPE_OPENPGP_GNUK &&
@@ -143,6 +143,3 @@ index 94c69ae..1e6e338 100644
143 143
  		r = gnuk_delete_key(card, 3);
144 144
  	}
145 145
  	else {
146
-2.1.3
147
-

+ 7
- 9
utils/opensc/patches/0026-hardcode-defines-for-DO-s.patch View File

@@ -7,11 +7,11 @@ Subject: [PATCH 26/26] hardcode->defines for DO's
7 7
  src/libopensc/card-openpgp.c | 16 ++++++++++++++--
8 8
  1 file changed, 14 insertions(+), 2 deletions(-)
9 9
 
10
-diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
11
-index 1e6e338..8464914 100644
12
---- a/src/libopensc/card-openpgp.c
13
-+++ b/src/libopensc/card-openpgp.c
14
-@@ -164,6 +164,18 @@ static int		pgp_get_pubkey_pem(sc_card_t *, unsigned int,
10
+Index: opensc-20150513/src/libopensc/card-openpgp.c
11
+===================================================================
12
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
13
++++ opensc-20150513/src/libopensc/card-openpgp.c
14
+@@ -166,6 +166,18 @@ static int		pgp_get_pubkey_pem(sc_card_t
15 15
  #define DO_SIGN_SYM              0xb601
16 16
  #define DO_ENCR_SYM              0xb801
17 17
  #define DO_AUTH_SYM              0xa401
@@ -30,7 +30,7 @@ index 1e6e338..8464914 100644
30 30
  /* Maximum length for response buffer when reading pubkey. This value is calculated with
31 31
   * 4096-bit key length */
32 32
  #define MAXLEN_RESP_PUBKEY       527
33
-@@ -851,7 +863,7 @@ pgp_get_blob(sc_card_t *card, pgp_blob_t *blob, unsigned int id,
33
+@@ -859,7 +871,7 @@ pgp_get_blob(sc_card_t *card, pgp_blob_t
34 34
  	/* Special case:
35 35
  	 * Gnuk does not have default value for children of DO 65 (DOs 5B, 5F2D, 5F35)
36 36
  	 * So, if these blob was not found, we create it. */
@@ -39,7 +39,7 @@ index 1e6e338..8464914 100644
39 39
  		sc_log(card->ctx, "Create blob %X under %X", id, blob->id);
40 40
  		child = pgp_new_blob(card, blob, id, sc_file_new());
41 41
  		if (child) {
42
-@@ -1198,7 +1210,7 @@ pgp_get_data(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len)
42
+@@ -1206,7 +1218,7 @@ pgp_get_data(sc_card_t *card, unsigned i
43 43
  	/* For Gnuk card, if there is no certificate, it returns error instead of empty data.
44 44
  	 * So, for this case, we ignore error and consider success */
45 45
  	if (r == SC_ERROR_DATA_OBJECT_NOT_FOUND && card->type == SC_CARD_TYPE_OPENPGP_GNUK
@@ -48,6 +48,3 @@ index 1e6e338..8464914 100644
48 48
  		r = SC_SUCCESS;
49 49
  		apdu.resplen = 0;
50 50
  	}
51
-2.1.3
52
-

+ 82
- 0
utils/opensc/patches/0027-OpenPGP-Remove-unused-variables-and-fix-type-cast.patch View File

@@ -0,0 +1,82 @@
1
+From 99b5cb53e1da2f0d7692f28dceff8485d4b74daf 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: Wed, 10 Dec 2014 03:59:54 +0800
5
+Subject: [PATCH 1/2] OpenPGP: Remove unused variables and fix type cast.
6
+
7
+---
8
+ src/libopensc/card-openpgp.c | 10 +++-------
9
+ src/tools/openpgp-tool.c     |  4 +---
10
+ 2 files changed, 4 insertions(+), 10 deletions(-)
11
+
12
+Index: opensc-20150513/src/libopensc/card-openpgp.c
13
+===================================================================
14
+--- opensc-20150513.orig/src/libopensc/card-openpgp.c
15
++++ opensc-20150513/src/libopensc/card-openpgp.c
16
+@@ -1966,8 +1966,6 @@ static int pgp_update_card_algorithms(sc
17
+  **/
18
+ static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info)
19
+ {
20
+-	struct pgp_priv_data *priv = DRVDATA(card);
21
+-	pgp_blob_t *algo_blob;
22
+ 	sc_apdu_t apdu;
23
+ 	/* Temporary variables to hold APDU params */
24
+ 	u8 apdu_case;
25
+@@ -2396,10 +2394,9 @@ static int pgp_erase_card(sc_card_t *car
26
+ 		{0, 0x44, 0, 0}
27
+ 	};
28
+ 	u8 apdu_lens[10] = {13, 13, 13, 13, 13, 13, 13, 13, 4, 4};
29
+-	u8 buf[SC_MAX_APDU_BUFFER_SIZE];
30
+ 	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
31
+ 	sc_apdu_t apdu;
32
+-	int i, l, r;
33
++	u8 i, l, r;
34
+ 
35
+ 	LOG_FUNC_CALLED(ctx);
36
+ 
37
+@@ -2478,7 +2475,7 @@ gnuk_delete_key(sc_card_t *card, u8 key_
38
+ {
39
+ 	sc_context_t *ctx = card->ctx;
40
+ 	int r = SC_SUCCESS;
41
+-	u8 *data = NULL;
42
++	char *data = NULL;
43
+ 
44
+ 	LOG_FUNC_CALLED(ctx);
45
+ 
46
+@@ -2506,7 +2503,7 @@ gnuk_delete_key(sc_card_t *card, u8 key_
47
+ 	else if (key_id == 3)
48
+ 		data = "\x4D\x02\xA4";
49
+ 
50
+-	r = pgp_put_data(card, 0x4D, data, strlen(data) + 1);
51
++	r = pgp_put_data(card, 0x4D, (const u8 *)data, strlen((const char *)data) + 1);
52
+ 
53
+ 	LOG_FUNC_RETURN(ctx, r);
54
+ }
55
+@@ -2519,7 +2516,6 @@ pgp_delete_file(sc_card_t *card, const s
56
+ 	struct pgp_priv_data *priv = DRVDATA(card);
57
+ 	pgp_blob_t *blob;
58
+ 	sc_file_t *file;
59
+-	u8 key_id;
60
+ 	int r;
61
+ 
62
+ 	LOG_FUNC_CALLED(card->ctx);
63
+Index: opensc-20150513/src/tools/openpgp-tool.c
64
+===================================================================
65
+--- opensc-20150513.orig/src/tools/openpgp-tool.c
66
++++ opensc-20150513/src/tools/openpgp-tool.c
67
+@@ -473,7 +473,6 @@ int do_verify(sc_card_t *card, char *typ
68
+  **/
69
+ int delete_key_openpgp(sc_card_t *card, u8 key_id)
70
+ {
71
+-	sc_context_t *ctx = card->ctx;
72
+ 	char *del_fingerprint = "00:DA:00:C6:14:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00";
73
+ 	char *del_creationtime = "00:DA:00:CD:04:00:00:00:00";
74
+ 	/* We need to replace the 4th byte later */
75
+@@ -520,7 +519,6 @@ int delete_key_openpgp(sc_card_t *card,
76
+ 
77
+ int do_delete_key(sc_card_t *card, u8 key_id)
78
+ {
79
+-	sc_context_t *ctx = card->ctx;
80
+ 	sc_path_t path;
81
+ 	int r = SC_SUCCESS;
82
+ 

+ 28
- 0
utils/opensc/patches/0028-openpgp-tool-Fix-wrong-operator.patch View File

@@ -0,0 +1,28 @@
1
+From c71a453ff1e19721a9245b8a2d637eabd9f12e54 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: Thu, 11 Dec 2014 12:51:15 +0800
5
+Subject: [PATCH 2/2] openpgp-tool: Fix wrong operator
6
+
7
+Used "!=" instead of "|="
8
+---
9
+ src/tools/openpgp-tool.c | 4 ++--
10
+ 1 file changed, 2 insertions(+), 2 deletions(-)
11
+
12
+Index: opensc-20150513/src/tools/openpgp-tool.c
13
+===================================================================
14
+--- opensc-20150513.orig/src/tools/openpgp-tool.c
15
++++ opensc-20150513/src/tools/openpgp-tool.c
16
+@@ -639,10 +639,10 @@ int main(int argc, char **argv)
17
+ 	}
18
+ 
19
+ 	if (opt_delkey)
20
+-		exit_status != do_delete_key(card, key_id);
21
++		exit_status |= do_delete_key(card, key_id);
22
+ 
23
+ 	if (opt_erase)
24
+-		exit_status != do_erase(card);
25
++		exit_status |= do_erase(card);
26
+ 
27
+ out:
28
+ 	sc_unlock(card);