From 06d96e6faed631f3ddf0683c5c0e3174d31c5ab2 Mon Sep 17 00:00:00 2001 From: frankmorgner Date: Thu, 9 Feb 2012 10:00:48 +0000 Subject: [PATCH] fixed CA, which is now successfully tested git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@712 96b47cad-a561-4643-ad3b-153ac7d7599c --- .../src/vpicc/virtualsmartcard/cards/nPA.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py b/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py index 0cb725a..26461fa 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py @@ -200,6 +200,11 @@ class nPA_SE(Security_Environment): pace.EAC_CTX_init_ef_cardaccess(ef_card_access_data, self.eac_ctx) pace.EAC_CTX_init_ca(self.eac_ctx, pace.id_CA_ECDH_AES_CBC_CMAC_128, 13, None, None) + # we don't have a good CA key, so we simply generate an ephemeral one + if not pace.TA_STEP3_generate_ephemeral_key(self.eac_ctx): + pace.print_ossl_err() + raise SwError(SW["WARN_NOINFO63"]) + nonce = pace.buf2string(pace.PACE_STEP1_enc_nonce(self.eac_ctx, self.sec)) resp = nPA_SE.__pack_general_authenticate([[0x80, len(nonce), nonce]]) @@ -292,13 +297,14 @@ class nPA_SE(Security_Environment): else: raise SwError(SW["ERR_INCORRECTPARAMETERS"]) - if pace.CA_STEP4_compute_shared_secret(self.eac_ctx, - pace.get_buf(pubkey)) != 1: + if pace.CA_STEP4_compute_shared_secret(self.eac_ctx, pubkey) != 1: pace.print_ossl_err() raise SwError(SW["ERR_NOINFO69"]) nonce, token = pace.CA_STEP5_derive_keys(self.eac_ctx, pubkey) + print "Generated Nonce and Authentication Token for CA" + # TODO activate SM return 0x9000, nPA_SE.__pack_general_authenticate([[0x81,