from apptest import Card, GP
from apptest.TLV import LV

SD_AID = 'A000000151000000'
PBOC_PKG_AID = 'B0004E5850050000000102'
PBOC_MDL_AID = 'B0004E585004D000000102' 


def _installPBOC(card):
    aid  = 'A00000033301010600030800005A5954'
    card.Transmit('00A4040000') 
    gp = GP.GP('404142434445464748494A4B4C4D4E4F', '404142434445464748494A4B4C4D4E4F', '404142434445464748494A4B4C4D4E4F', '0C')
    gp.Authentication(card, '01')
    gp.Delete(aid,card)
    #p = 'C9'+LV('E10101F10130')+'EF'+ LV('A0'+LV('A5038201C0810100')+'A1'+LV('A6'+LV('BF0C'+LV('61'+LV('4F'+LV(aid)+'50'+LV('50424F435F437265646974')+'870101')))+'A3'+LV('4F'+LV('325041592e5359532e4444463031'))+'87'+LV('01')))
    #p = 'C900' 
    p = 'C9'+LV('E10101F10130')+'EF44A008A5038201C0810101A138A624BF0C21611F4F10A00000033301010600030800005A5954500B50424F435F437265646974A3104F0E325041592E5359532E4444463031'
    gp.Install(PBOC_PKG_AID, PBOC_MDL_AID, aid, card,p)
    card.Transmit('00A40400'+LV('A00000015143525300'))
    card.Transmit('80F00101'+LV('4F'+LV(aid)))

if __name__ == '__main__': 
    card = Card.Card()
    _installPBOC(card)
     