Skip to content

Use a DSC USB Token on Linux

Detect a DSC USB token on Linux, install what its driver needs, sign a PDF and protect your PIN retries: a walkthrough for Indian DSC users.

On this page

Using a DSC USB token on Linux means getting four parties to agree: the smart card service, your token vendor’s driver, a signing program and you, holding a PIN. This walkthrough goes from plugged in to signed PDF with tda-dsc-signer, an open source app I wrote, and says plainly which parts are verified.

What a USB token on Linux needs

The private key lives inside the token and signs inside the token. Everything on your computer exists to ask it politely.

LayerWhere it comes fromIts job
pcscdthe pcsclite packagethe smart card service
CCID driverthe ccid packagetalks to USB readers
PKCS#11 libraryyour token’s vendorspeaks to your token
Signing programtda-dsc-signer hereasks the library to sign

Your token presents itself as a reader, which is why the CCID driver is involved at all. The signer ships no vendor library.

Notice how little of that chain is the signing program. When something fails, the symptom at the top is usually the same, an empty list, while the cause can sit in any layer below it. So it pays to know which layer you are asking before you reinstall everything in sight. The Arch wiki page on smart cards is a good companion if you want the wider picture.

Install the pieces

bash
sudo pacman -S --needed pcsclite ccid gtk4 poppler-glib python-gobject python-cairo nss usbutils p11-kit uv git make
sudo systemctl enable --now pcscd.socket

Those are the Arch package names. On other distributions, you need Python 3.12 or newer, GTK4, poppler-glib, PyGObject, pcsclite, ccid, git, make and uv. Then build from source, and the command lands in ~/.local/bin:

bash
git clone https://github.com/TheDarkArtist/tda-dsc-signer
cd tda-dsc-signer
make install

Now install your vendor’s PKCS#11 driver. For InnaIT the library is libInnaITPKCS11Driver.so. The signer looks at modules registered with p11-kit and at known vendor paths, and you can add others with the DSC_MODULES variable or extra_modules in its config.

Check that the token is detected

Plug the token in, then ask two questions. Neither needs a PIN.

bash
tda-dsc-signer doctor
tda-dsc-signer list

list prints the signing certificates on attached tokens, with the numbers you pass to -t when more than one is plugged in. If it prints them, skip ahead to signing. If it does not, follow the branch that matches:

flowchart TD
    A["list shows no certificate"] --> B["Run doctor"]
    B --> C{"What fails?"}
    C -->|"smart card service"| D["Enable the pcscd socket"]
    C -->|"vendor driver"| E["Install the vendor package"]
    C -->|"device list"| F["Add your token to the CCID list"]
    C -->|"driver in use"| G["Close the other signer"]

doctor prints a suggested fix for what fails and never runs it. Apply one fix, run list again, and only then move to the next. It exits with code 1 if any check fails.

doctor looks atThe question
Smart card serviceis pcscd or its socket active?
USB device, CCID list, package hookis the InnaIT token seen, listed and covered by the hook?
Vendor driverdoes the InnaIT library load?
Driver in useis another copy of the signer holding it?
Desktop entrycan a launcher start the app?

The USB, device list, hook and driver rows are written around the InnaIT token, so on any other brand read those rows as being about a token you do not have.

Seeing no tokens while one is clearly plugged in? Look for a second guest at the driver. Vendor drivers and readers cannot be shared, and Seahorse, OpenSC tools, a browser’s smart card module or another signer window can all be holding it. Close that program and try again. When the other holder is a second copy of the signer, the command says the driver is busy, exits with code 3, and --wait-driver 30 will wait up to thirty seconds for it.

If the InnaIT token is not recognised

The CCID driver keeps a list of devices it knows. If your InnaIT token shows up in lsusb as 338c:0031 but the signer’s doctor says the list lacks it, the entry has to be added. The file is /usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist, and it holds three parallel arrays. Append one value to the end of each, then restart the service:

ArrayValue to append
ifdVendorID0x338C
ifdProductID0x0031
ifdFriendlyNameInnaitKey DSC
bash
sudo systemctl restart pcscd.service pcscd.socket

You have two choices. Protect your edited file with pacman’s NoUpgrade setting, and remember that you then stop receiving new entries in it. Or use the optional pacman hook kept in the repository’s packaging folder, which reapplies the edit after each upgrade. The hook modifies a file owned by another package, and pacman -Qkk ccid will say so. If that trade sounds odd, it is worth reading how package managers decide what ends up on your disk.

Look after your PIN

A token counts wrong PINs and locks when the count runs out. Unblocking is then a matter for the issuer. So do not guess.

The signer makes exactly one login for each signing action and never retries it. Three situations get extra care:

SituationWhat you need
Token reports it is lockedthe issuer, no login is attempted
Token reports its final try--confirm-final-try
Quick retry after a wrong PIN--confirm-after-failure

Do not read silence from the token as a sign that tries remain. When in doubt, stop and check which PIN you are about to type.

Type the PIN at the prompt. Keeping it in a script or an environment variable is a habit worth refusing. Saving it is off unless you turn it on:

bash
tda-dsc-signer pin set -t 1       # store it in your system keyring
tda-dsc-signer pin status         # what is saved, never the PIN itself
tda-dsc-signer pin forget --all   # remove it again

Sign the PDF

For a visible signature, give a page and a box. The box is two corners in PDF points, measured from the bottom left, and page -1 means the last page.

bash
tda-dsc-signer sign report.pdf -p 1 -b 50,50,300,120
tda-dsc-signer sign report.pdf --invisible -o quiet.pdf

Prefer a window? Run tda-dsc-signer, draw the box, pick the signer.

The signer window with two visible signature boxes drawn on a synthetic page and the signer chosen for each
General mode, with fake tokens and synthetic names.

For an MCA style form with empty signature fields, look first and sign second:

bash
tda-dsc-signer fields form.pdf
tda-dsc-signer sign form.pdf --all-fields

--all-fields signs the fields whose PAN matches an attached token and lists the rest for the next person, who signs the file you saved.

The thing to keep straight is which file travels. Send the saved output onward, not the original, or the next copy arrives without the first signature. Your input is never modified, and an existing output is left alone unless you add --force.

Check what you made

After signing, whether the document is unmodified, whether the signature is valid and whether the issuer is trusted are reported separately. Treat them as separate questions, because a file can pass one and fail another.

Exit codeMeaning
0success
1a doctor check failed, or the command ended in an error
2signing ran, verification afterwards failed (a mistyped option also exits 2)
3another copy of the signer holds the driver

For a second opinion from Poppler, create the signer’s private trust database, which holds the pinned CCA India root, and point pdfsig at it:

bash
tda-dsc-signer trust install
pdfsig -nssdir ~/.local/share/tda-dsc-signer/nssdb report-signed.pdf

Two things this walkthrough cannot promise. Acceptance by the MCA portal, and the format it expects, are not verified. How Adobe Acrobat displays trust is not verified either, since it keeps its own list. Check that a signed file meets the needs of whoever receives it, ideally before the deadline and not on it.