Loading ePassport/ttcn/ePassport_Functions.ttcn +14 −7 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ * @desc Derive key seed from MRZ information fields (document number, date of birth and date of expiry) * @param p_mrz MRZ * @param p_kSeed Calculated Kenc * @see PKI for Machine Readable Travel Documents offering ICC Read-Only Access - Annex F Worked Exemples */ external function fx_deriveKeySeedFromMRZ( in octetstring p_mrz, out octetstring p_kSeed); Loading @@ -35,6 +36,7 @@ * @param p_kSeed Key seed * @param p_kEnc Calculated Kenc * @param p_kMac Calculated Kmac * @see PKI for Machine Readable Travel Documents offering ICC Read-Only Access - Annex E Basic Access Control and Secure Messaging */ external function fx_deriveBasicAccessKeysFromKeySeed( in octetstring p_kSeed, out octetstring p_kEnc, out octetstring p_kMac); Loading Loading @@ -90,6 +92,13 @@ */ external function fx_random( ) return integer; /** * @desc Generate a pseudo-random vector as described in RFC2246 * @param p_stringSize Sieze of the random vector * @return A random vector */ external function fx_randomOctetstring( integer p_stringSize ) return octetstring; /** * @desc Compute a cryptographic checksum using ISO/IEC 9797-1 MAC algorithm 3 * with block cipher DES, zero IV (8 bytes) and ISO9797-1 padding method 2. Loading @@ -113,11 +122,12 @@ /** * @desc Load in memory cache the specified passport file system * @param p_rootDirectory Root directory to access to CFG.DFLT.PLAIN directories * @param p_configurationID Configuration identifier (e.g. "CFG.DFLT.PLAIN" means that ePasport files are located in <EPASSPORT_DATA>/CFG/DFLT/PLAIN> * @remark This method SHALL be call before any call to ReadElementFile method * @return Error code */ external function fx_loadPassportConfiguration(in charstring p_configurationID) return charstring; external function fx_loadPassportConfiguration(in charstring p_rootDirectory, in charstring p_configurationID) return charstring; /** * @desc Read the specified amount of bytes from the specified offset Loading Loading @@ -153,10 +163,7 @@ group securityFunctions { function f_generateRandomOctetstring(integer p_stringSize) return octetstring { // FIXME: use an xf to generate a true random nonce return c_rndIcc; return fx_randomOctetstring(p_stringSize); } // end f_generateRandomOctetstring function f_extractKseedFromMrz(in octetstring p_mrz) return octetstring { Loading Loading @@ -254,7 +261,7 @@ // TODO: if() // b) Decrypt the cryptogram E_IFD. v_s := f_decrypt(vc_simu.kEnc, v_encryptedIfd); v_s := f_decrypt(f_build3DesKey(vc_simu.kEnc), v_encryptedIfd); // c) Extract RND.ICC from S and check if IFD returned the correct value. v_rndIfd := substr(v_s, 0, c_bacNonceSize); Loading Loading @@ -344,7 +351,7 @@ function f_loadPassportConfiguration(in charstring p_configurationID) return charstring { return fx_loadPassportConfiguration(p_configurationID); return fx_loadPassportConfiguration(PXT_EPASSPORT_DATA_ROOT, p_configurationID); } // end f_loadPassportConfiguration Loading ePassport/ttcn/ePassport_Testcases.ttcn +35 −15 Original line number Diff line number Diff line Loading @@ -432,25 +432,45 @@ module ePassport_Testcases { group debug { testcase TC_Fake_For_Test() runs on MRTD system MRTD_System { var octetstring v_rndV1 := null; var octetstring v_rndV2 := null; template octetstring mw_kEnc := 'AB94FDECF2674FDFB9B391F85D7F76F2'O; template octetstring mw_kMac := '7962D9ECE03D1ACD4C76089DCE131543'O; t_guard.start; f_cfUp(); //f_cfUp(); f_initializeMRTD("CFG.DFLT.PLAIN"); //f_initializeIS(); for (var integer i := 0; i < 15; i := i +1) { log ("Random #" & int2str(i) & " = " & int2str(fx_random())); } t_wait.start; alt { [] a_standardInspectionProcedure(); [] t_wait.timeout { log("**** TC_Fake_For_Test: Timeout: Expected message not received ****"); setverdict(inconc); log (vc_simu.kEnc); if (match(vc_simu.kEnc, mw_kEnc) == false) { setverdict(fail); stop; } log (vc_simu.kMac); if (match(vc_simu.kMac, mw_kMac) == false) { setverdict(fail); stop; } v_rndV1 := f_generateRandomOctetstring(8); log (v_rndV1); v_rndV2 := f_generateRandomOctetstring(8); log (v_rndV1); setverdict(pass); // t_wait.start; // alt { // [] a_standardInspectionProcedure(); // [] t_wait.timeout { // log("**** TC_Fake_For_Test: Timeout: Expected message not received ****"); // setverdict(inconc); // } // } t_guard.stop; } Loading Loading @@ -479,7 +499,7 @@ module ePassport_Testcases { v_computedMacIcc := f_cryptographicChecksum(vc_simu.kMac, v_encryptedIcc); // b) Decrypt the cryptogram E_IFD. v_s := f_decrypt(vc_simu.kEnc, v_encryptedIfd); v_s := f_decrypt(f_build3DesKey(vc_simu.kEnc), v_encryptedIfd); // c) Extract RND.ICC from S and check if IFD returned the correct value. v_rndIfd := substr(v_s, 0, c_bacNonceSize); Loading Loading
ePassport/ttcn/ePassport_Functions.ttcn +14 −7 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ * @desc Derive key seed from MRZ information fields (document number, date of birth and date of expiry) * @param p_mrz MRZ * @param p_kSeed Calculated Kenc * @see PKI for Machine Readable Travel Documents offering ICC Read-Only Access - Annex F Worked Exemples */ external function fx_deriveKeySeedFromMRZ( in octetstring p_mrz, out octetstring p_kSeed); Loading @@ -35,6 +36,7 @@ * @param p_kSeed Key seed * @param p_kEnc Calculated Kenc * @param p_kMac Calculated Kmac * @see PKI for Machine Readable Travel Documents offering ICC Read-Only Access - Annex E Basic Access Control and Secure Messaging */ external function fx_deriveBasicAccessKeysFromKeySeed( in octetstring p_kSeed, out octetstring p_kEnc, out octetstring p_kMac); Loading Loading @@ -90,6 +92,13 @@ */ external function fx_random( ) return integer; /** * @desc Generate a pseudo-random vector as described in RFC2246 * @param p_stringSize Sieze of the random vector * @return A random vector */ external function fx_randomOctetstring( integer p_stringSize ) return octetstring; /** * @desc Compute a cryptographic checksum using ISO/IEC 9797-1 MAC algorithm 3 * with block cipher DES, zero IV (8 bytes) and ISO9797-1 padding method 2. Loading @@ -113,11 +122,12 @@ /** * @desc Load in memory cache the specified passport file system * @param p_rootDirectory Root directory to access to CFG.DFLT.PLAIN directories * @param p_configurationID Configuration identifier (e.g. "CFG.DFLT.PLAIN" means that ePasport files are located in <EPASSPORT_DATA>/CFG/DFLT/PLAIN> * @remark This method SHALL be call before any call to ReadElementFile method * @return Error code */ external function fx_loadPassportConfiguration(in charstring p_configurationID) return charstring; external function fx_loadPassportConfiguration(in charstring p_rootDirectory, in charstring p_configurationID) return charstring; /** * @desc Read the specified amount of bytes from the specified offset Loading Loading @@ -153,10 +163,7 @@ group securityFunctions { function f_generateRandomOctetstring(integer p_stringSize) return octetstring { // FIXME: use an xf to generate a true random nonce return c_rndIcc; return fx_randomOctetstring(p_stringSize); } // end f_generateRandomOctetstring function f_extractKseedFromMrz(in octetstring p_mrz) return octetstring { Loading Loading @@ -254,7 +261,7 @@ // TODO: if() // b) Decrypt the cryptogram E_IFD. v_s := f_decrypt(vc_simu.kEnc, v_encryptedIfd); v_s := f_decrypt(f_build3DesKey(vc_simu.kEnc), v_encryptedIfd); // c) Extract RND.ICC from S and check if IFD returned the correct value. v_rndIfd := substr(v_s, 0, c_bacNonceSize); Loading Loading @@ -344,7 +351,7 @@ function f_loadPassportConfiguration(in charstring p_configurationID) return charstring { return fx_loadPassportConfiguration(p_configurationID); return fx_loadPassportConfiguration(PXT_EPASSPORT_DATA_ROOT, p_configurationID); } // end f_loadPassportConfiguration Loading
ePassport/ttcn/ePassport_Testcases.ttcn +35 −15 Original line number Diff line number Diff line Loading @@ -432,25 +432,45 @@ module ePassport_Testcases { group debug { testcase TC_Fake_For_Test() runs on MRTD system MRTD_System { var octetstring v_rndV1 := null; var octetstring v_rndV2 := null; template octetstring mw_kEnc := 'AB94FDECF2674FDFB9B391F85D7F76F2'O; template octetstring mw_kMac := '7962D9ECE03D1ACD4C76089DCE131543'O; t_guard.start; f_cfUp(); //f_cfUp(); f_initializeMRTD("CFG.DFLT.PLAIN"); //f_initializeIS(); for (var integer i := 0; i < 15; i := i +1) { log ("Random #" & int2str(i) & " = " & int2str(fx_random())); } t_wait.start; alt { [] a_standardInspectionProcedure(); [] t_wait.timeout { log("**** TC_Fake_For_Test: Timeout: Expected message not received ****"); setverdict(inconc); log (vc_simu.kEnc); if (match(vc_simu.kEnc, mw_kEnc) == false) { setverdict(fail); stop; } log (vc_simu.kMac); if (match(vc_simu.kMac, mw_kMac) == false) { setverdict(fail); stop; } v_rndV1 := f_generateRandomOctetstring(8); log (v_rndV1); v_rndV2 := f_generateRandomOctetstring(8); log (v_rndV1); setverdict(pass); // t_wait.start; // alt { // [] a_standardInspectionProcedure(); // [] t_wait.timeout { // log("**** TC_Fake_For_Test: Timeout: Expected message not received ****"); // setverdict(inconc); // } // } t_guard.stop; } Loading Loading @@ -479,7 +499,7 @@ module ePassport_Testcases { v_computedMacIcc := f_cryptographicChecksum(vc_simu.kMac, v_encryptedIcc); // b) Decrypt the cryptogram E_IFD. v_s := f_decrypt(vc_simu.kEnc, v_encryptedIfd); v_s := f_decrypt(f_build3DesKey(vc_simu.kEnc), v_encryptedIfd); // c) Extract RND.ICC from S and check if IFD returned the correct value. v_rndIfd := substr(v_s, 0, c_bacNonceSize); Loading