Skip to content

alediator/pyscard-dnie-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pyscard-dnie-exaples

Simple APDU commands for DNIe using pyscard. View http://opendnie.cenatic.es/wiki/index.php/Documentacion_DNIe_Comandos

Pre requisites: Pyscard instalation

Pyscard is the python smartcard library you need to execute this examples

From source

  1. Download latest
  2. Download and install python dependencies
  1. Unpackage and install pyscard:
setup.py install

Debian package

~$ sudo apt-get install python-pyscard

Exercices DNIe

  • GET CHIP INFO
  • SELECT && GET RESPONSE
  • GET CHALLENGE

GET CHIP INFO

Doc reference (spanish): http://opendnie.cenatic.es/wiki/index.php/Documentacion_DNIe_Comandos#Informaci.C3.B3n_de_control_de_fichero_.28FCI.29

This example gets the serial number of the DNIe:

# define the apdus used in this script
# apdu bytes
CLA=0x90
INS=0xB8
P1=0x00
P2=0x00
LE=0x07
# apdu chip info apdu
CHIP_INFO = [CLA, INS, P1, P2, LE]

and show it in console:

    # there is a DNIe
    if sw1 == 0x90:
        print 'serial number: ', toHexString(response)

To execute:

~$ ./getCHIP_INFO_dnie.py 
insert a card (SIM card if possible) within 10s
connecting to C3PO LTC31 (80060327) 00 00
>  90 B8 00 00 07
<  ** ** ** ** ** ** ** 90 0 
serial number:  ** ** ** ** ** ** **
disconnecting from C3PO LTC31 (80060327) 00 00
disconnecting from C3PO LTC31 (80060327) 00 00
~$

SELECT && GET RESPONSE

Doc reference (spanish):

This example reads the 0x60, 0x1F path in a DNIe:

~$ ./selectDNIe.py 
insert a card (SIM card if possible) within 10s
connecting to C3PO LTC31 (80060327) 00 00
>  00 A4 00 00 02 60 1F
<  []  61 E 
>  00 C0 00 00 0E
<  ** ** ** ** ** ** ** ** ** ** ** ** ** ** 90 0 
disconnecting from C3PO LTC31 (80060327) 00 00
disconnecting from C3PO LTC31 (80060327) 00 00
~$

GET CHALLENGE

Doc reference (spanish):

This sample get a challenge to be used in a security procedure:

~$ ./getChallenge.py 
insert a card (SIM card if possible) within 10s
connecting to C3PO LTC31 (80060327) 00 00
>  00 84 00 00 08
<  49 95 52 E4 05 70 55 20 90 0 
Challenge is 49 95 52 E4 05 70 55 20
~$

Releases

No releases published

Packages

No packages published

Languages