Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

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

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.

Patches

build.sh applies these; kpkg applies nothing by itself.

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:

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.