Пример #1
0
 def internal_auth(self):
     S_ENC = self.process_key().s_enc_session_key
     host_challenge = nonce.Terminal_Generator_8()
     card_challenge = nonce.Terminal_Generator_6()
     icv = '0000000000000000'
     d_data = host_challenge + '0000' + card_challenge + '8000000000000000'
     data = d_data.decode('hex')
     host_cryptogram = DES3.new(S_ENC, MODE_CBC, icv).encrypt(data)
     logging.debug('host cryptogram: %s' % host_cryptogram)
Пример #2
0
class GetApplicationInformation(CAPDU):
    """Used for getting the traffic card application version information,

     mainly include: internal version number, external version number,

     the application life cycle state, ordering information
     """

    name = 'GetApplicationInformation'

    SERIAL = nonce.Terminal_Generator_8() #8字节终端随机数

    def __init__(self,data):
        super(GetApplicationInformation, self).__init__()


        if self.p1 == 0x00 and self.p2 == 0x01 or 0x80:

            self.data = None
            self.le = 0x00
            logging.debug('获取内部版本号')
        elif self.p1 == 0x00 and self.p2 == 0x02:

            self.data = None
            self.le = 0x00
            logging.debug('获取外部版本号')
        elif self.p1 == 0x00 and self.p2 == 0x03:

            self.data = None
            self.le = 0x00
            logging.debug('获取应用生命周期状态')
        elif self.p1 == 0x01 or 0x02 or 0x07 or 0x5A and self.p2 == 04:
            if self.p1 == 0x01:
                logging.debug('根据主版本号')
            elif self.p1 == 0x02:
                logging.debug('根据次版本号')
            elif self.p1 == 0x07:
                logging.debug('根据修订版本号')
            elif self.p1 == 0x5A:
                logging.debug('根据发行模式')

            self.data = data #data = nonce.Terminal_Generator_8()
            self.le =None
            logging.debug('获取订购信息')
Пример #3
0
    def external_auth(self):
        S_ENC = self.process_key().s_enc_session_key
        C_MAC = self.process_key().c_mac_session_key
        length_c_mac = len(C_MAC)
        host_challenge = nonce.Terminal_Generator_8()
        card_challenge = nonce.Terminal_Generator_6()
        icv = '0000000000000000'
        d_data = '0000' + card_challenge + host_challenge + '8000000000000000'
        data = d_data.decode('hex')
        host_cryptogram = DES3.new(S_ENC, MODE_CBC, icv).encrypt(data)

        der_data = '8482010010' + host_cryptogram
        length = len(der_data)
        der_data1 = der_data[:length / 2]
        der_data2 = der_data[length / 2:]
        icv1 = DES.new(C_MAC[0:length_c_mac / 2], MODE_CBC,
                       icv).encrypt(der_data1)
        mac = DES3.new(C_MAC, MODE_CBC, icv1).encrypt(der_data2)
        logging.debug('mac: %s' % mac)
Пример #4
0
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# date        :2018/1/
# discriptions :
# vision      :
# copyright   :All copyright reserved by FMSH company
__author__ = 'zuodengbo'
import nonce

SELECT_FILE = 0x6F328409A00000000386980701A5259F0801029F0C1E869820007590FFFF82052000B2D0614C800960A720140504201605040914
GET_APPLICATION_VERSION = ''
STORE_DATA = None
GET_CHALLENGE = nonce.Terminal_Generator_8()
print(GET_CHALLENGE)
GET_APPLICATION_INFORMATION = ''
INITIALIZE_FOR_LOAD = 0x00030F980004010020A124BA1D7E073D
CREDIT_FOR_LOAD = 0x17B8946D
EXTRADITION = 0x1612120A00002E090102075A90800960A7F716C6B4905AD5C4D50F2C82170FFC5B7713B2C7D23E9AB1A3F06DD3AC7654112D93EBA7DE4B54AF309BF3F6E72E758AAD122E8EDC78DCC9A09FECB689F77350559A4D1DBBFC98CE