101.14. opensc-0.27.1
The PKCS#11 module for PIV, CAC, OpenPGP and national eID smart cards, and the tools to manage them
| Version | 0.27.1, release 1 |
| Shelf | crypto — Cryptographic libraries, PKCS#11, smartcards and TPM |
| Phase | 41_system (System), 322 of 1047 in build order |
| Licence | LGPL-2.1-or-later |
| Homepage | https://github.com/OpenSC/OpenSC |
| Build time | 1.0 SBU |
| Installed size | 4.6 MiB in 115 files |
| Recipe | ports/core/crypto/opensc/kpkgbuild |
About
OpenSC is the PKCS #11 module through which programs use a smart card’s keys: opensc-pkcs11.so speaks PIV, CAC, OpenPGP cards and many national eID cards to the reader that pcsc-lite and ccid reach. Without it a card is visible to pcscd and useless to everything else. Its opensc.module registers it with p11-kit, so GnuTLS programs see the card’s certificates and openconnect accepts a pkcs11: URI, and ssh -I /usr/lib/opensc-pkcs11.so uses its keys; see Thunderbolt, phones, smart cards and firmware updates. The port also installs the card tools, opensc-tool, pkcs11-tool, pkcs15-tool, pkcs15-init, piv-tool and the rest, with their manual pages and bash completions.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/crypto.txt:
The PKCS#11 module a smart card is used through. pcscd and ccid reach the reader; without this nothing speaks PIV, CAC, OpenPGP or an eID card to it, so
ssh -I, openconnect's pkcs11: URIs and every p11-kit consumer see none.
Sources
opensc-0.27.1.tar.gz(2.4 MiB)
sha256976f4a23eaf3397a1a2c3a7aac80bf971a8c3d829c9a79f06145bfaeeae5eca7
upstream: https://github.com/OpenSC/OpenSC/releases/download/0.27.1/opensc-0.27.1.tar.gz
archive copy: sources-1/crypto--opensc-0.27.1.tar.gz
Dependencies
Depends on: pkgconf, pcsc-lite, openssl, zlib, readline, p11-kit, libxslt, docbook-xsl, bash-completion.
Required by: no port names it.
Optional, off in KDOS
These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.
--disable-notify, line 22: libnotify (explained with the switches below)
Patches
build.sh applies these; kpkg applies nothing by itself.
openssl4.patch— Changes for OpenSSL-4.0.0Changes to get OpenSC to compile with OpenSSl-4.0.0
OpenSSL says: "Opaque Structures: ASN1_STRING has been made opaque, and further work has been done to make X509 structures more memory-efficient and const-correct."
ASN1_STRING was made opaque thus requiring the use of ASN1_STRING_get0_data, and ASN1_STRING_length. These routines have been in OpenSSL since 1.1.1 and are also in libressl.
ASN1_STRING_get0_data returns a const pointer, so the data can not be changed. There are a number of reverse() functions one of which was reversing the bytes in a EC pubkey.
Changes not addressed: "Global Cleanup: libcrypto no longer uses atexit() for cleanup; OPENSSL_cleanup() now runs in a global destructor."
On branch OpenSSL-4.0.0 Changes to be committed: modified: src/libopensc/cwa-dnie.c modified: src/pkcs11/openssl.c modified: src/pkcs15init/pkcs15-oberthur-awp.c modified: src/tests/p11test/p11test_case_common.c modified: src/tools/netkey-tool.c modified: src/tools/pkcs11-tool.c modified: src/tools/pkcs15-init.c
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install opensc'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/crypto/opensc.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/crypto/opensc
echo '976f4a23eaf3397a1a2c3a7aac80bf971a8c3d829c9a79f06145bfaeeae5eca7 opensc-0.27.1.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/opensc
SRC=$SRC_ROOT/opensc-0.27.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf opensc-0.27.1.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/openssl4.patch"
./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --disable-static \
--enable-openssl \
--enable-zlib \
--enable-readline \
--enable-pcsc \
--enable-sm \
--enable-man \
--disable-doc \
--disable-notify \
--disable-openpace \
--disable-autostart-items \
--disable-tests \
--disable-cmocka \
--with-xsl-stylesheetsdir=/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2 \
--with-pcsc-provider=libpcsclite.so.1
make
make DESTDIR=$PKG install
rm "$PKG/usr/share/applications/org.opensc.notify.desktop" \
"$PKG/usr/share/bash-completion/completions/opensc-notify" \
"$PKG/usr/share/man/man1/opensc-notify.1"
The switches, and why each is set:
--enable-openssl,--enable-zlib,--enable-readline,--enable-pcsc— Atdetect, configure’s default for the first three, a missing library is left out and configure goes on; namedyes, a missing library stops configure. PC/SC is on by default. They give openssl for the cryptography of most card drivers, zlib for compressed certificates on cards, readline foropensc-explorer’s line editing, and PC/SC for the readers.--enable-sm— Secure messaging, the encrypted channel some cards, national eIDs among them, require between the host and the card; upstream’s default, written out.--enable-man,--disable-doc— Generate the manual pages withxsltprocfrom libxslt, and install no HTML documentation.--with-xsl-stylesheetsdir=/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2— The DocBook stylesheets the manual pages are made with, from docbook-xsl. Left to detect them, configure looks only in a set list of other systems’ directories (Debian’s, MacPorts’, Fink’s and/usr/share/sgml/docbook), and with--enable-manit stops when it finds none.--with-pcsc-provider=libpcsclite.so.1— The PC/SC library OpenSC opens at run time, by its versioned soname, which is upstream’s default for Linux written out.--disable-notify— Noopensc-notify, the desktop notifier for card insertion and removal, built on GIO notifications.--disable-autostart-items— Install no XDG autostart entry forpkcs11-register, which would add OpenSC’s module to the user’s Firefox, Chromium and Thunderbird NSS databases at every login; upstream’s default, written out.--disable-openpace— No PACE, the password-authenticated channel of the German eID card and others, which needs the OpenPACE library; it is not in the tree.--disable-tests,--disable-cmocka— Build neither upstream’s test programs undersrc/testsnor the cmocka suites insrc/tests/p11testandsrc/tests/unittests.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/opensc, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf opensc-0.27.1-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/opensc, and runs the triggers its paths call for.
Contents
Installed programs: cardos-tool, cryptoflex-tool, dnie-tool, dtrust-tool, egk-tool, eidenv, gids-tool, goid-tool, iasecc-tool, netkey-tool, openpgp-tool, opensc-asn1, opensc-explorer, opensc-tool, piv-tool, pkcs11-register, pkcs11-tool, pkcs15-crypt, pkcs15-init, pkcs15-tool, sc-hsm-tool, westcos-tool.
Installed libraries: libopensc.so, libsmm-local.so.
Installed directories: /usr/share/doc/opensc, /usr/share/licenses/opensc, /usr/share/opensc.
Short descriptions
cardos-tool |
displays information about Card OS-based security tokens or format them |
cryptoflex-tool |
utility for manipulating Schlumberger Cryptoflex data structures |
dnie-tool |
displays information about DNIe based security tokens |
dtrust-tool |
displays information about D-Trust signature cards and remove the transport protection |
egk-tool |
displays information on the German electronic health card (elektronische Gesundheitskarte, eGK) |
eidenv |
utility for accessing visible data from electronic identity cards |
gids-tool |
smart card utility for GIDS cards |
goid-tool |
smart card utility for GoID fingerprint card |
iasecc-tool |
displays information about IAS/ECC card |
netkey-tool |
administrative utility for Netkey E4 cards |
openpgp-tool |
utility for accessing visible data OpenPGP smart cards and compatible tokens |
opensc-asn1 |
parse ASN.1 data |
opensc-explorer |
generic interactive utility for accessing smart card and similar security token functions |
opensc-tool |
generic smart card utility |
piv-tool |
smart card utility for HSPD-12 PIV cards |
pkcs11-register |
Simple tool to install PKCS#11 modules to known applications. |
pkcs11-tool |
utility for managing and using PKCS #11 security tokens |
pkcs15-crypt |
perform crypto operations using PKCS#15 smart cards |
pkcs15-init |
smart card personalization utility |
pkcs15-tool |
utility for manipulating PKCS #15 data structures on smart cards and similar security tokens |
sc-hsm-tool |
smart card utility for SmartCard-HSM |
westcos-tool |
utility for manipulating data structures on westcos smart cards |
opensc-pkcs11.pc |
OpenSC PKCS#11 module |
Notes
make install puts opensc-notify’s desktop entry, bash completion and manual page in place even with --disable-notify, so build.sh deletes those three files. It deletes them with rm and no -f, so the build fails if a release stops installing any of them.
The stylesheet directory is named with its version. A docbook-xsl update that renames it makes configure stop with invalid at the xsl-stylesheets check until this path follows it.