Browse Source

opensc: update source, refresh patches

Also import two new GnuK-related patches.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
lilik-openwrt-22.03
Daniel Golle 9 years ago
parent
commit
764c55e013
29 changed files with 361 additions and 329 deletions
  1. +2
    -2
      utils/opensc/Makefile
  2. +30
    -33
      utils/opensc/patches/0001-OpenPGP-Detect-and-support-Gnuk-Token.patch
  3. +11
    -14
      utils/opensc/patches/0002-OpenPGP-Add-Gnuk-in-pkcs15-emulation-layer.patch
  4. +5
    -8
      utils/opensc/patches/0003-OpenPGP-Include-private-DO-to-filesystem-at-driver-i.patch
  5. +8
    -11
      utils/opensc/patches/0004-PKCS15-OpenPGP-Declare-DATA-objects.patch
  6. +14
    -17
      utils/opensc/patches/0005-OpenPGP-Support-erasing-reset-card.patch
  7. +7
    -10
      utils/opensc/patches/0006-openpgp-tool-Support-deleting-key-in-Gnuk.patch
  8. +5
    -8
      utils/opensc/patches/0007-OpenPGP-Correct-building-Extended-Header-List-when-i.patch
  9. +6
    -9
      utils/opensc/patches/0008-OpenPGP-Read-some-empty-DOs-from-Gnuk.patch
  10. +5
    -8
      utils/opensc/patches/0009-PKCS15-OpenPGP-Do-not-show-empty-DO-in-pkcs15-emu_in.patch
  11. +11
    -14
      utils/opensc/patches/0010-PKCS15-OpenPGP-Allow-to-store-data-to-pkcs15-data-ob.patch
  12. +8
    -11
      utils/opensc/patches/0011-OpenPGP-Provide-enough-buffer-to-read-pubkey-from-Gn.patch
  13. +8
    -11
      utils/opensc/patches/0012-OpenPGP-Support-write-certificate-for-Gnuk.patch
  14. +5
    -8
      utils/opensc/patches/0013-pkcs15-openpgp-Change-to-sc_put_data-instead-of-sc_u.patch
  15. +6
    -9
      utils/opensc/patches/0014-OpenPGP-Overcome-the-restriction-of-even-data-length.patch
  16. +7
    -10
      utils/opensc/patches/0015-OpenPGP-Delete-key-as-file-for-Gnuk.patch
  17. +7
    -10
      utils/opensc/patches/0016-OpenPGP-Correct-parameter-checking.patch
  18. +6
    -9
      utils/opensc/patches/0017-OpenPGP-Make-code-neater.patch
  19. +6
    -9
      utils/opensc/patches/0018-Move-declaration-to-top-of-block.patch
  20. +14
    -17
      utils/opensc/patches/0019-OpenPGP-Make-indentation-consistent-space-tab.patch
  21. +8
    -11
      utils/opensc/patches/0020-OpenPGP-Don-t-use-sc_log-in-openpgp-tool.patch
  22. +7
    -10
      utils/opensc/patches/0021-OpenPGP-Don-t-reimplement-gnuk_delete_key-in-openpgp.patch
  23. +6
    -9
      utils/opensc/patches/0022-OpenPGP-Use-directly-binary-array-of-APDUs-for-ERASE.patch
  24. +35
    -38
      utils/opensc/patches/0023-OpenPGP-Rename-private-blob-type-to-avoid-confusing-.patch
  25. +7
    -10
      utils/opensc/patches/0024-OpenPGP-Fix-crash-after-accessing-inexistent-file.patch
  26. +10
    -13
      utils/opensc/patches/0025-Replace-hardcode.patch
  27. +7
    -10
      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 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=opensc PKG_NAME:=opensc
PKG_VERSION:=20141126
PKG_VERSION:=20150513
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_LICENSE:=LGPL-2.1+ PKG_LICENSE:=LGPL-2.1+
PKG_LICENSE_FILES:=COPYING PKG_LICENSE_FILES:=COPYING
@ -19,7 +19,7 @@ PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/OpenSC/OpenSC.git PKG_SOURCE_URL:=https://github.com/OpenSC/OpenSC.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=8aadbbd678730dbafb819382da553439887499fd
PKG_SOURCE_VERSION:=a09ca246a797230c14bc33a34f2dddc4a4dbff40
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_BUILD_DEPENDS:=+libpcsclite PKG_BUILD_DEPENDS:=+libpcsclite
PKG_FIXUP:=libtool PKG_FIXUP:=libtool


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

@ -11,11 +11,11 @@ http://www.fsij.org/gnuk/
src/tools/openpgp-tool.c | 7 ++++- src/tools/openpgp-tool.c | 7 ++++-
3 files changed, 55 insertions(+), 14 deletions(-) 3 files changed, 55 insertions(+), 14 deletions(-)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index 6774fe1..c785a55 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -43,6 +43,7 @@
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -45,6 +45,7 @@
static struct sc_atr_table pgp_atrs[] = { static struct sc_atr_table pgp_atrs[] = {
{ "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 }, { "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 },
{ "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 }, { "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
{ NULL, NULL, NULL, 0, 0, NULL } { NULL, NULL, NULL, 0, 0, NULL }
}; };
@@ -307,6 +308,8 @@ pgp_init(sc_card_t *card)
@@ -309,6 +310,8 @@ pgp_init(sc_card_t *card)
int r; int r;
struct blob *child = NULL;
struct blob *child = NULL;
+ LOG_FUNC_CALLED(card->ctx); + LOG_FUNC_CALLED(card->ctx);
+ +
priv = calloc (1, sizeof *priv); priv = calloc (1, sizeof *priv);
if (!priv) if (!priv)
return SC_ERROR_OUT_OF_MEMORY; return SC_ERROR_OUT_OF_MEMORY;
@@ -315,11 +318,11 @@ pgp_init(sc_card_t *card)
@@ -317,11 +320,11 @@ pgp_init(sc_card_t *card)
card->cla = 0x00; card->cla = 0x00;
/* set pointer to correct list of card objects */ /* set pointer to correct list of card objects */
@ -46,7 +46,7 @@ index 6774fe1..c785a55 100644
? OPENPGP_CARD_2_0 : OPENPGP_CARD_1_1; ? OPENPGP_CARD_2_0 : OPENPGP_CARD_1_1;
/* select application "OpenPGP" */ /* select application "OpenPGP" */
@@ -428,7 +431,8 @@ pgp_get_card_features(sc_card_t *card)
@@ -436,7 +439,8 @@ pgp_get_card_features(sc_card_t *card)
if ((pgp_get_blob(card, blob73, 0x00c0, &blob) >= 0) && if ((pgp_get_blob(card, blob73, 0x00c0, &blob) >= 0) &&
(blob->data != NULL) && (blob->len > 0)) { (blob->data != NULL) && (blob->len > 0)) {
/* in v2.0 bit 0x04 in first byte means "algorithm attributes changeable */ /* in v2.0 bit 0x04 in first byte means "algorithm attributes changeable */
@ -56,7 +56,7 @@ index 6774fe1..c785a55 100644
priv->ext_caps |= EXT_CAP_ALG_ATTR_CHANGEABLE; priv->ext_caps |= EXT_CAP_ALG_ATTR_CHANGEABLE;
/* bit 0x08 in first byte means "support for private use DOs" */ /* bit 0x08 in first byte means "support for private use DOs" */
if (blob->data[0] & 0x08) if (blob->data[0] & 0x08)
@@ -445,7 +449,8 @@ pgp_get_card_features(sc_card_t *card)
@@ -453,7 +457,8 @@ pgp_get_card_features(sc_card_t *card)
priv->ext_caps |= EXT_CAP_GET_CHALLENGE; priv->ext_caps |= EXT_CAP_GET_CHALLENGE;
} }
/* in v2.0 bit 0x80 in first byte means "support Secure Messaging" */ /* in v2.0 bit 0x80 in first byte means "support Secure Messaging" */
@ -66,7 +66,7 @@ index 6774fe1..c785a55 100644
priv->ext_caps |= EXT_CAP_SM; priv->ext_caps |= EXT_CAP_SM;
if ((priv->bcd_version >= OPENPGP_CARD_2_0) && (blob->len >= 10)) { if ((priv->bcd_version >= OPENPGP_CARD_2_0) && (blob->len >= 10)) {
@@ -1057,12 +1062,18 @@ static int
@@ -1065,12 +1070,18 @@ static int
pgp_get_pubkey(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len) pgp_get_pubkey(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len)
{ {
sc_apdu_t apdu; sc_apdu_t apdu;
@ -86,7 +86,7 @@ index 6774fe1..c785a55 100644
apdu.lc = 2; apdu.lc = 2;
apdu.data = ushort2bebytes(idbuf, tag); apdu.data = ushort2bebytes(idbuf, tag);
apdu.datalen = 2; apdu.datalen = 2;
@@ -1154,6 +1165,7 @@ pgp_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t buf_len)
@@ -1162,6 +1173,7 @@ pgp_put_data(sc_card_t *card, unsigned i
u8 ins = 0xDA; u8 ins = 0xDA;
u8 p1 = tag >> 8; u8 p1 = tag >> 8;
u8 p2 = tag & 0xFF; u8 p2 = tag & 0xFF;
@ -94,7 +94,7 @@ index 6774fe1..c785a55 100644
int r; int r;
LOG_FUNC_CALLED(card->ctx); LOG_FUNC_CALLED(card->ctx);
@@ -1195,13 +1207,17 @@ pgp_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t buf_len)
@@ -1203,13 +1215,17 @@ pgp_put_data(sc_card_t *card, unsigned i
/* Build APDU */ /* Build APDU */
if (buf != NULL && buf_len > 0) { if (buf != NULL && buf_len > 0) {
@ -114,7 +114,7 @@ index 6774fe1..c785a55 100644
apdu.datalen = buf_len; apdu.datalen = buf_len;
apdu.lc = buf_len; apdu.lc = buf_len;
} }
@@ -1328,6 +1344,7 @@ pgp_compute_signature(sc_card_t *card, const u8 *data,
@@ -1336,6 +1352,7 @@ pgp_compute_signature(sc_card_t *card, c
struct pgp_priv_data *priv = DRVDATA(card); struct pgp_priv_data *priv = DRVDATA(card);
sc_security_env_t *env = &priv->sec_env; sc_security_env_t *env = &priv->sec_env;
sc_apdu_t apdu; sc_apdu_t apdu;
@ -122,7 +122,7 @@ index 6774fe1..c785a55 100644
int r; int r;
LOG_FUNC_CALLED(card->ctx); LOG_FUNC_CALLED(card->ctx);
@@ -1336,14 +1353,19 @@ pgp_compute_signature(sc_card_t *card, const u8 *data,
@@ -1344,14 +1361,19 @@ pgp_compute_signature(sc_card_t *card, c
LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
"invalid operation"); "invalid operation");
@ -144,7 +144,7 @@ index 6774fe1..c785a55 100644
break; break;
case 0x01: case 0x01:
default: default:
@@ -1352,7 +1374,7 @@ pgp_compute_signature(sc_card_t *card, const u8 *data,
@@ -1360,7 +1382,7 @@ pgp_compute_signature(sc_card_t *card, c
} }
apdu.lc = data_len; apdu.lc = data_len;
@ -153,7 +153,7 @@ index 6774fe1..c785a55 100644
apdu.datalen = data_len; apdu.datalen = data_len;
apdu.le = ((outlen >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : outlen; apdu.le = ((outlen >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : outlen;
apdu.resp = out; apdu.resp = out;
@@ -1376,6 +1398,7 @@ pgp_decipher(sc_card_t *card, const u8 *in, size_t inlen,
@@ -1384,6 +1406,7 @@ pgp_decipher(sc_card_t *card, const u8 *
struct pgp_priv_data *priv = DRVDATA(card); struct pgp_priv_data *priv = DRVDATA(card);
sc_security_env_t *env = &priv->sec_env; sc_security_env_t *env = &priv->sec_env;
sc_apdu_t apdu; sc_apdu_t apdu;
@ -161,7 +161,7 @@ index 6774fe1..c785a55 100644
u8 *temp = NULL; u8 *temp = NULL;
int r; int r;
@@ -1400,7 +1423,7 @@ pgp_decipher(sc_card_t *card, const u8 *in, size_t inlen,
@@ -1408,7 +1431,7 @@ pgp_decipher(sc_card_t *card, const u8 *
case 0x01: /* Decryption key */ case 0x01: /* Decryption key */
case 0x02: /* authentication key */ case 0x02: /* authentication key */
/* PSO DECIPHER */ /* PSO DECIPHER */
@ -170,7 +170,7 @@ index 6774fe1..c785a55 100644
break; break;
case 0x00: /* signature key */ case 0x00: /* signature key */
default: default:
@@ -1409,8 +1432,13 @@ pgp_decipher(sc_card_t *card, const u8 *in, size_t inlen,
@@ -1417,8 +1440,13 @@ pgp_decipher(sc_card_t *card, const u8 *
"invalid key reference"); "invalid key reference");
} }
@ -185,7 +185,7 @@ index 6774fe1..c785a55 100644
apdu.datalen = inlen; apdu.datalen = inlen;
apdu.le = ((outlen >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : outlen; apdu.le = ((outlen >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : outlen;
apdu.resp = out; apdu.resp = out;
@@ -1794,6 +1822,11 @@ static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_in
@@ -1802,6 +1830,11 @@ static int pgp_gen_key(sc_card_t *card,
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
} }
@ -197,7 +197,7 @@ index 6774fe1..c785a55 100644
/* Set attributes for new-generated key */ /* Set attributes for new-generated key */
r = pgp_update_new_algo_attr(card, key_info); r = pgp_update_new_algo_attr(card, key_info);
LOG_TEST_RET(card->ctx, r, "Cannot set attributes for new-generated key"); LOG_TEST_RET(card->ctx, r, "Cannot set attributes for new-generated key");
@@ -1801,7 +1834,9 @@ static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_in
@@ -1809,7 +1842,9 @@ static int pgp_gen_key(sc_card_t *card,
/* Test whether we will need extended APDU. 1900 is an /* Test whether we will need extended APDU. 1900 is an
* arbitrary modulus length which for sure fits into a short APDU. * arbitrary modulus length which for sure fits into a short APDU.
* This idea is borrowed from GnuPG code. */ * This idea is borrowed from GnuPG code. */
@ -208,10 +208,10 @@ index 6774fe1..c785a55 100644
/* We won't store to apdu variable yet, because it will be reset in /* We won't store to apdu variable yet, because it will be reset in
* sc_format_apdu() */ * sc_format_apdu() */
apdu_le = card->max_recv_size; apdu_le = card->max_recv_size;
diff --git a/src/libopensc/cards.h b/src/libopensc/cards.h
index 7be6667..a3f3634 100644
--- a/src/libopensc/cards.h
+++ b/src/libopensc/cards.h
Index: opensc-20150513/src/libopensc/cards.h
===================================================================
--- opensc-20150513.orig/src/libopensc/cards.h
+++ opensc-20150513/src/libopensc/cards.h
@@ -105,6 +105,7 @@ enum { @@ -105,6 +105,7 @@ enum {
SC_CARD_TYPE_OPENPGP_BASE = 9000, SC_CARD_TYPE_OPENPGP_BASE = 9000,
SC_CARD_TYPE_OPENPGP_V1, SC_CARD_TYPE_OPENPGP_V1,
@ -220,10 +220,10 @@ index 7be6667..a3f3634 100644
/* jcop driver */ /* jcop driver */
SC_CARD_TYPE_JCOP_BASE = 10000, SC_CARD_TYPE_JCOP_BASE = 10000,
diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c
index f42e6d6..a24a395 100644
--- a/src/tools/openpgp-tool.c
+++ b/src/tools/openpgp-tool.c
Index: opensc-20150513/src/tools/openpgp-tool.c
===================================================================
--- opensc-20150513.orig/src/tools/openpgp-tool.c
+++ opensc-20150513/src/tools/openpgp-tool.c
@@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
#include "libopensc/cards.h" #include "libopensc/cards.h"
#include "libopensc/cardctl.h" #include "libopensc/cardctl.h"
@ -232,7 +232,7 @@ index f42e6d6..a24a395 100644
#include "util.h" #include "util.h"
#include "libopensc/log.h" #include "libopensc/log.h"
@@ -396,6 +397,8 @@ int do_genkey(sc_card_t *card, u8 key_id, unsigned int key_len)
@@ -396,6 +397,8 @@ int do_genkey(sc_card_t *card, u8 key_id
sc_path_t path; sc_path_t path;
sc_file_t *file; sc_file_t *file;
@ -253,6 +253,3 @@ index f42e6d6..a24a395 100644
exit_status = EXIT_FAILURE; exit_status = EXIT_FAILURE;
goto out; goto out;
} }
--
2.1.3

+ 11
- 14
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.
src/libopensc/pkcs15-syn.c | 1 + src/libopensc/pkcs15-syn.c | 1 +
2 files changed, 5 insertions(+), 2 deletions(-) 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/libopensc/pkcs15-openpgp.c b/src/libopensc/pkcs15-openpgp.c
index 4daaa98..fdf720a 100644
--- a/src/libopensc/pkcs15-openpgp.c
+++ b/src/libopensc/pkcs15-openpgp.c
@@ -151,7 +151,8 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
Index: opensc-20150513/src/libopensc/pkcs15-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/pkcs15-openpgp.c
+++ opensc-20150513/src/libopensc/pkcs15-openpgp.c
@@ -153,7 +153,8 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card
u8 c4data[10]; u8 c4data[10];
u8 c5data[70]; u8 c5data[70];
int r, i; int r, i;
@ -23,7 +23,7 @@ index 4daaa98..fdf720a 100644
sc_path_t path; sc_path_t path;
sc_file_t *file; sc_file_t *file;
@@ -363,7 +364,8 @@ failed: sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Failed to initialize OpenPGP e
@@ -365,7 +366,8 @@ failed: sc_debug(card->ctx, SC_LOG_DEBUG
static int openpgp_detect_card(sc_pkcs15_card_t *p15card) static int openpgp_detect_card(sc_pkcs15_card_t *p15card)
{ {
@ -33,11 +33,11 @@ index 4daaa98..fdf720a 100644
return SC_SUCCESS; return SC_SUCCESS;
else else
return SC_ERROR_WRONG_CARD; return SC_ERROR_WRONG_CARD;
diff --git a/src/libopensc/pkcs15-syn.c b/src/libopensc/pkcs15-syn.c
index ffbf642..d2c086c 100644
--- a/src/libopensc/pkcs15-syn.c
+++ b/src/libopensc/pkcs15-syn.c
@@ -115,6 +115,7 @@ int sc_pkcs15_is_emulation_only(sc_card_t *card)
Index: opensc-20150513/src/libopensc/pkcs15-syn.c
===================================================================
--- opensc-20150513.orig/src/libopensc/pkcs15-syn.c
+++ opensc-20150513/src/libopensc/pkcs15-syn.c
@@ -117,6 +117,7 @@ int sc_pkcs15_is_emulation_only(sc_card_
case SC_CARD_TYPE_GEMSAFEV1_PTEID: case SC_CARD_TYPE_GEMSAFEV1_PTEID:
case SC_CARD_TYPE_OPENPGP_V1: case SC_CARD_TYPE_OPENPGP_V1:
case SC_CARD_TYPE_OPENPGP_V2: case SC_CARD_TYPE_OPENPGP_V2:
@ -45,6 +45,3 @@ index ffbf642..d2c086c 100644
case SC_CARD_TYPE_SC_HSM: case SC_CARD_TYPE_SC_HSM:
case SC_CARD_TYPE_DNIE_BASE: case SC_CARD_TYPE_DNIE_BASE:
case SC_CARD_TYPE_DNIE_BLANK: case SC_CARD_TYPE_DNIE_BLANK:
--
2.1.3

+ 5
- 8
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.
src/libopensc/card-openpgp.c | 2 +- src/libopensc/card-openpgp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index c785a55..1cc3923 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -357,7 +357,7 @@ pgp_init(sc_card_t *card)
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -365,7 +365,7 @@ pgp_init(sc_card_t *card)
/* Populate MF - add matching blobs listed in the pgp_objects table. */ /* Populate MF - add matching blobs listed in the pgp_objects table. */
for (info = priv->pgp_objects; (info != NULL) && (info->id > 0); info++) { for (info = priv->pgp_objects; (info != NULL) && (info->id > 0); info++) {
@ -25,6 +25,3 @@ index c785a55..1cc3923 100644
(info->get_fn != NULL)) { (info->get_fn != NULL)) {
child = pgp_new_blob(card, priv->mf, info->id, sc_file_new()); child = pgp_new_blob(card, priv->mf, info->id, sc_file_new());
--
2.1.3

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

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

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

@ -10,11 +10,11 @@ Command: openpgp-tool --erase
src/tools/openpgp-tool.c | 22 ++++++++++++++- src/tools/openpgp-tool.c | 22 ++++++++++++++-
2 files changed, 85 insertions(+), 1 deletion(-) 2 files changed, 85 insertions(+), 1 deletion(-)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index 1cc3923..7349876 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -2195,6 +2195,66 @@ out:
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -2206,6 +2206,66 @@ out:
#endif /* ENABLE_OPENSSL */ #endif /* ENABLE_OPENSSL */
@ -81,7 +81,7 @@ index 1cc3923..7349876 100644
/* ABI: card ctl: perform special card-specific operations */ /* ABI: card ctl: perform special card-specific operations */
static int pgp_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr) static int pgp_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr)
{ {
@@ -2219,6 +2279,10 @@ static int pgp_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr)
@@ -2232,6 +2292,10 @@ static int pgp_card_ctl(sc_card_t *card,
LOG_FUNC_RETURN(card->ctx, r); LOG_FUNC_RETURN(card->ctx, r);
break; break;
#endif /* ENABLE_OPENSSL */ #endif /* ENABLE_OPENSSL */
@ -92,12 +92,12 @@ index 1cc3923..7349876 100644
} }
LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c
index a24a395..de1c9d4 100644
--- a/src/tools/openpgp-tool.c
+++ b/src/tools/openpgp-tool.c
Index: opensc-20150513/src/tools/openpgp-tool.c
===================================================================
--- opensc-20150513.orig/src/tools/openpgp-tool.c
+++ opensc-20150513/src/tools/openpgp-tool.c
@@ -78,6 +78,7 @@ static int opt_pin = 0; @@ -78,6 +78,7 @@ static int opt_pin = 0;
static char *pin = NULL;
static const char *pin = NULL;
static int opt_dump_do = 0; static int opt_dump_do = 0;
static u8 do_dump_idx; static u8 do_dump_idx;
+static int opt_erase = 0; +static int opt_erase = 0;
@ -120,7 +120,7 @@ index a24a395..de1c9d4 100644
"Verify PIN (CHV1, CHV2, CHV3...)", "Verify PIN (CHV1, CHV2, CHV3...)",
"PIN string", "PIN string",
/* d */ "Dump private data object number <arg> (i.e. PRIVATE-DO-<arg>)" /* d */ "Dump private data object number <arg> (i.e. PRIVATE-DO-<arg>)"
@@ -232,7 +235,7 @@ static int decode_options(int argc, char **argv)
@@ -232,7 +235,7 @@ static int decode_options(int argc, char
{ {
int c; int c;
@ -129,7 +129,7 @@ index a24a395..de1c9d4 100644
switch (c) { switch (c) {
case 'r': case 'r':
opt_reader = optarg; opt_reader = optarg;
@@ -296,6 +299,8 @@ static int decode_options(int argc, char **argv)
@@ -294,6 +297,8 @@ static int decode_options(int argc, char
do_dump_idx = optarg[0] - '0'; do_dump_idx = optarg[0] - '0';
opt_dump_do++; opt_dump_do++;
actions++; actions++;
@ -138,7 +138,7 @@ index a24a395..de1c9d4 100644
break; break;
default: default:
util_print_usage_and_die(app_name, options, option_help, NULL); util_print_usage_and_die(app_name, options, option_help, NULL);
@@ -452,6 +457,18 @@ int do_verify(sc_card_t *card, char *type, char *pin)
@@ -452,6 +457,18 @@ int do_verify(sc_card_t *card, char *typ
return r; return r;
} }
@ -167,6 +167,3 @@ index a24a395..de1c9d4 100644
out: out:
sc_unlock(card); sc_unlock(card);
sc_disconnect_card(card); sc_disconnect_card(card);
--
2.1.3

+ 7
- 10
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.
src/tools/openpgp-tool.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++ src/tools/openpgp-tool.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 142 insertions(+) 1 file changed, 142 insertions(+)
diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c
index de1c9d4..374819a 100644
--- a/src/tools/openpgp-tool.c
+++ b/src/tools/openpgp-tool.c
Index: opensc-20150513/src/tools/openpgp-tool.c
===================================================================
--- opensc-20150513.orig/src/tools/openpgp-tool.c
+++ opensc-20150513/src/tools/openpgp-tool.c
@@ -41,6 +41,7 @@ @@ -41,6 +41,7 @@
#define OPT_PRETTY 257 #define OPT_PRETTY 257
#define OPT_VERIFY 258 #define OPT_VERIFY 258
@ -20,7 +20,7 @@ index de1c9d4..374819a 100644
/* define structures */ /* define structures */
struct ef_name_map { struct ef_name_map {
@@ -79,6 +80,7 @@ static char *pin = NULL;
@@ -79,6 +80,7 @@ static const char *pin = NULL;
static int opt_dump_do = 0; static int opt_dump_do = 0;
static u8 do_dump_idx; static u8 do_dump_idx;
static int opt_erase = 0; static int opt_erase = 0;
@ -44,7 +44,7 @@ index de1c9d4..374819a 100644
/* d */ "Dump private data object number <arg> (i.e. PRIVATE-DO-<arg>)" /* d */ "Dump private data object number <arg> (i.e. PRIVATE-DO-<arg>)"
}; };
@@ -302,6 +306,14 @@ static int decode_options(int argc, char **argv)
@@ -300,6 +304,14 @@ static int decode_options(int argc, char
case 'E': case 'E':
opt_erase++; opt_erase++;
break; break;
@ -59,7 +59,7 @@ index de1c9d4..374819a 100644
default: default:
util_print_usage_and_die(app_name, options, option_help, NULL); util_print_usage_and_die(app_name, options, option_help, NULL);
} }
@@ -457,6 +469,133 @@ int do_verify(sc_card_t *card, char *type, char *pin)
@@ -457,6 +469,133 @@ int do_verify(sc_card_t *card, char *typ
return r; return r;
} }
@ -203,6 +203,3 @@ index de1c9d4..374819a 100644
if (opt_erase) if (opt_erase)
exit_status != do_erase(card); exit_status != do_erase(card);
--
2.1.3

+ 5
- 8
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
src/libopensc/card-openpgp.c | 2 +- src/libopensc/card-openpgp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index 7349876..91c311b 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -1977,7 +1977,7 @@ pgp_build_extended_header_list(sc_card_t *card, sc_cardctl_openpgp_keystore_info
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -1988,7 +1988,7 @@ pgp_build_extended_header_list(sc_card_t
u8 *p = NULL; u8 *p = NULL;
u8 *components[] = {key_info->e, key_info->p, key_info->q, key_info->n}; u8 *components[] = {key_info->e, key_info->p, key_info->q, key_info->n};
size_t componentlens[] = {key_info->e_len, key_info->p_len, key_info->q_len, key_info->n_len}; 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
char *componentnames[] = { char *componentnames[] = {
"public exponent", "public exponent",
"prime p", "prime p",
--
2.1.3

+ 6
- 9
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.
src/libopensc/card-openpgp.c | 25 +++++++++++++++++++++++++ src/libopensc/card-openpgp.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+) 1 file changed, 25 insertions(+)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index 91c311b..e7b25c0 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -815,6 +815,23 @@ pgp_get_blob(sc_card_t *card, struct blob *blob, unsigned int id,
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -823,6 +823,23 @@ pgp_get_blob(sc_card_t *card, struct blo
} }
} }
@ -38,7 +38,7 @@ index 91c311b..e7b25c0 100644
return SC_ERROR_FILE_NOT_FOUND; return SC_ERROR_FILE_NOT_FOUND;
} }
@@ -1149,6 +1166,14 @@ pgp_get_data(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len)
@@ -1157,6 +1174,14 @@ pgp_get_data(sc_card_t *card, unsigned i
LOG_TEST_RET(card->ctx, r, "APDU transmit failed"); LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
r = sc_check_sw(card, apdu.sw1, apdu.sw2); r = sc_check_sw(card, apdu.sw1, apdu.sw2);
@ -53,6 +53,3 @@ index 91c311b..e7b25c0 100644
LOG_TEST_RET(card->ctx, r, "Card returned error"); LOG_TEST_RET(card->ctx, r, "Card returned error");
LOG_FUNC_RETURN(card->ctx, apdu.resplen); LOG_FUNC_RETURN(card->ctx, apdu.resplen);
--
2.1.3

+ 5
- 8
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
src/libopensc/pkcs15-openpgp.c | 18 ++++++++++++++++++ src/libopensc/pkcs15-openpgp.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+) 1 file changed, 18 insertions(+)
diff --git a/src/libopensc/pkcs15-openpgp.c b/src/libopensc/pkcs15-openpgp.c
index fea2805..51a2032 100644
--- a/src/libopensc/pkcs15-openpgp.c
+++ b/src/libopensc/pkcs15-openpgp.c
@@ -381,16 +381,34 @@ sc_pkcs15emu_openpgp_add_data(sc_pkcs15_card_t *p15card)
Index: opensc-20150513/src/libopensc/pkcs15-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/pkcs15-openpgp.c
+++ opensc-20150513/src/libopensc/pkcs15-openpgp.c
@@ -383,16 +383,34 @@ sc_pkcs15emu_openpgp_add_data(sc_pkcs15_
sc_pkcs15_object_t dat_obj; sc_pkcs15_object_t dat_obj;
char name[8]; char name[8];
char path[9]; char path[9];
@ -48,6 +48,3 @@ index fea2805..51a2032 100644
sc_log(ctx, "Add %s data object", name); sc_log(ctx, "Add %s data object", name);
r = sc_pkcs15emu_add_data_object(p15card, &dat_obj, &dat_info); r = sc_pkcs15emu_add_data_object(p15card, &dat_obj, &dat_info);
} }
--
2.1.3

+ 11
- 14
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.
src/pkcs15init/pkcs15-openpgp.c | 38 +++++++++++++++++++++++++++++++++++++- src/pkcs15init/pkcs15-openpgp.c | 38 +++++++++++++++++++++++++++++++++++++-
2 files changed, 38 insertions(+), 2 deletions(-) 2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/src/libopensc/pkcs15-openpgp.c b/src/libopensc/pkcs15-openpgp.c
index 51a2032..4cc1c39 100644
--- a/src/libopensc/pkcs15-openpgp.c
+++ b/src/libopensc/pkcs15-openpgp.c
@@ -393,7 +393,7 @@ sc_pkcs15emu_openpgp_add_data(sc_pkcs15_card_t *p15card)
Index: opensc-20150513/src/libopensc/pkcs15-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/pkcs15-openpgp.c
+++ opensc-20150513/src/libopensc/pkcs15-openpgp.c
@@ -395,7 +395,7 @@ sc_pkcs15emu_openpgp_add_data(sc_pkcs15_
*/ */
r = read_file(p15card->card, path, content, sizeof(content)); r = read_file(p15card->card, path, content, sizeof(content));
if (r <= 0 ) { if (r <= 0 ) {
@ -24,11 +24,11 @@ index 51a2032..4cc1c39 100644
/* Skip */ /* Skip */
continue; continue;
} }
diff --git a/src/pkcs15init/pkcs15-openpgp.c b/src/pkcs15init/pkcs15-openpgp.c
index f3a4962..1455580 100755
--- a/src/pkcs15init/pkcs15-openpgp.c
+++ b/src/pkcs15init/pkcs15-openpgp.c
@@ -236,13 +236,16 @@ static int openpgp_emu_update_tokeninfo(sc_profile_t *profile, sc_pkcs15_card_t
Index: opensc-20150513/src/pkcs15init/pkcs15-openpgp.c
===================================================================
--- opensc-20150513.orig/src/pkcs15init/pkcs15-openpgp.c
+++ opensc-20150513/src/pkcs15init/pkcs15-openpgp.c
@@ -236,13 +236,16 @@ static int openpgp_emu_update_tokeninfo(
} }
static int openpgp_store_data(struct sc_pkcs15_card *p15card, struct sc_profile *profile, static int openpgp_store_data(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
@ -46,7 +46,7 @@ index f3a4962..1455580 100755
int r; int r;
LOG_FUNC_CALLED(card->ctx); LOG_FUNC_CALLED(card->ctx);
@@ -282,6 +285,39 @@ static int openpgp_store_data(struct sc_pkcs15_card *p15card, struct sc_profile
@@ -282,6 +285,39 @@ static int openpgp_store_data(struct sc_
content->len, 0); content->len, 0);
break; break;
@ -86,6 +86,3 @@ index f3a4962..1455580 100755
default: default:
r = SC_ERROR_NOT_IMPLEMENTED; r = SC_ERROR_NOT_IMPLEMENTED;
} }
--
2.1.3

+ 8
- 11
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
src/libopensc/card-openpgp.c | 28 +++++++++++++++++++++++----- src/libopensc/card-openpgp.c | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-) 1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index e7b25c0..1913eca 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -263,7 +263,12 @@ static struct do_info pgp2_objects[] = { /* OpenPGP card spec 2.0 */
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -265,7 +265,12 @@ static struct do_info pgp2_objects[] =
/* The DO holding X.509 certificate is constructed but does not contain child DO. /* The DO holding X.509 certificate is constructed but does not contain child DO.
* We should notice this when building fake file system later. */ * We should notice this when building fake file system later. */
@ -27,7 +27,7 @@ index e7b25c0..1913eca 100644
#define DRVDATA(card) ((struct pgp_priv_data *) ((card)->drv_data)) #define DRVDATA(card) ((struct pgp_priv_data *) ((card)->drv_data))
struct pgp_priv_data { struct pgp_priv_data {
@@ -731,6 +736,14 @@ pgp_read_blob(sc_card_t *card, struct blob *blob)
@@ -739,6 +744,14 @@ pgp_read_blob(sc_card_t *card, struct bl
u8 buffer[2048]; u8 buffer[2048];
size_t buf_len = (card->caps & SC_CARD_CAP_APDU_EXT) size_t buf_len = (card->caps & SC_CARD_CAP_APDU_EXT)
? sizeof(buffer) : 256; ? sizeof(buffer) : 256;
@ -42,7 +42,7 @@ index e7b25c0..1913eca 100644
int r = blob->info->get_fn(card, blob->id, buffer, buf_len); int r = blob->info->get_fn(card, blob->id, buffer, buf_len);
if (r < 0) { /* an error occurred */ if (r < 0) { /* an error occurred */
@@ -1828,6 +1841,7 @@ static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_in
@@ -1836,6 +1849,7 @@ static int pgp_gen_key(sc_card_t *card,
u8 apdu_case; u8 apdu_case;
u8 *apdu_data; u8 *apdu_data;
size_t apdu_le; size_t apdu_le;
@ -50,7 +50,7 @@ index e7b25c0..1913eca 100644
int r = SC_SUCCESS; int r = SC_SUCCESS;
LOG_FUNC_CALLED(card->ctx); LOG_FUNC_CALLED(card->ctx);
@@ -1868,23 +1882,27 @@ static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_in
@@ -1876,23 +1890,27 @@ static int pgp_gen_key(sc_card_t *card,
apdu_case = SC_APDU_CASE_4_EXT; apdu_case = SC_APDU_CASE_4_EXT;
} }
else { else {
@ -82,6 +82,3 @@ index e7b25c0..1913eca 100644
/* Send */ /* Send */
sc_log(card->ctx, "Waiting for the card to generate key..."); sc_log(card->ctx, "Waiting for the card to generate key...");
--
2.1.3

+ 8
- 11
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.
src/libopensc/card-openpgp.c | 158 +++++++++++++++++++++++++++++++++---------- src/libopensc/card-openpgp.c | 158 +++++++++++++++++++++++++++++++++----------
1 file changed, 123 insertions(+), 35 deletions(-) 1 file changed, 123 insertions(+), 35 deletions(-)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index 1913eca..7cea84f 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -727,6 +727,8 @@ pgp_iterate_blobs(struct blob *blob, int level, void (*func)())
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -735,6 +735,8 @@ pgp_iterate_blobs(struct blob *blob, int
static int static int
pgp_read_blob(sc_card_t *card, struct blob *blob) pgp_read_blob(sc_card_t *card, struct blob *blob)
{ {
@ -21,7 +21,7 @@ index 1913eca..7cea84f 100644
if (blob->data != NULL) if (blob->data != NULL)
return SC_SUCCESS; return SC_SUCCESS;
if (blob->info == NULL) if (blob->info == NULL)
@@ -737,6 +739,11 @@ pgp_read_blob(sc_card_t *card, struct blob *blob)
@@ -745,6 +747,11 @@ pgp_read_blob(sc_card_t *card, struct bl
size_t buf_len = (card->caps & SC_CARD_CAP_APDU_EXT) size_t buf_len = (card->caps & SC_CARD_CAP_APDU_EXT)
? sizeof(buffer) : 256; ? sizeof(buffer) : 256;
@ -33,7 +33,7 @@ index 1913eca..7cea84f 100644
/* Buffer length for Gnuk pubkey */ /* Buffer length for Gnuk pubkey */
if (card->type == SC_CARD_TYPE_OPENPGP_GNUK && if (card->type == SC_CARD_TYPE_OPENPGP_GNUK &&
(blob->id == 0xa400 || blob->id == 0xb600 || blob->id == 0xb800 (blob->id == 0xa400 || blob->id == 0xb600 || blob->id == 0xb800
@@ -1192,49 +1199,75 @@ pgp_get_data(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len)
@@ -1200,49 +1207,75 @@ pgp_get_data(sc_card_t *card, unsigned i
LOG_FUNC_RETURN(card->ctx, apdu.resplen); LOG_FUNC_RETURN(card->ctx, apdu.resplen);
} }
@ -143,7 +143,7 @@ index 1913eca..7cea84f 100644
/* Extended Header list (004D DO) needs a variant of PUT DATA command */ /* Extended Header list (004D DO) needs a variant of PUT DATA command */
if (tag == 0x004D) { if (tag == 0x004D) {
@@ -1260,15 +1293,70 @@ pgp_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t buf_len)
@@ -1268,15 +1301,70 @@ pgp_put_data(sc_card_t *card, unsigned i
apdu.lc = buf_len; apdu.lc = buf_len;
} }
else { else {
@ -215,6 +215,3 @@ index 1913eca..7cea84f 100644
/* Instruct more in case of error */ /* Instruct more in case of error */
if (r == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED) { if (r == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED) {
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Please verify PIN first."); sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Please verify PIN first.");
--
2.1.3

+ 5
- 8
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
src/pkcs15init/pkcs15-openpgp.c | 5 ++--- src/pkcs15init/pkcs15-openpgp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-) 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/pkcs15init/pkcs15-openpgp.c b/src/pkcs15init/pkcs15-openpgp.c
index 1455580..be1291e 100755
--- a/src/pkcs15init/pkcs15-openpgp.c
+++ b/src/pkcs15init/pkcs15-openpgp.c
@@ -279,10 +279,9 @@ static int openpgp_store_data(struct sc_pkcs15_card *p15card, struct sc_profile
Index: opensc-20150513/src/pkcs15init/pkcs15-openpgp.c
===================================================================
--- opensc-20150513.orig/src/pkcs15init/pkcs15-openpgp.c
+++ opensc-20150513/src/pkcs15init/pkcs15-openpgp.c
@@ -279,10 +279,9 @@ static int openpgp_store_data(struct sc_
r = sc_select_file(card, path, &file); r = sc_select_file(card, path, &file);
LOG_TEST_RET(card->ctx, r, "Cannot select cert file"); LOG_TEST_RET(card->ctx, r, "Cannot select cert file");
r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE); r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
@ -26,6 +26,3 @@ index 1455580..be1291e 100755
break; break;
case SC_PKCS15_TYPE_DATA_OBJECT: case SC_PKCS15_TYPE_DATA_OBJECT:
--
2.1.3

+ 6
- 9
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
src/libopensc/card-openpgp.c | 20 ++++++++++++++++++-- src/libopensc/card-openpgp.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-) 1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index 7cea84f..7a77a71 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -1208,6 +1208,10 @@ static int gnuk_write_certificate(sc_card_t *card, const u8 *buf, size_t length)
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -1216,6 +1216,10 @@ static int gnuk_write_certificate(sc_car
sc_apdu_t apdu; sc_apdu_t apdu;
u8 *part; u8 *part;
size_t plen; size_t plen;
@ -25,7 +25,7 @@ index 7cea84f..7a77a71 100644
int r = SC_SUCCESS; int r = SC_SUCCESS;
LOG_FUNC_CALLED(ctx); LOG_FUNC_CALLED(ctx);
@@ -1238,8 +1242,20 @@ static int gnuk_write_certificate(sc_card_t *card, const u8 *buf, size_t length)
@@ -1246,8 +1250,20 @@ static int gnuk_write_certificate(sc_car
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xD6, i, 0); sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xD6, i, 0);
} }
apdu.flags |= SC_APDU_FLAGS_CHAINING; apdu.flags |= SC_APDU_FLAGS_CHAINING;
@ -48,6 +48,3 @@ index 7cea84f..7a77a71 100644
r = sc_transmit_apdu(card, &apdu); r = sc_transmit_apdu(card, &apdu);
LOG_TEST_RET(card->ctx, r, "APDU transmit failed"); LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
--
2.1.3

+ 7
- 10
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.
src/libopensc/card-openpgp.c | 51 +++++++++++++++++++++++++++++++++++++++++++- src/libopensc/card-openpgp.c | 51 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 50 insertions(+), 1 deletion(-) 1 file changed, 50 insertions(+), 1 deletion(-)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index 7a77a71..4d0500d 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -2435,6 +2435,44 @@ static int pgp_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr)
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -2448,6 +2448,44 @@ static int pgp_card_ctl(sc_card_t *card,
LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
} }
@ -57,7 +57,7 @@ index 7a77a71..4d0500d 100644
/* ABI: DELETE FILE */ /* ABI: DELETE FILE */
static int static int
pgp_delete_file(sc_card_t *card, const sc_path_t *path) pgp_delete_file(sc_card_t *card, const sc_path_t *path)
@@ -2442,6 +2480,7 @@ pgp_delete_file(sc_card_t *card, const sc_path_t *path)
@@ -2455,6 +2493,7 @@ pgp_delete_file(sc_card_t *card, const s
struct pgp_priv_data *priv = DRVDATA(card); struct pgp_priv_data *priv = DRVDATA(card);
struct blob *blob; struct blob *blob;
sc_file_t *file; sc_file_t *file;
@ -65,7 +65,7 @@ index 7a77a71..4d0500d 100644
int r; int r;
LOG_FUNC_CALLED(card->ctx); LOG_FUNC_CALLED(card->ctx);
@@ -2457,10 +2496,20 @@ pgp_delete_file(sc_card_t *card, const sc_path_t *path)
@@ -2470,10 +2509,20 @@ pgp_delete_file(sc_card_t *card, const s
if (blob == priv->mf) if (blob == priv->mf)
LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
@ -87,6 +87,3 @@ index 7a77a71..4d0500d 100644
else { else {
/* call pgp_put_data() with zero-sized NULL-buffer to zap the DO contents */ /* call pgp_put_data() with zero-sized NULL-buffer to zap the DO contents */
r = pgp_put_data(card, file->id, NULL, 0); r = pgp_put_data(card, file->id, NULL, 0);
--
2.1.3

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

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

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

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

+ 6
- 9
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.
src/libopensc/card-openpgp.c | 3 ++- src/libopensc/card-openpgp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-) 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index ca0d01b..037ef73 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -738,6 +738,7 @@ pgp_read_blob(sc_card_t *card, struct blob *blob)
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -746,6 +746,7 @@ pgp_read_blob(sc_card_t *card, struct bl
u8 buffer[2048]; u8 buffer[2048];
size_t buf_len = (card->caps & SC_CARD_CAP_APDU_EXT) size_t buf_len = (card->caps & SC_CARD_CAP_APDU_EXT)
? sizeof(buffer) : 256; ? sizeof(buffer) : 256;
@ -20,7 +20,7 @@ index ca0d01b..037ef73 100644
/* Buffer length for certificate */ /* Buffer length for certificate */
if (blob->id == DO_CERT && priv->max_cert_size > 0) { if (blob->id == DO_CERT && priv->max_cert_size > 0) {
@@ -751,7 +752,7 @@ pgp_read_blob(sc_card_t *card, struct blob *blob)
@@ -759,7 +760,7 @@ pgp_read_blob(sc_card_t *card, struct bl
buf_len = MAXLEN_RESP_PUBKEY_GNUK; buf_len = MAXLEN_RESP_PUBKEY_GNUK;
} }
@ -29,6 +29,3 @@ index ca0d01b..037ef73 100644
if (r < 0) { /* an error occurred */ if (r < 0) { /* an error occurred */
blob->status = r; blob->status = r;
--
2.1.3

+ 14
- 17
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).
src/tools/openpgp-tool.c | 56 ++++++++++++++++++++++---------------------- src/tools/openpgp-tool.c | 56 ++++++++++++++++++++++----------------------
2 files changed, 39 insertions(+), 39 deletions(-) 2 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index 037ef73..ae40940 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -192,12 +192,12 @@ static struct do_info pgp1_objects[] = { /* OpenPGP card spec 1.1 */
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -194,12 +194,12 @@ static struct do_info pgp1_objects[] =
{ 0x5f35, SIMPLE, READ_ALWAYS | WRITE_PIN3, NULL, sc_put_data }, { 0x5f35, SIMPLE, READ_ALWAYS | WRITE_PIN3, NULL, sc_put_data },
{ 0x5f50, SIMPLE, READ_ALWAYS | WRITE_PIN3, sc_get_data, sc_put_data }, { 0x5f50, SIMPLE, READ_ALWAYS | WRITE_PIN3, sc_get_data, sc_put_data },
{ 0x7f49, CONSTRUCTED, READ_ALWAYS | WRITE_NEVER, NULL, NULL }, { 0x7f49, CONSTRUCTED, READ_ALWAYS | WRITE_NEVER, NULL, NULL },
@ -32,7 +32,7 @@ index 037ef73..ae40940 100644
{ 0, 0, 0, NULL, NULL }, { 0, 0, 0, NULL, NULL },
}; };
@@ -253,11 +253,11 @@ static struct do_info pgp2_objects[] = { /* OpenPGP card spec 2.0 */
@@ -255,11 +255,11 @@ static struct do_info pgp2_objects[] =
/* The 0xA401, 0xB601, 0xB801 are just symbolic, it does not represent any real DO. /* The 0xA401, 0xB601, 0xB801 are just symbolic, it does not represent any real DO.
* However, their R/W access condition may block the process of importing key in pkcs15init. * However, their R/W access condition may block the process of importing key in pkcs15init.
* So we set their accesses condition as WRITE_PIN3 (writable). */ * So we set their accesses condition as WRITE_PIN3 (writable). */
@ -49,10 +49,10 @@ index 037ef73..ae40940 100644
{ 0, 0, 0, NULL, NULL }, { 0, 0, 0, NULL, NULL },
}; };
diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c
index 374819a..a0334ca 100644
--- a/src/tools/openpgp-tool.c
+++ b/src/tools/openpgp-tool.c
Index: opensc-20150513/src/tools/openpgp-tool.c
===================================================================
--- opensc-20150513.orig/src/tools/openpgp-tool.c
+++ opensc-20150513/src/tools/openpgp-tool.c
@@ -37,11 +37,11 @@ @@ -37,11 +37,11 @@
#include "util.h" #include "util.h"
#include "libopensc/log.h" #include "libopensc/log.h"
@ -70,7 +70,7 @@ index 374819a..a0334ca 100644
/* define structures */ /* define structures */
struct ef_name_map { struct ef_name_map {
@@ -142,10 +142,10 @@ static const struct ef_name_map openpgp_data[] = {
@@ -142,10 +142,10 @@ static const struct ef_name_map openpgp_
static void show_version(void) static void show_version(void)
{ {
fprintf(stderr, fprintf(stderr,
@ -85,7 +85,7 @@ index 374819a..a0334ca 100644
} }
@@ -176,16 +176,16 @@ static char *prettify_language(char *str)
@@ -176,16 +176,16 @@ static char *prettify_language(char *str
{ {
if (str != NULL) { if (str != NULL) {
switch (strlen(str)) { switch (strlen(str)) {
@ -121,7 +121,7 @@ index 374819a..a0334ca 100644
} }
} }
return NULL; return NULL;
@@ -218,7 +218,7 @@ static void display_data(const struct ef_name_map *mapping, char *value)
@@ -218,7 +218,7 @@ static void display_data(const struct ef
char *envvar; char *envvar;
envvar = malloc(strlen(mapping->env_name) + envvar = malloc(strlen(mapping->env_name) +
@ -130,7 +130,7 @@ index 374819a..a0334ca 100644
if (envvar != NULL) { if (envvar != NULL) {
strcpy(envvar, mapping->env_name); strcpy(envvar, mapping->env_name);
strcat(envvar, "="); strcat(envvar, "=");
@@ -346,20 +346,20 @@ static int do_userinfo(sc_card_t *card)
@@ -344,20 +344,20 @@ static int do_userinfo(sc_card_t *card)
if (!count) if (!count)
continue; continue;
@ -177,6 +177,3 @@ index 374819a..a0334ca 100644
return EXIT_FAILURE; return EXIT_FAILURE;
} }
--
2.1.3

+ 8
- 11
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.
src/tools/openpgp-tool.c | 21 +++++++++++---------- src/tools/openpgp-tool.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-) 1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c
index a0334ca..505abd9 100644
--- a/src/tools/openpgp-tool.c
+++ b/src/tools/openpgp-tool.c
@@ -414,8 +414,6 @@ int do_genkey(sc_card_t *card, u8 key_id, unsigned int key_len)
Index: opensc-20150513/src/tools/openpgp-tool.c
===================================================================
--- opensc-20150513.orig/src/tools/openpgp-tool.c
+++ opensc-20150513/src/tools/openpgp-tool.c
@@ -414,8 +414,6 @@ int do_genkey(sc_card_t *card, u8 key_id
sc_path_t path; sc_path_t path;
sc_file_t *file; sc_file_t *file;
@ -21,7 +21,7 @@ index a0334ca..505abd9 100644
if (key_id < 1 || key_id > 3) { if (key_id < 1 || key_id > 3) {
printf("Unknown key ID %d.\n", key_id); printf("Unknown key ID %d.\n", key_id);
return 1; return 1;
@@ -479,14 +477,14 @@ int delete_key_gnuk(sc_card_t *card, u8 key_id)
@@ -479,14 +477,14 @@ int delete_key_gnuk(sc_card_t *card, u8
u8 *data = NULL; u8 *data = NULL;
/* Delete fingerprint */ /* Delete fingerprint */
@ -39,7 +39,7 @@ index a0334ca..505abd9 100644
if (key_id == 1) if (key_id == 1)
data = "\x4D\x02\xB6"; data = "\x4D\x02\xB6";
@@ -534,15 +532,18 @@ int delete_key_openpgp(sc_card_t *card, u8 key_id)
@@ -534,15 +532,18 @@ int delete_key_openpgp(sc_card_t *card,
/* Build APDU from binary array */ /* Build APDU from binary array */
r = sc_bytes2apdu(card->ctx, buf, len0, &apdu); r = sc_bytes2apdu(card->ctx, buf, len0, &apdu);
if (r) { if (r) {
@ -61,7 +61,7 @@ index a0334ca..505abd9 100644
} }
/* TODO: Rewrite Extended Header List. /* TODO: Rewrite Extended Header List.
* Not support by OpenGPG v2 yet */ * Not support by OpenGPG v2 yet */
@@ -557,7 +558,7 @@ int delete_key(sc_card_t *card, u8 key_id)
@@ -557,7 +558,7 @@ int delete_key(sc_card_t *card, u8 key_i
LOG_FUNC_CALLED(ctx); LOG_FUNC_CALLED(ctx);
/* Check key ID */ /* Check key ID */
if (key_id < 1 || key_id > 3) { if (key_id < 1 || key_id > 3) {
@ -79,6 +79,3 @@ index a0334ca..505abd9 100644
exit_status = EXIT_FAILURE; exit_status = EXIT_FAILURE;
goto out; goto out;
} }
--
2.1.3

+ 7
- 10
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
src/tools/openpgp-tool.c | 64 ++++++------------------------------------------ src/tools/openpgp-tool.c | 64 ++++++------------------------------------------
1 file changed, 8 insertions(+), 56 deletions(-) 1 file changed, 8 insertions(+), 56 deletions(-)
diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c
index 505abd9..a7796e7 100644
--- a/src/tools/openpgp-tool.c
+++ b/src/tools/openpgp-tool.c
@@ -468,38 +468,6 @@ int do_verify(sc_card_t *card, char *type, char *pin)
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
} }
/** /**
@ -52,7 +52,7 @@ index 505abd9..a7796e7 100644
* Delete key, for OpenPGP card. * Delete key, for OpenPGP card.
* This function is not complete and is reserved for future version (> 2) of 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, u8 key_id)
@@ -547,32 +515,13 @@ int delete_key_openpgp(sc_card_t *card,
} }
/* TODO: Rewrite Extended Header List. /* TODO: Rewrite Extended Header List.
* Not support by OpenGPG v2 yet */ * Not support by OpenGPG v2 yet */
@ -87,7 +87,7 @@ index 505abd9..a7796e7 100644
int r = SC_SUCCESS; int r = SC_SUCCESS;
/* Currently, only Gnuk supports deleting keys */ /* Currently, only Gnuk supports deleting keys */
@@ -586,13 +535,16 @@ int do_delete_key(sc_card_t *card, u8 key_id)
@@ -586,13 +535,16 @@ int do_delete_key(sc_card_t *card, u8 ke
return SC_ERROR_INVALID_ARGUMENTS; return SC_ERROR_INVALID_ARGUMENTS;
} }
if (key_id == 1 || key_id == 'a') { if (key_id == 1 || key_id == 'a') {
@ -107,6 +107,3 @@ index 505abd9..a7796e7 100644
} }
return r; return r;
} }
--
2.1.3

+ 6
- 9
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.
src/libopensc/card-openpgp.c | 47 +++++++++++++++++++++++--------------------- src/libopensc/card-openpgp.c | 47 +++++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 22 deletions(-) 1 file changed, 25 insertions(+), 22 deletions(-)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index ae40940..724fe73 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -2347,24 +2347,27 @@ out:
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -2358,24 +2358,27 @@ out:
static int pgp_erase_card(sc_card_t *card) static int pgp_erase_card(sc_card_t *card)
{ {
sc_context_t *ctx = card->ctx; sc_context_t *ctx = card->ctx;
@ -56,7 +56,7 @@ index ae40940..724fe73 100644
LOG_FUNC_CALLED(ctx); LOG_FUNC_CALLED(ctx);
@@ -2376,17 +2379,17 @@ static int pgp_erase_card(sc_card_t *card)
@@ -2387,17 +2390,17 @@ static int pgp_erase_card(sc_card_t *car
sc_log(ctx, "Card is OpenPGP v2. Erase card."); sc_log(ctx, "Card is OpenPGP v2. Erase card.");
/* Iterate over 10 commands above */ /* Iterate over 10 commands above */
@ -82,6 +82,3 @@ index ae40940..724fe73 100644
if (r) { if (r) {
sc_log(ctx, "Failed to build APDU"); sc_log(ctx, "Failed to build APDU");
LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL); LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
--
2.1.3

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

@ -11,11 +11,11 @@ type.
src/libopensc/card-openpgp.c | 96 ++++++++++++++++++++++---------------------- src/libopensc/card-openpgp.c | 96 ++++++++++++++++++++++----------------------
1 file changed, 49 insertions(+), 47 deletions(-) 1 file changed, 49 insertions(+), 47 deletions(-)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index 724fe73..ca3173c 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -111,9 +111,9 @@ enum _card_state {
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -113,9 +113,9 @@ enum _card_state {
CARD_STATE_ACTIVATED = 0x05 CARD_STATE_ACTIVATED = 0x05
}; };
@ -28,7 +28,7 @@ index 724fe73..ca3173c 100644
struct do_info *info; struct do_info *info;
sc_file_t * file; sc_file_t * file;
@@ -122,8 +122,8 @@ struct blob {
@@ -124,8 +124,8 @@ struct blob {
unsigned char * data; unsigned char * data;
unsigned int len; unsigned int len;
@ -39,7 +39,7 @@ index 724fe73..ca3173c 100644
struct do_info { struct do_info {
unsigned int id; /* ID of the DO in question */ unsigned int id; /* ID of the DO in question */
@@ -141,12 +141,12 @@ struct do_info {
@@ -143,12 +143,12 @@ struct do_info {
static int pgp_get_card_features(sc_card_t *card); static int pgp_get_card_features(sc_card_t *card);
static int pgp_finish(sc_card_t *card); static int pgp_finish(sc_card_t *card);
@ -57,7 +57,7 @@ index 724fe73..ca3173c 100644
static int pgp_get_pubkey(sc_card_t *, unsigned int, static int pgp_get_pubkey(sc_card_t *, unsigned int,
u8 *, size_t); u8 *, size_t);
static int pgp_get_pubkey_pem(sc_card_t *, unsigned int, static int pgp_get_pubkey_pem(sc_card_t *, unsigned int,
@@ -272,8 +272,8 @@ static struct do_info pgp2_objects[] = { /* OpenPGP card spec 2.0 */
@@ -274,8 +274,8 @@ static struct do_info pgp2_objects[] =
#define DRVDATA(card) ((struct pgp_priv_data *) ((card)->drv_data)) #define DRVDATA(card) ((struct pgp_priv_data *) ((card)->drv_data))
struct pgp_priv_data { struct pgp_priv_data {
@ -68,16 +68,16 @@ index 724fe73..ca3173c 100644
enum _version bcd_version; enum _version bcd_version;
struct do_info *pgp_objects; struct do_info *pgp_objects;
@@ -311,7 +311,7 @@ pgp_init(sc_card_t *card)
@@ -313,7 +313,7 @@ pgp_init(sc_card_t *card)
sc_file_t *file = NULL; sc_file_t *file = NULL;
struct do_info *info; struct do_info *info;
int r; int r;
- struct blob *child = NULL;
+ pgp_blob_t *child = NULL;
- struct blob *child = NULL;
+ pgp_blob_t *child = NULL;
LOG_FUNC_CALLED(card->ctx); LOG_FUNC_CALLED(card->ctx);
@@ -389,7 +389,7 @@ pgp_get_card_features(sc_card_t *card)
@@ -397,7 +397,7 @@ pgp_get_card_features(sc_card_t *card)
unsigned char *hist_bytes = card->atr.value; unsigned char *hist_bytes = card->atr.value;
size_t atr_len = card->atr.len; size_t atr_len = card->atr.len;
size_t i = 0; size_t i = 0;
@ -86,7 +86,7 @@ index 724fe73..ca3173c 100644
/* parse card capabilities from historical bytes */ /* parse card capabilities from historical bytes */
while ((i < atr_len) && (hist_bytes[i] != 0x73)) while ((i < atr_len) && (hist_bytes[i] != 0x73))
@@ -526,7 +526,7 @@ pgp_finish(sc_card_t *card)
@@ -534,7 +534,7 @@ pgp_finish(sc_card_t *card)
/* internal: fill a blob's data */ /* internal: fill a blob's data */
static int static int
@ -95,7 +95,7 @@ index 724fe73..ca3173c 100644
{ {
if (blob->data) if (blob->data)
free(blob->data); free(blob->data);
@@ -620,16 +620,16 @@ pgp_attach_acl(sc_card_t *card, sc_file_t *file, struct do_info *info)
@@ -628,16 +628,16 @@ pgp_attach_acl(sc_card_t *card, sc_file_
} }
/* internal: append a blob to the list of children of a given parent blob */ /* internal: append a blob to the list of children of a given parent blob */
@ -116,7 +116,7 @@ index 724fe73..ca3173c 100644
struct pgp_priv_data *priv = DRVDATA (card); struct pgp_priv_data *priv = DRVDATA (card);
struct do_info *info; struct do_info *info;
@@ -643,7 +643,7 @@ pgp_new_blob(sc_card_t *card, struct blob *parent, unsigned int file_id,
@@ -651,7 +651,7 @@ pgp_new_blob(sc_card_t *card, struct blo
blob->parent = parent; blob->parent = parent;
if (parent != NULL) { if (parent != NULL) {
@ -125,7 +125,7 @@ index 724fe73..ca3173c 100644
/* set file's path = parent's path + file's id */ /* set file's path = parent's path + file's id */
blob->file->path = parent->file->path; blob->file->path = parent->file->path;
@@ -681,11 +681,11 @@ pgp_new_blob(sc_card_t *card, struct blob *parent, unsigned int file_id,
@@ -689,11 +689,11 @@ pgp_new_blob(sc_card_t *card, struct blo
/* internal: free a blob including its content */ /* internal: free a blob including its content */
static void static void
@ -139,7 +139,7 @@ index 724fe73..ca3173c 100644
/* remove blob from list of parent's children */ /* remove blob from list of parent's children */
for (p = &blob->parent->files; *p != NULL && *p != blob; p = &(*p)->next) for (p = &blob->parent->files; *p != NULL && *p != blob; p = &(*p)->next)
@@ -705,14 +705,14 @@ pgp_free_blob(struct blob *blob)
@@ -713,14 +713,14 @@ pgp_free_blob(struct blob *blob)
/* internal: iterate through the blob tree, calling a function for each blob */ /* internal: iterate through the blob tree, calling a function for each blob */
static void static void
@ -157,7 +157,7 @@ index 724fe73..ca3173c 100644
pgp_iterate_blobs(child, level-1, func); pgp_iterate_blobs(child, level-1, func);
child = next; child = next;
@@ -725,7 +725,7 @@ pgp_iterate_blobs(struct blob *blob, int level, void (*func)())
@@ -733,7 +733,7 @@ pgp_iterate_blobs(struct blob *blob, int
/* internal: read a blob's contents from card */ /* internal: read a blob's contents from card */
static int static int
@ -166,7 +166,7 @@ index 724fe73..ca3173c 100644
{ {
struct pgp_priv_data *priv = DRVDATA (card); struct pgp_priv_data *priv = DRVDATA (card);
@@ -772,7 +772,7 @@ pgp_read_blob(sc_card_t *card, struct blob *blob)
@@ -780,7 +780,7 @@ pgp_read_blob(sc_card_t *card, struct bl
* The OpenPGP card has a TLV encoding according ASN.1 BER-encoding rules. * The OpenPGP card has a TLV encoding according ASN.1 BER-encoding rules.
*/ */
static int static int
@ -175,7 +175,7 @@ index 724fe73..ca3173c 100644
{ {
const u8 *in; const u8 *in;
int r; int r;
@@ -789,7 +789,7 @@ pgp_enumerate_blob(sc_card_t *card, struct blob *blob)
@@ -797,7 +797,7 @@ pgp_enumerate_blob(sc_card_t *card, stru
unsigned int cla, tag, tmptag; unsigned int cla, tag, tmptag;
size_t len; size_t len;
const u8 *data = in; const u8 *data = in;
@ -184,7 +184,7 @@ index 724fe73..ca3173c 100644
r = sc_asn1_read_tag(&data, blob->len - (in - blob->data), r = sc_asn1_read_tag(&data, blob->len - (in - blob->data),
&cla, &tag, &len); &cla, &tag, &len);
@@ -819,10 +819,10 @@ pgp_enumerate_blob(sc_card_t *card, struct blob *blob)
@@ -827,10 +827,10 @@ pgp_enumerate_blob(sc_card_t *card, stru
/* internal: find a blob by ID below a given parent, filling its contents when necessary */ /* internal: find a blob by ID below a given parent, filling its contents when necessary */
static int static int
@ -198,7 +198,7 @@ index 724fe73..ca3173c 100644
int r; int r;
if ((r = pgp_enumerate_blob(card, blob)) < 0) if ((r = pgp_enumerate_blob(card, blob)) < 0)
@@ -858,10 +858,10 @@ pgp_get_blob(sc_card_t *card, struct blob *blob, unsigned int id,
@@ -866,10 +866,10 @@ pgp_get_blob(sc_card_t *card, struct blo
/* Internal: search recursively for a blob by ID below a given root */ /* Internal: search recursively for a blob by ID below a given root */
static int static int
@ -212,7 +212,7 @@ index 724fe73..ca3173c 100644
int r; int r;
if ((r = pgp_get_blob(card, root, id, ret)) == 0) if ((r = pgp_get_blob(card, root, id, ret)) == 0)
@@ -883,11 +883,11 @@ pgp_seek_blob(sc_card_t *card, struct blob *root, unsigned int id,
@@ -891,11 +891,11 @@ pgp_seek_blob(sc_card_t *card, struct bl
} }
/* internal: find a blob by tag - pgp_seek_blob with optimizations */ /* internal: find a blob by tag - pgp_seek_blob with optimizations */
@ -226,7 +226,7 @@ index 724fe73..ca3173c 100644
int r; int r;
/* Check if current selected blob is which we want to test*/ /* Check if current selected blob is which we want to test*/
@@ -941,7 +941,7 @@ static int
@@ -949,7 +949,7 @@ static int
pgp_select_file(sc_card_t *card, const sc_path_t *path, sc_file_t **ret) pgp_select_file(sc_card_t *card, const sc_path_t *path, sc_file_t **ret)
{ {
struct pgp_priv_data *priv = DRVDATA(card); struct pgp_priv_data *priv = DRVDATA(card);
@ -235,7 +235,7 @@ index 724fe73..ca3173c 100644
unsigned int path_start = 0; unsigned int path_start = 0;
unsigned int n; unsigned int n;
sc_path_t dummy_path; sc_path_t dummy_path;
@@ -1022,7 +1022,7 @@ static int
@@ -1030,7 +1030,7 @@ static int
pgp_list_files(sc_card_t *card, u8 *buf, size_t buflen) pgp_list_files(sc_card_t *card, u8 *buf, size_t buflen)
{ {
struct pgp_priv_data *priv = DRVDATA(card); struct pgp_priv_data *priv = DRVDATA(card);
@ -244,7 +244,7 @@ index 724fe73..ca3173c 100644
unsigned int k; unsigned int k;
int r; int r;
@@ -1058,7 +1058,7 @@ pgp_read_binary(sc_card_t *card, unsigned int idx,
@@ -1066,7 +1066,7 @@ pgp_read_binary(sc_card_t *card, unsigne
u8 *buf, size_t count, unsigned long flags) u8 *buf, size_t count, unsigned long flags)
{ {
struct pgp_priv_data *priv = DRVDATA(card); struct pgp_priv_data *priv = DRVDATA(card);
@ -253,7 +253,7 @@ index 724fe73..ca3173c 100644
int r; int r;
LOG_FUNC_CALLED(card->ctx); LOG_FUNC_CALLED(card->ctx);
@@ -1134,7 +1134,7 @@ static int
@@ -1142,7 +1142,7 @@ static int
pgp_get_pubkey_pem(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len) pgp_get_pubkey_pem(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len)
{ {
struct pgp_priv_data *priv = DRVDATA(card); struct pgp_priv_data *priv = DRVDATA(card);
@ -262,7 +262,7 @@ index 724fe73..ca3173c 100644
sc_pkcs15_pubkey_t pubkey; sc_pkcs15_pubkey_t pubkey;
u8 *data; u8 *data;
size_t len; size_t len;
@@ -1329,7 +1329,7 @@ static int
@@ -1337,7 +1337,7 @@ static int
pgp_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t buf_len) pgp_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t buf_len)
{ {
struct pgp_priv_data *priv = DRVDATA(card); struct pgp_priv_data *priv = DRVDATA(card);
@ -271,7 +271,7 @@ index 724fe73..ca3173c 100644
struct do_info *dinfo = NULL; struct do_info *dinfo = NULL;
int r; int r;
@@ -1603,7 +1603,7 @@ static int
@@ -1611,7 +1611,7 @@ static int
pgp_update_new_algo_attr(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info) pgp_update_new_algo_attr(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info)
{ {
struct pgp_priv_data *priv = DRVDATA(card); struct pgp_priv_data *priv = DRVDATA(card);
@ -280,7 +280,7 @@ index 724fe73..ca3173c 100644
unsigned int old_modulus_len; /* Measured in bit */ unsigned int old_modulus_len; /* Measured in bit */
unsigned int old_exponent_len; unsigned int old_exponent_len;
const unsigned int tag = 0x00C0 | key_info->keytype; const unsigned int tag = 0x00C0 | key_info->keytype;
@@ -1708,7 +1708,7 @@ pgp_calculate_and_store_fingerprint(sc_card_t *card, time_t ctime,
@@ -1716,7 +1716,7 @@ pgp_calculate_and_store_fingerprint(sc_c
u8 *p; /* Use this pointer to set fp_buffer content */ u8 *p; /* Use this pointer to set fp_buffer content */
size_t pk_packet_len; size_t pk_packet_len;
unsigned int tag; unsigned int tag;
@ -289,7 +289,7 @@ index 724fe73..ca3173c 100644
u8 *newdata; u8 *newdata;
int r; int r;
@@ -1797,7 +1797,7 @@ pgp_update_pubkey_blob(sc_card_t *card, u8* modulus, size_t modulus_len,
@@ -1805,7 +1805,7 @@ pgp_update_pubkey_blob(sc_card_t *card,
u8* exponent, size_t exponent_len, u8 key_id) u8* exponent, size_t exponent_len, u8 key_id)
{ {
struct pgp_priv_data *priv = DRVDATA(card); struct pgp_priv_data *priv = DRVDATA(card);
@ -298,7 +298,7 @@ index 724fe73..ca3173c 100644
unsigned int blob_id; unsigned int blob_id;
sc_pkcs15_pubkey_t pubkey; sc_pkcs15_pubkey_t pubkey;
u8 *data = NULL; u8 *data = NULL;
@@ -1939,6 +1939,8 @@ static int pgp_update_card_algorithms(sc_card_t *card, sc_cardctl_openpgp_keygen
@@ -1947,6 +1947,8 @@ static int pgp_update_card_algorithms(sc
**/ **/
static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info) static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info)
{ {
@ -307,7 +307,7 @@ index 724fe73..ca3173c 100644
sc_apdu_t apdu; sc_apdu_t apdu;
/* Temporary variables to hold APDU params */ /* Temporary variables to hold APDU params */
u8 apdu_case; u8 apdu_case;
@@ -2132,7 +2134,7 @@ pgp_build_extended_header_list(sc_card_t *card, sc_cardctl_openpgp_keystore_info
@@ -2143,7 +2145,7 @@ pgp_build_extended_header_list(sc_card_t
}; };
size_t comp_to_add = 3; size_t comp_to_add = 3;
size_t req_e_len = 0; /* The exponent length specified in Algorithm Attributes */ size_t req_e_len = 0; /* The exponent length specified in Algorithm Attributes */
@ -316,7 +316,7 @@ index 724fe73..ca3173c 100644
u8 i; u8 i;
int r; int r;
@@ -2483,7 +2485,7 @@ static int
@@ -2496,7 +2498,7 @@ static int
pgp_delete_file(sc_card_t *card, const sc_path_t *path) pgp_delete_file(sc_card_t *card, const sc_path_t *path)
{ {
struct pgp_priv_data *priv = DRVDATA(card); struct pgp_priv_data *priv = DRVDATA(card);
@ -325,7 +325,7 @@ index 724fe73..ca3173c 100644
sc_file_t *file; sc_file_t *file;
u8 key_id; u8 key_id;
int r; int r;
@@ -2533,7 +2535,7 @@ pgp_update_binary(sc_card_t *card, unsigned int idx,
@@ -2546,7 +2548,7 @@ pgp_update_binary(sc_card_t *card, unsig
const u8 *buf, size_t count, unsigned long flags) const u8 *buf, size_t count, unsigned long flags)
{ {
struct pgp_priv_data *priv = DRVDATA(card); struct pgp_priv_data *priv = DRVDATA(card);
@ -334,6 +334,3 @@ index 724fe73..ca3173c 100644
int r = SC_SUCCESS; int r = SC_SUCCESS;
LOG_FUNC_CALLED(card->ctx); LOG_FUNC_CALLED(card->ctx);
--
2.1.3

+ 7
- 10
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.
src/libopensc/card-openpgp.c | 3 --- src/libopensc/card-openpgp.c | 3 ---
1 file changed, 3 deletions(-) 1 file changed, 3 deletions(-)
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
index ca3173c..94c69ae 100644
--- a/src/libopensc/card-openpgp.c
+++ b/src/libopensc/card-openpgp.c
@@ -973,7 +973,6 @@ pgp_select_file(sc_card_t *card, const sc_path_t *path, sc_file_t **ret)
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -981,7 +981,6 @@ pgp_select_file(sc_card_t *card, const s
* So we set its size to be the same as max certificate size the card supports. */ * So we set its size to be the same as max certificate size the card supports. */
(*ret)->size = priv->max_cert_size; (*ret)->size = priv->max_cert_size;
} }
@ -20,7 +20,7 @@ index ca3173c..94c69ae 100644
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
} }
@@ -990,7 +989,6 @@ pgp_select_file(sc_card_t *card, const sc_path_t *path, sc_file_t **ret)
@@ -998,7 +997,6 @@ pgp_select_file(sc_card_t *card, const s
/* This file ID is refered when importing key&certificate via pkcs15init, like above. /* This file ID is refered when importing key&certificate via pkcs15init, like above.
* We pretend to successfully find this inexistent file. */ * We pretend to successfully find this inexistent file. */
if (id == 0x4402 || id == 0x5f48) { if (id == 0x4402 || id == 0x5f48) {
@ -28,7 +28,7 @@ index ca3173c..94c69ae 100644
if (ret == NULL) if (ret == NULL)
/* No need to return file */ /* No need to return file */
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
@@ -1002,7 +1000,6 @@ pgp_select_file(sc_card_t *card, const sc_path_t *path, sc_file_t **ret)
@@ -1010,7 +1008,6 @@ pgp_select_file(sc_card_t *card, const s
} }
if (r < 0) { /* failure */ if (r < 0) { /* failure */
@ -36,6 +36,3 @@ index ca3173c..94c69ae 100644
LOG_FUNC_RETURN(card->ctx, r); LOG_FUNC_RETURN(card->ctx, r);
} }
} }
--
2.1.3

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

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

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

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

@ -0,0 +1,82 @@
From 99b5cb53e1da2f0d7692f28dceff8485d4b74daf 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: Wed, 10 Dec 2014 03:59:54 +0800
Subject: [PATCH 1/2] OpenPGP: Remove unused variables and fix type cast.
---
src/libopensc/card-openpgp.c | 10 +++-------
src/tools/openpgp-tool.c | 4 +---
2 files changed, 4 insertions(+), 10 deletions(-)
Index: opensc-20150513/src/libopensc/card-openpgp.c
===================================================================
--- opensc-20150513.orig/src/libopensc/card-openpgp.c
+++ opensc-20150513/src/libopensc/card-openpgp.c
@@ -1966,8 +1966,6 @@ static int pgp_update_card_algorithms(sc
**/
static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info)
{
- struct pgp_priv_data *priv = DRVDATA(card);
- pgp_blob_t *algo_blob;
sc_apdu_t apdu;
/* Temporary variables to hold APDU params */
u8 apdu_case;
@@ -2396,10 +2394,9 @@ static int pgp_erase_card(sc_card_t *car
{0, 0x44, 0, 0}
};
u8 apdu_lens[10] = {13, 13, 13, 13, 13, 13, 13, 13, 4, 4};
- u8 buf[SC_MAX_APDU_BUFFER_SIZE];
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
sc_apdu_t apdu;
- int i, l, r;
+ u8 i, l, r;
LOG_FUNC_CALLED(ctx);
@@ -2478,7 +2475,7 @@ gnuk_delete_key(sc_card_t *card, u8 key_
{
sc_context_t *ctx = card->ctx;
int r = SC_SUCCESS;
- u8 *data = NULL;
+ char *data = NULL;
LOG_FUNC_CALLED(ctx);
@@ -2506,7 +2503,7 @@ gnuk_delete_key(sc_card_t *card, u8 key_
else if (key_id == 3)
data = "\x4D\x02\xA4";
- r = pgp_put_data(card, 0x4D, data, strlen(data) + 1);
+ r = pgp_put_data(card, 0x4D, (const u8 *)data, strlen((const char *)data) + 1);
LOG_FUNC_RETURN(ctx, r);
}
@@ -2519,7 +2516,6 @@ pgp_delete_file(sc_card_t *card, const s
struct pgp_priv_data *priv = DRVDATA(card);
pgp_blob_t *blob;
sc_file_t *file;
- u8 key_id;
int r;
LOG_FUNC_CALLED(card->ctx);
Index: opensc-20150513/src/tools/openpgp-tool.c
===================================================================
--- opensc-20150513.orig/src/tools/openpgp-tool.c
+++ opensc-20150513/src/tools/openpgp-tool.c
@@ -473,7 +473,6 @@ int do_verify(sc_card_t *card, char *typ
**/
int delete_key_openpgp(sc_card_t *card, u8 key_id)
{
- sc_context_t *ctx = card->ctx;
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";
char *del_creationtime = "00:DA:00:CD:04:00:00:00:00";
/* We need to replace the 4th byte later */
@@ -520,7 +519,6 @@ int delete_key_openpgp(sc_card_t *card,
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;

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

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

Loading…
Cancel
Save