pyGlobalPlatform

u64_line

pyGlobalPlatform is an open source python globalplatform client library. It depends on the GlobalPlatform project. Using this library, you can use all features of GlobalPlatform project via Python programming language.

Download

More>>

pyGlobalPlatform Structure

pyGlobalPlatform-py

------ friendly python library of GlobalPlatform

pyGlobalPlatform-pyd

------ python library of GlobalPlatform

project GlobalPlatform

------ opensource project GlobalPlatform

Usage Demo

  • 1. list smartcard readers

     
    # Import the module
    import globalplatformlib as gp
    
    # Establish context
    context = gp.establishContext()
    
    # List readers
    readernames = gp.listReaders(context)
    
    # print all the reader names
    for readername in readernames:
    print readername
    
    # Release context
    gp.releaseContext(context)
    										 
  • 2. Get data in the card

     
    # Import the module
    import globalplatformlib as gp
    
    # Establish context
    context = gp.establishContext()
    
    # Select smartcard reader
    readernames = gp.listReaders(context)
    readerName=readernames[0]
    
    # Connect the reader
    cardInfo = gp.connectCard(context, readerName, gp.SCARD_PROTOCOL_Tx)
    
    # Get SCP details
    scp, scpi = gp.getSCPDetails(context, cardInfo)
    
    # Mutual Authentication
    securityInfo = gp.mutualAuthentication(context, cardInfo, gp.DEFAULT_KEY, gp.DEFAULT_KEY, gp.DEFAULT_KEY, gp.DEFAULT_KEY, 0, 0, scp, scpi, 0, 0)
    
    # Get data from card
    data1 = gp.getData(context, cardInfo, securityInfo, gp.TAG_DATA_IIN)
    data2 = gp.getData(context, cardInfo, securityInfo, gp.TAG_DATA_CIN)
    data3 = gp.getData(context, cardInfo, securityInfo, gp.TAG_DATA_CARD_DATA)
    data4 = gp.getData(context, cardInfo, securityInfo, gp.TAG_DATA_KEY_INFORMATION_TEMPLATE)
    # Optional
    data5 = gp.getData(context, cardInfo, securityInfo, gp.TAG_DATA_SECURITY_LEVEL)
    # Optional
    data6 = gp.getData(context, cardInfo, securityInfo, gp.TAG_DATA_APPLICATIONS)
    # Optional
    data7 = gp.getData(context, cardInfo, securityInfo, gp.TAG_DATA_EXTENDED_CARD_RESOURCE_INFORMATION)
    # Optional
    data8 = gp.getData(context, cardInfo, securityInfo, gp.TAG_CONFIRMATION_COUNTER)
    data9 = gp.getData(context, cardInfo, securityInfo, gp.TAG_SEQUENCE_COUNTER)
    
    # Release context
    gp.releaseContext(context)
    
    # Print the card information
    if data1 != -1:
        print "1 IIN: " + "".join("%02X" %(ord(b)) for b in data1)
    if data2 != -1:
        print "2 CIN: " + "".join("%02X" %(ord(b)) for b in data2)
    if data3 != -1:
        print "3 CARD DATA: " + "".join("%02X" %(ord(b)) for b in data3)
    if data4 != -1:
        print "4 KEY INFORMATION TEMPLATE: " + "".join("%02X" %(ord(b)) for b in data4)
    if data5 != -1:
        print "5 SECURITY LEVEL: " + "".join("%02X" %(ord(b)) for b in data5)
    if data6 != -1:
        print "6 APPLICATIONS: " + "".join("%02X" %(ord(b)) for b in data6)
    if data7 != -1:
        print "7 EXTENDED CARD RESOURCE INFORMATION: " + "".join("%02X" %(ord(b)) for b in data7)
    if data8 != -1:
        print "8 CONFIRMATION COUNTER: " + "".join("%02X" %(ord(b)) for b in data8)
    if data9 != -1:
        print "9 SEQUENCE COUNTER: " + "".join("%02X" %(ord(b)) for b in data9)
    										 
  • 3. Establish secure channel

    										
    # Import the module
    import globalplatformlib as gp
    
    # Establish Context
    context = gp.establishContext()
    
    # Select the smartcard reader you want to connect
    readernames = gp.listReaders(context)
    readerName=readernames[0]
    
    #Connect reader
    cardInfo = gp.connectCard(context, readerName, gp.SCARD_PROTOCOL_Tx)
    
    # Get SCP details
    scp, scpi = gp.getSCPDetails(context, cardInfo)
    
    # Mutual Authentication
    securityInfo = gp.mutualAuthentication(context, cardInfo, gp.DEFAULT_KEY, gp.DEFAULT_KEY, gp.DEFAULT_KEY, gp.DEFAULT_KEY, 0, 0, scp, scpi, 0, 0)
    
    # Release context
    gp.releaseContext(context)
    										 
  • 4. Load package and install applet

     
    # Import the module
    import globalplatformlib as gp
    
    # EstablishContext
    context = gp.establishContext()
    
    # Select smartcard reader
    readernames = gp.listReaders(context)
    readerName=readernames[0]
    
    # Connect the reader
    cardInfo = gp.connectCard(context, readerName, gp.SCARD_PROTOCOL_Tx)
    
    # Get SCP details
    scp, scpi = gp.getSCPDetails(context, cardInfo)
    
    # Mutual Authentication
    securityInfo = gp.mutualAuthentication(context, cardInfo, gp.DEFAULT_KEY, gp.DEFAULT_KEY, gp.DEFAULT_KEY, gp.DEFAULT_KEY, 0, 0, scp, scpi, 0, 0)
    
    # Select CAP file
    capFile = PATH_TO_CAP_FILE
    loadFileInfo = gp.readExecutableLoadFileParameters(capFile)
    packageAID = loadFileInfo['loadFileAID']
    appletAID = loadFileInfo['applets'][0]
    
    # Delete the same package which has been already in the card.
    try:
        ret = gp.deleteApplication(context, cardInfo, securityInfo, packageAID)
    except Exception, e:
        print e.message
        pass
    
    # Install the applet
    ret = gp.installForLoad(context, cardInfo, securityInfo, packageAID, gp.AID_ISD, '', '', 0, 0, 0)
    if ret == -1:
        raise Exception("Install for load failed.")
    ret = gp.load(context, cardInfo, securityInfo, '', capFile)
    if ret == -1:
        raise Exception("Load failed.")
    ret = gp.installForInstall(context, cardInfo, securityInfo, packageAID, appletAID, appletAID, 0, 0, 0, 0, '')
    if ret == -1:
        raise Exception("Install failed.")
    
    # Release context
    gp.releaseContext(context)
    										 
  • 5. Get status

     
    # Import the module
    import globalplatformlib as gp
    
    # EstablishContext
    context = gp.establishContext()
    
    # Select smartcard reader
    readernames = gp.listReaders(context)
    readerName=readernames[0]
    
    # Connect the reader
    cardInfo = gp.connectCard(context, readerName, gp.SCARD_PROTOCOL_Tx)
    
    # Get SCP details
    scp, scpi = gp.getSCPDetails(context, cardInfo)
    
    # Mutual Authentication
    securityInfo = gp.mutualAuthentication(context, cardInfo, gp.DEFAULT_KEY, gp.DEFAULT_KEY, gp.DEFAULT_KEY, gp.DEFAULT_KEY, 0, 0, scp, scpi, 0, 0)
    
    # Get data from card
    isd = gp.getStatus(context, cardInfo, securityInfo, gp.GET_STATUS_P1_ISD)
    appSSDs = gp.getStatus(context, cardInfo, securityInfo, gp.GET_STATUS_P1_APP_SSD)
    exeFiles = gp.getStatus(context, cardInfo, securityInfo, gp.GET_STATUS_P1_EXECUTABLE_LOAD_FILES)
    exeFilesModules = gp.getStatus(context, cardInfo, securityInfo, gp.GET_STATUS_P1_EXECUTABLE_LOAD_FILES_MODULES)
    
    # Release context
    gp.releaseContext(context)
      
    # Print the data  
    for status in (isd, appSSDs, exeFiles, exeFilesModules):
        print "-------------------------------------"
        if status != -1:
            appsInfo, fileModulesInfo = status
            for appInfo in appsInfo:
                print "AID: %s - PRIV: %02X - LIFE-CYCLE-STATE: %02X" %("".join("%02X" %(ord(b)) for b in appInfo['aid']), appInfo['privileges'], appInfo['lifeCycleState'])
            for fileModuleInfo in fileModulesInfo:
                print "AID: %s - PRIV: %02X" %("".join("%02X" %(ord(b)) for b in fileModuleInfo['aid']), fileModuleInfo['lifeCycleState'])
                for moduleInfo in fileModuleInfo['executableModules']:
                    print "    " + "".join('%02X' %(ord(b)) for b in moduleInfo)
    										 

Documentation

  • 1. establishContext() -- Establish a context to connect layer

    • Return the context established.
    • Exception raised if failed.
  • 2. releaseContext(context)-- Release the context to the connection layer established by establish_context().

    • context: The context established by establish_context().
    • Returns 0 if successful.
    • Exception raised if failed.
  • 3. listReaders(context)-- Return a list of current available readers.

    • context: The context established by establish_context().
    • Returns 0 if successful.
    • Exception raised if failed.
  • 4. connectCard(context, readerName, protocul)-- Connect to a reader.
    • context: The context established by establish_context().
    • readerName: The reader name.
    • protocul: Connection protocul, the value can be one of:
      • SCARD_PROTOCOL_UNDEFINED = 0x00000000
      • SCARD_PROTOCOL_T0 = 0x00000001
      • SCARD_PROTOCOL_T1 = 0x00000002
      • SCARD_PROTOCOL_RAW = 0x00010000
      • SCARD_PROTOCOL_Tx = (SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1)
    • Return cardInfo if successful, cardInfo is used in the fullowing functions.
    • Exception raised if failed.
  • 5. disconnectCard(context, cardInfo)-- Disconnect a reader.

    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • Return 0 if successful.
    • Exception raised if failed.
  • 6. selectApplication(context, cardInfo, aid)-- Select an application on a card by AID.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • aid: The id of application.
    • Return 0 if successful.
    • Exception raised if failed.
  • 7. mutualAuthentication(context, cardInfo, baseKey, sencKey, smacKey, dekKey, keySetVersion, keyIndex, scp, scpi, securityLevel, derivationMethod)-- Mutual authentication
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • baseKey: Secure Channel base key or the master key for the key derivation.
    • sencKey: Secure Channel Encryption Key.
    • smacKey: Secure Channel Message Authentication Code Key.
    • dekKey: Data Encryption Key.
    • keySetVersion: The key set version on the card to use for mutual authentication.
    • keyIndex: The key index of the encryption key in the key set version on the card to use for mutual authentication.
    • scp: The Secure Channel Protocul.
    • scpi: The Secure Channel Protocul Implementation.
    • securityLevel: The requested security level.
    • derivationMethod: The derivation method to use for.
    • Return securityInfo if successful, securityInfo is used in functions which uses Secure Channel.
    • Exception raised if failed.
  • 8. getStatus(context, cardInfo, securityInfo, cardElement)-- Get the life cycle status of Applications, the Issuer Security Domains, Security Domains and Executable Load Files and their privileges or information about Executable Modules of the Executable Load Files.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication().
    • cardElement: Identifier to retrieve data for Load Files, Applications or the Card Manager. The value is one of:
      • GET_STATUS_P1_ISD = 0x80
      • GET_STATUS_P1_APP_SSD = 0x40
      • GET_STATUS_P1_EXECUTABLE_LOAD_FILES = 0x20
      • GET_STATUS_P1_EXECUTABLE_LOAD_FILES_MODULES = 0x10
    • Return tuple(appletsData, executableModulesData) if successful. Each appletData contains aid/lifeCycleState/privileges of applet. Each executableModuleData contains aid/lifeCycleState and executableModules aids.
    • Exception raised if failed.
  • 9.setStatus(context, cardInfo, securityInfo, cardElement, aid, lifeCycleState)-- Sets the life cycle status of Applications, Security Domains or the Card Manager.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication().
    • cardElement: Identifier to retrieve data for Load Files, Applications or the Card Manager. The value is one of:
      • GET_STATUS_P1_ISD = 0x80
      • GET_STATUS_P1_APP_SSD = 0x40
      • GET_STATUS_P1_EXECUTABLE_LOAD_FILES = 0x20
      • GET_STATUS_P1_EXECUTABLE_LOAD_FILES_MODULES = 0x10
    • aid: The id of applet.
    • lifeCycleState: The new life cycle state.
    • Return 0 if successful.
    • Exception raised if failed.
  • 10. getData(context, cardInfo, securityInfo, identifier)-- Retrieve card data.

    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • identifier: Two byte buffer with high and low order tag value for identifying card data object. The value is one of:
      • TAG_DATA_IIN = '42'
      • TAG_DATA_CIN = '45'
      • TAG_DATA_CARD_DATA = '66'
      • TAG_DATA_KEY_INFORMATION_TEMPLATE = '0'
      • TAG_DATA_SECURITY_LEVEL = '3'
      • TAG_DATA_APPLICATIONS = '2F00'
      • TAG_DATA_EXTENDED_CARD_RESOURCE_INFORMATION = '21'
      • TAG_CONFIRMATION_COUNTER = '2'
      • TAG_SEQUENCE_COUNTER = '1'
    • Return the data.
    • Exception raised if failed.
  • 11.putData(context, cardInfo, securityInfo, identifier, data)-- Put card data.

    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • identifier: Two byte buffer with high and low order tag value for identifying card data object. The value is one of:
      • TAG_DATA_IIN = '42'
      • TAG_DATA_CIN = '45'
      • TAG_DATA_CARD_DATA = '66'
      • TAG_DATA_KEY_INFORMATION_TEMPLATE = '0'
      • TAG_DATA_SECURITY_LEVEL = '3'
      • TAG_DATA_APPLICATIONS = '2F00'
      • TAG_DATA_EXTENDED_CARD_RESOURCE_INFORMATION = '21'
      • TAG_CONFIRMATION_COUNTER = '2'
      • TAG_SEQUENCE_COUNTER = '1'
    • data: The data.
    • Return 0 if successful.
    • Exception raised if failed.
  • 12. getSCPDetails(context, cardInfo)-- Get the Secure Channel Protocul and the Secure Channel Protocul implementation.

    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • Return tuple(scp, scpi) if successful.
    • Exception raised if failed.
  • 13. getSequenceCounter(context, cardInfo)-- Get the current Sequence Counter.

    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • Return sequence counter if successful.
    • Exception raised if failed.
  • 14. putSCKey(context, cardInfo, securityInfo, keysetVersion, newKeySetVersion, newBaseKey, newSEncKey, newSMacKey, newDEKKey)-- Replace or add a secure channel key set consisting of S-ENC, S-MAC and DEK.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • keysetVersion: An existing key set version.
    • newKeySetVersion: The new key set version.
    • newBaseKey: The new Secure Channel base key.
    • newSEncKey: The new S-ENC key.
    • newSMacKey: The new S-MAC key.
    • newDEKKey: The new DEK.
    • Return 0 if successful.
    • Exception raised if failed.
  • 15. deleteKey(context, cardInfo, securityInfo, keysetVersion, keyIndex)-- Delete a key or multiple keys.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • keysetVersion: An existing key set version.
    • keyIndex: The index of key in the keyset.
    • Return 0 if successful.
    • Exception raised if failed.
  • 16. getKeyInformationTemplates(context, cardInfo, securityInfo, num)-- Retrieve key information of keys on the card.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • num: The number of the key information template.
    • Return key information template data if successful.
    • Exception raised if failed.
  • 17. deleteApplication(context, cardInfo, securityInfo, aids)-- Delete Executable Load Files or applications.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • aids: aids of the applications and load files to delete.
    • Return 0 if successful.
    • Exception raised if failed.
  • 18. installForLoad(context, cardInfo, securityInfo, packageAID, sdAID, dataBlockHash, loadToken, nonVulatileCodeSpaceLimit, vulatileDataSpaceLimit, nonVulatileDataSpaceLimit)-- Prepare the card for loading an application.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • packageAID: The Executable Load File AID.
    • sdAID: The Security Domain AID.
    • dataBlockHash: The Load File Data Block Hash of the Executable Load File.
    • loadToken: The Load Token. This is a 1024 bit (=128 byte) RSA Signature.
    • nonVulatileCodeSpaceLimit: The minimum amount of space that must be available to store the package.
    • vulatileDataSpaceLimit: The minimum amount of RAM space that must be available.
    • nonVulatileDataSpaceLimit: The minimum amount of space for objects of the application.
    • Return 0 if successful.
    • Exception raised if failed.
  • 19. load(context, cardInfo, securityInfo, dapBlock, packageFileName)-- Load a Executable Load File (containing an application) to the card.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • dapBlock: The DAP block.
    • packageFileName: The package file path name.
    • Return receiptData if successful.
    • Exception raised if failed.
  • 20. loadFromBuffer(context, cardInfo, securityInfo, dapBlock, packageBuf)-- Load a Executable Load File (containing an application) from a buffer to the card.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • dapBlock: The DAP block.
    • packageBuf: The package data buffer.
    • Return receiptData if successful.
    • Exception raised if failed.
  • 21. installForInstall(context, cardInfo, securityInfo, packageAID, moduleAID, appletAID, privileges, vulatileDataSpaceLimit, nonVulatileDataSpaceLimit, installParameters, installToken)-- Install an application on the card.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • packageAID: AID of the Executable Load File.
    • moduleAID: The AID of the application class in the package.
    • appletAID: The AID of the installed application.
    • privileges: The application privileges.
    • vulatileDataSpaceLimit: The minimum amount of RAM space that must be available.
    • nonVulatileDataSpaceLimit: The minimum amount of space for objects of the application, i.e. the data allocated in its lifetime.
    • installParameters: Applet install parameters for the install() method of the application.
    • installToken: The Install Token. This is a 1024 bit (=128 byte) RSA Signature.
    • Return receiptData if successful.
    • Exception raised if failed.
  • 22.installForMakeSelectable(context, cardInfo, securityInfo, appletAID, privileges, installToken)-- Make an installed application selectable.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • appletAID: The AID of the installed application or security domain.
    • privileges: The application privileges. Can be an OR of multiple privileges.
    • installToken: The Install Token. This is a 1024 bit (=128 byte) RSA Signature.
    • Return receiptData if successful.
    • Exception raised if failed.
  • 23. installForInstallAndMakeSelectable(context, cardInfo, securityInfo, packageAID, moduleAID, appletAID, privileges, vulatileDataSpaceLimit, nonVulatileDataSpaceLimit, installParameters, installToken)-- Install and make an installed application selectable.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • packageAID: AID of the Executable Load File.
    • moduleAID: The AID of the application class in the package.
    • appletAID: The AID of the installed application.
    • privileges: The application privileges.
    • vulatileDataSpaceLimit: The minimum amount of RAM space that must be available.
    • nonVulatileDataSpaceLimit: The minimum amount of space for objects of the application, i.e. the data allocated in its lifetime.
    • installParameters: Applet install parameters for the install() method of the application.
    • installToken: The Install Token. This is a 1024 bit (=128 byte) RSA Signature.
    • Return receiptData if successful.
    • Exception raised if failed.
  • 24. installForPersonalization(context, cardInfo, securityInfo, appAID)-- Inform a Security Domain that a associated application will retrieve personalization data.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • appAID: The AID of the installed application.
    • Return receiptData if successful.
    • Exception raised if failed.
  • 25. insatllForExtradition(context, cardInfo, securityInfo, sdAID, appletAID, extrationToken)-- Associate an application with another Security Domain.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • sdAID: The Security Domain AID.
    • appletAID: The AID of the installed application.
    • extrationToken: The Install Token. This is a 1024 bit (=128 byte) RSA Signature.
    • Return receiptData if successful.
    • Exception raised if failed.
  • 26. sendApdu(context, cardInfo, securityInfo, capdu)-- Send an application protocul data unit.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • capdu: The command APDU to send.
    • Return response APDU data if successful.
    • Exception raised if failed.
  • 27. manageChannel(context, cardInfo, securityInfo, openClose, channelToClose)-- Open or close a Logical Channel.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • openClose: Open or close?
    • channelToClose: The Logical Channel number to close.
    • Return the Logical Channel number opened if successful.
    • Exception raised if failed.
  • 28. selectChannel(cardInfo, channelNUmber)-- If multiple Logical Channels are open or a new Logical Channel is opened with select_application(), select the Logical Channel.
    • cardInfo: The cardInfo returned by connectCard().
    • channelNUmber: The Logical Channel number to select.
    • Returns 0 if success.
    • Exception raised if failed.
  • 29. storeData(context, cardInfo, securityInfo, data)-- The STORE DATA command is used to transfer data to an Application or the Security Domain processing the command.
    • context: The context established by establish_context().
    • cardInfo: The cardInfo returned by connectCard().
    • securityInfo: The securityInfo returned by mutualAuthentication(), null if securityInfo not needed.
    • data: Data to send to application or Security Domain.
    • Return 0 if successful.
    • Exception raised if failed.
  • 30. readExecutableLoadFileParameters(fileName)-- Read the parameters of an Executable Load File.
    • fileName: The name of file to parse.
    • Return dict("loadFileSize", "loadFileAID", "applets") if successful. Applets contain aids of all applets in the executable load file.
    • Exception raised if failed.
  • 31. enableTraceMode(v)-- Enable the trace mode.
    • v: Enable or disable the trace mode.
    • Return 0 if successful.

Installation

  • 1.Preparation
    • Windows platform:
      • > Set GlobalPlatform library path:
        set GLOBALPLATFORM_ROOT=/PATH/TO/GLOBALPLATFORM/ROOT
      • > Put globalplatform.dll and gppcscconnectionplugin.dll in system PATH directory.
    • Linux platform:
      • > Install globalplatform
        • Download globalplatform-6.0.0.tar.gz
        • Unzip installation package
          tar zxvf globalplatform-6.0.0.tar.gz
        • Go to installation directory
          cd globalplatform-6.0.0
        • Install
           ./configure --prefix=/usr
          make
          sudo make install 
      • > Install gppcscconnectionplugin
        • Download gppcscconnectionplugin-1.1.0.tar.gz
        • Unzip installation package
          tar zxvf gppcscconnectionplugin-1.1.0.tar.gz
        • Go to installation directory
          cd gppcscconnectionplugin-1.1.0
        • Install
           ./configure --prefix=/usr
           make
          sudo make install 
    • Note:
      Download GlobalPlatform library Here.
  • 2.Install from Pypi:
      • >Install with command:
        pip install pyGlobalPlatform
      • >Upgrade with command:
        pip install --upgrade pyGlobalPlatform
  • 3.Installation verification
      • >Code to verify
      •  # List all the current smart card readers. If successful, it indicates that pyGlobalPlatform is installed successfully.
        		 from pyGlobalPlatform import globalplatformlib as gp
        		sccontext = gp.establishContext() 
        		gp.listReaders(sccontext)
      • >Run test script
         python tests/test.py

Discussion

Follow us