Example #1
0
    def __eac_pace_step4(self, data):
        tlv_data = nPA_SE.__unpack_general_authenticate(data)
        eac.PACE_STEP3C_derive_keys(self.eac_ctx)
        my_token = \
            eac.PACE_STEP3D_compute_authentication_token(self.eac_ctx,
                                                         self.pace_opp_pub_key)
        token = b""
        for tag, length, value in tlv_data:
            if tag == 0x85:
                token = value
            else:
                raise SwError(SW["ERR_INCORRECTPARAMETERS"])

        ver = eac.PACE_STEP3D_verify_authentication_token(self.eac_ctx, token)
        if not my_token or ver != 1:
            eac.print_ossl_err()
            raise SwError(SW["WARN_NOINFO63"])

        print("Established PACE channel")

        if self.at.keyref_is_can():
            if (self.sam.counter == 1):
                self.sam.active = True
                print("PIN resumed")
        elif self.at.keyref_is_pin():
            self.sam.active = True
            self.sam.counter = 3
        elif self.at.keyref_is_puk():
            self.sam.active = True
            self.sam.counter = 3
            print("PIN unblocked")

        self.eac_step += 1
        self.at.algorithm = "TA"

        self.new_encryption_ctx = eac.EAC_ID_PACE

        result = [[0x86, len(my_token), my_token]]
        if self.at.chat:
            if self.cvca:
                self.car = CVC(self.cvca).get_chr()
            result.append([0x87, len(self.car), self.car])
            if (self.disable_checks):
                eac.TA_disable_checks(self.eac_ctx)
            if not eac.EAC_CTX_init_ta(self.eac_ctx, None, self.cvca):
                eac.print_ossl_err()
                raise SwError(SW["WARN_NOINFO63"])

        return 0x9000, nPA_SE.__pack_general_authenticate(result)
Example #2
0
def cvctest():
    cvc = CVC(TEST_CVC)
    cvc_desc = eac.d2i_CVC_CERTIFICATE_DESCRIPTION(TEST_DESCRIPTION)
    print cvc.chat
    #eac.cvc_chat_print(cvc.chat, 4)

    asn1_chat = "\x7F\x4C\x12\x06\x09\x04\x00\x7F\x00\x07\x03\x01\x02\x02\x53\x05\x00\x01\x01\x98\x04"

    chat = CHAT(asn1_chat)
    print(chat)
    print(chat.get_role())
    print(chat.get_terminal_type())
    print(chat.get_relative_authorizations())

    eac.CVC_CERTIFICATE_DESCRIPTION_free(cvc_desc)

    terminal_cert = CVC(CHAIN_CVC)
    print terminal_cert
    dvca_cert = CVC(DVCA)
    print dvca_cert
    cvca_cert = CVC(CVCA)
    print("Certificate chain:")
    print(cvca_cert.get_chr() + " -> " + dvca_cert.get_chr() + " -> " +
          terminal_cert.get_chr())
    print(terminal_cert.get_chr() + " -> " + terminal_cert.get_car() + " -> " +
          dvca_cert.get_car())
    print("Terminal certificate validity period:")
    print(terminal_cert.get_effective_date())
    print(terminal_cert.get_expiration_date())
    print("Terminal certificate profile identifier")
    print(terminal_cert.get_profile_identifier())
Example #3
0
def cvctest():
    cvc = CVC(TEST_CVC)
    cvc_desc = eac.d2i_CVC_CERTIFICATE_DESCRIPTION(TEST_DESCRIPTION)
    print cvc.chat
    #eac.cvc_chat_print(cvc.chat, 4)

    asn1_chat="\x7F\x4C\x12\x06\x09\x04\x00\x7F\x00\x07\x03\x01\x02\x02\x53\x05\x00\x01\x01\x98\x04"

    chat = CHAT(asn1_chat)
    print(chat)
    print(chat.get_role())
    print(chat.get_terminal_type())
    print(chat.get_relative_authorizations())

    eac.CVC_CERTIFICATE_DESCRIPTION_free(cvc_desc)

    terminal_cert = CVC(CHAIN_CVC)
    print terminal_cert
    dvca_cert = CVC(DVCA)
    print dvca_cert
    cvca_cert = CVC(CVCA)
    print("Certificate chain:")
    print(cvca_cert.get_chr() + " -> " + dvca_cert.get_chr() + " -> " + terminal_cert.get_chr())
    print(terminal_cert.get_chr() + " -> " + terminal_cert.get_car() + " -> " + dvca_cert.get_car())
    print("Terminal certificate validity period:")
    print(terminal_cert.get_effective_date())
    print(terminal_cert.get_expiration_date())
    print("Terminal certificate profile identifier")
    print(terminal_cert.get_profile_identifier())