From 8a2998867535156ec7d1b93a16e9b3cd839199c2 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Jul 19 2017 07:43:53 +0000 Subject: opensc-0.17.0-1 --- diff --git a/.gitignore b/.gitignore index 0fea1bd..65c0d1b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /opensc-0.15.0.tar.gz /opensc-0.16.0.tar.gz /opensc-0.16.0-git0362439.tar.gz +/opensc-0.17.0.tar.gz diff --git a/opensc-coolkey.patch b/opensc-coolkey.patch new file mode 100644 index 0000000..6b493de --- /dev/null +++ b/opensc-coolkey.patch @@ -0,0 +1,59 @@ +diff --git a/src/libopensc/pkcs15-coolkey.c b/src/libopensc/pkcs15-coolkey.c +index 5064a0f..d93875a 100644 +--- a/src/libopensc/pkcs15-coolkey.c ++++ b/src/libopensc/pkcs15-coolkey.c +@@ -484,7 +484,7 @@ static int sc_pkcs15emu_coolkey_init(sc_pkcs15_card_t *p15card) + sc_card_t *card = p15card->card; + sc_serial_number_t serial; + int count; +- ++ struct sc_pkcs15_object *obj; + + SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); + +@@ -558,6 +558,8 @@ static int sc_pkcs15emu_coolkey_init(sc_pkcs15_card_t *p15card) + + + memset(&obj_obj, 0, sizeof(obj_obj)); ++ /* coolkey applets have label only on the certificates, ++ * but we should copy it also to the keys maching the same ID */ + coolkey_get_attribute_bytes(card, &coolkey_obj, CKA_LABEL, (u8 *)obj_obj.label, &len, sizeof(obj_obj.label)); + coolkey_get_flags(card, &coolkey_obj, &obj_obj.flags); + if (obj_obj.flags & SC_PKCS15_CO_FLAG_PRIVATE) { +@@ -677,6 +679,36 @@ fail: + } + r = (card->ops->card_ctl)(card, SC_CARDCTL_COOLKEY_FINAL_GET_OBJECTS, &count); + ++ /* Iterate over all the objects again and fill missing labels */ ++ for (obj = p15card->obj_list; obj != NULL; obj = obj->next) { ++ struct sc_pkcs15_id *id = NULL; ++ struct sc_pkcs15_object *cert_object; ++ ++ sc_log(card->ctx, "Object with label %s", obj->label); ++ if (obj->label[0] != '\0') ++ /* label already filled -- do not overwrite */ ++ continue; ++ ++ switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) { ++ case SC_PKCS15_TYPE_PUBKEY: ++ id = &((struct sc_pkcs15_pubkey_info *)obj->data)->id; ++ break; ++ case SC_PKCS15_TYPE_PRKEY: ++ id = &((struct sc_pkcs15_prkey_info *)obj->data)->id; ++ break; ++ default: ++ /* We do not care about other objects */ ++ continue; ++ } ++ sc_log(card->ctx, "Object ID is %s", id->value); ++ r = sc_pkcs15_find_cert_by_id(p15card, id, &cert_object); ++ if (r != 0) ++ continue; ++ ++ sc_log(card->ctx, "Found cert with with label %s", cert_object->label); ++ memcpy(obj->label, cert_object->label, SC_PKCS15_MAX_LABEL_SIZE); ++ } ++ + LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); + } + diff --git a/opensc.spec b/opensc.spec index 0712802..227a7fe 100644 --- a/opensc.spec +++ b/opensc.spec @@ -1,21 +1,18 @@ -%global commit0 0362439563a11d254aeda63b9e9ddb44ea289308 -%global shortcommit0 %(c=%{commit0}; echo ${c:0:7}) - %define opensc_module "OpenSC PKCS #11 Module" %define nssdb %{_sysconfdir}/pki/nssdb Name: opensc -Version: 0.16.0 -Release: 5.20161016git%{shortcommit0}%{?dist} +Version: 0.17.0 +Release: 1%{?dist} Summary: Smart card library and applications Group: System Environment/Libraries License: LGPLv2+ URL: https://github.com/OpenSC/OpenSC/wiki -Source0: https://github.com/OpenSC/OpenSC/archive/%{commit0}.tar.gz#/%{name}-%{version}-git%{shortcommit0}.tar.gz +Source0: https://github.com/OpenSC/OpenSC/releases/download/%{version}/%{name}-%{version}.tar.gz Source1: opensc.module Source2: pkcs11-switch.sh -Patch0: opensc-prkey-fixup.patch +Patch0: opensc-coolkey.patch BuildRequires: pcsc-lite-devel BuildRequires: readline-devel @@ -40,9 +37,8 @@ every software/card that does so, too. %prep -%setup -q -n OpenSC-%{commit0} - -%patch0 -p1 -b .prkey-fixes +%setup -q +%patch0 -p1 cp -p src/pkcs15init/README ./README.pkcs15init cp -p src/scconf/README.scconf . @@ -84,6 +80,10 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/libsmm-local.so rm -rf %{buildroot}%{_sysconfdir}/bash_completion.d/ %endif +# the npa-tool builds to nothing since we do not have OpenPACE library +rm -rf %{buildroot}%{_bindir}/npa-tool +rm -rf %{buildroot}%{_mandir}/man1/npa-tool.1* + %post /sbin/ldconfig isThere=`modutil -rawlist -dbdir %{nssdb} | grep %{opensc_module} || echo NO` @@ -158,6 +158,9 @@ fi %changelog +* Wed Jul 19 2017 Jakub Jelen - 0.17.0-1 +- New upstream release including support for Coolkey and CAC cards + * Tue Feb 28 2017 Jakub Jelen - 0.16.0-5.20161016git0362439 - Add PKCS#11 library to the NSS DB (#1421692) diff --git a/sources b/sources index 52f3313..02276d2 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -8167e4a92feac4bec613bc58e8f3a0cf opensc-0.16.0-git0362439.tar.gz +SHA512 (opensc-0.17.0.tar.gz) = 8991c1724d187d3c34a2ed591b21f0085f767c0d866edc2decfda85a2b3dedf717838f4937d1dda3e1bbc17f02e6eca6740299660128bc448a29e8bfc2962922