Ejemplo n.º 1
0
    def __eac_pace_step2(self, data):
        tlv_data = nPA_SE.__unpack_general_authenticate(data)

        pubkey = eac.PACE_STEP3A_generate_mapping_data(self.eac_ctx)
        if not pubkey:
            eac.print_ossl_err()
            raise SwError(SW["WARN_NOINFO63"])

        for tag, length, value in tlv_data:
            if tag == 0x81:
                eac.PACE_STEP3A_map_generator(self.eac_ctx, value)
            else:
                raise SwError(SW["ERR_INCORRECTPARAMETERS"])

        self.eac_step += 1

        return 0x9000, \
            nPA_SE.__pack_general_authenticate([[0x82, len(pubkey), pubkey]])
Ejemplo n.º 2
0
 def get_static_pubkey(self):
     self._static_pubkey = eac.PACE_STEP3A_generate_mapping_data(self.ctx)
     return self._static_pubkey
Ejemplo n.º 3
0
print("Secret:")
print(eac.PACE_SEC_print_private(secret, 4))

picc_ctx = eac.EAC_CTX_new()
pcd_ctx = eac.EAC_CTX_new()
eac.EAC_CTX_init_ef_cardaccess(EF_CARDACCESS, pcd_ctx)
eac.EAC_CTX_init_ef_cardaccess(EF_CARDACCESS, picc_ctx)

print("PACE step 1")
enc_nonce = eac.PACE_STEP1_enc_nonce(picc_ctx, secret)

print("PACE step 2")
eac.PACE_STEP2_dec_nonce(pcd_ctx, secret, enc_nonce)

print("PACE step 3A")
pcd_mapping_data = eac.PACE_STEP3A_generate_mapping_data(pcd_ctx)
picc_mapping_data = eac.PACE_STEP3A_generate_mapping_data(picc_ctx)

eac.PACE_STEP3A_map_generator(pcd_ctx, picc_mapping_data)
eac.PACE_STEP3A_map_generator(picc_ctx, pcd_mapping_data)

print("PACE step 3B")
pcd_ephemeral_pubkey = eac.PACE_STEP3B_generate_ephemeral_key(pcd_ctx)
picc_ephemeral_pubkey = eac.PACE_STEP3B_generate_ephemeral_key(picc_ctx)

eac.PACE_STEP3B_compute_shared_secret(pcd_ctx, picc_ephemeral_pubkey)
eac.PACE_STEP3B_compute_shared_secret(picc_ctx, pcd_ephemeral_pubkey)

print("PACE step 3C")
eac.PACE_STEP3C_derive_keys(pcd_ctx)
eac.PACE_STEP3C_derive_keys(picc_ctx)