How edeustua/peru-dnie works
Peru DNIe is a Linux command-line tool for extracting DNIe v2 certificates and signing files with the card. The main workflow parses a command, initializes a smart-card connection, then dispatches to certificate extraction or signing; results are written to files. The graph also shows the APDU/card transport layer and supporting hash, configuration, and localization modules. Evidence is limited to the README and indexed source excerpts; unsampled subsystem internals are not inferred.
Main entry points: pyscard.py PC/SC Adapter · context.py Operation Context · cli.py Command CLI · signature.py File Signing
Components 17
CLI
- Command CLI
src/peru_dnie/cli.py - Card Initialization
src/peru_dnie/card_init.py
Card Operations
- Certificate Extraction
src/peru_dnie/commands/certificate.py - File Signing
src/peru_dnie/commands/signature.py - PIN Verification
src/peru_dnie/commands/general.py
Card Transport
- APDU Encoding
src/peru_dnie/apdu.py - Smart Card Interface
src/peru_dnie/card.py - PC/SC Adapter
src/peru_dnie/pyscard.py
Shared Support
- Operation Context
src/peru_dnie/context.py - Hash Functions
src/peru_dnie/hashes.py - Card and Hash Constants
src/peru_dnie/constants.py - Localization
src/peru_dnie/i18n.py - CLI Configuration
src/peru_dnie/cli_config.py - Card Errors
src/peru_dnie/exceptions.py
Other components
- User
- Input and Output Files
- Smart Card Reader and DNIe
Connections 24
- User → Command CLI: runs command
README.md - Command CLI → Card Initialization: initializes card
src/peru_dnie/cli.py - Command CLI → File Signing: dispatches signing
src/peru_dnie/cli.py - Command CLI → Certificate Extraction: dispatches extraction
src/peru_dnie/cli.py - Command CLI → Hash Functions: selects hash
src/peru_dnie/cli.py - Card Initialization → PC/SC Adapter: gets connection
src/peru_dnie/card_init.py - PC/SC Adapter → Smart Card Reader and DNIe: connects to card
src/peru_dnie/pyscard.py - PC/SC Adapter → Smart Card Interface: implements interface
src/peru_dnie/pyscard.py - PC/SC Adapter → APDU Encoding: serializes commands
src/peru_dnie/pyscard.py - Card Initialization → Operation Context: sets card
src/peru_dnie/card_init.py - File Signing → Operation Context: transmits commands
src/peru_dnie/commands/signature.py - Certificate Extraction → Operation Context: transmits commands
src/peru_dnie/commands/certificate.py - PIN Verification → Operation Context: transmits PIN
src/peru_dnie/commands/general.py - Operation Context → Smart Card Interface: forwards commands
src/peru_dnie/context.py - File Signing → Hash Functions: hashes input
src/peru_dnie/commands/signature.py - File Signing → PIN Verification: verifies PIN
src/peru_dnie/commands/signature.py - Certificate Extraction → PIN Verification: selects PKI app
src/peru_dnie/commands/certificate.py - File Signing → Input and Output Files: reads and writes
src/peru_dnie/commands/signature.py - Certificate Extraction → Input and Output Files: writes certificate
src/peru_dnie/commands/certificate.py - Hash Functions → Card and Hash Constants: uses DER encodings
src/peru_dnie/hashes.py - Operation Context → CLI Configuration: uses CLI settings
src/peru_dnie/context.py - APDU Encoding → Localization: uses error messages
src/peru_dnie/apdu.py - PC/SC Adapter → Card and Hash Constants: matches card ATR
src/peru_dnie/pyscard.py - PC/SC Adapter → Card Errors: raises card error
src/peru_dnie/pyscard.py