piv_pin.py
Provision or change the OpenAliro PIV PIN through macOS PC/SC.
Overview
Provision or change the OpenAliro PIV PIN through macOS PC/SC.
API
Cclass PivPinError(RuntimeError)
Expected provisioning or PC/SC failure.
PcscCard.__init__, PcscCard._check, PcscCard._select_reader, encode_pin, prompt_new_pin, provision_or_change, select_piv, status_wordCclass ScardIoRequest(ctypes.Structure)
PC/SC IO_REQUEST structure with protocol and length fields.
PcscCard.transmitFencode_pin(value)
Return an eight-byte PIV PIN padded with 0xff.
prompt_new_pin, provision_or_change · calls PivPinErrorFstatus_word(response)
Extract the two-byte status word from the end of a PIV APDU response; raise PivPinError if the response is truncated.
provision_or_change, select_piv · calls PivPinErrorFdescribe_status(status)
Decode a PIV status word into a human-readable message; include retry count for PIN-guessing failures.
provision_or_change, select_pivCclass PcscCard
Open and manage a PC/SC connection to an OpenAliro PIV card on macOS; establish context, connect to the reader matching reader_match, begin a transaction, and clean up on exit.
mainFPcscCard._configure_functions(self)
Configure ctypes return types for all PC/SC library functions.
PcscCard.__init__FPcscCard._check(result, operation)
Raise PivPinError if a PC/SC operation returned nonzero.
PcscCard.__init__, PcscCard._select_reader, PcscCard.transmit · calls PivPinErrorFPcscCard.close(self)
Release the PC/SC transaction, disconnect from the card, and release the context.
PcscCard.__exit__FPcscCard.__enter__(self)
Enter the context manager and return self.
Fprompt_new_pin()
Prompt for a new PIV PIN twice, verify they match, encode it, and return the result.
provision_or_change · calls PivPinError, encode_pinFbuild_parser()
Return an argument parser for --change and --reader options.
mainUndocumented (7)
PcscCard.__init__, PcscCard._select_reader, PcscCard.transmit, PcscCard.__exit__, select_piv, provision_or_change, main