Commit eca30c6e authored by berge's avatar berge
Browse files

Misc cleanup

parent 1cf8f62f
Loading
Loading
Loading
Loading
+7 −17
Original line number Diff line number Diff line
@@ -357,11 +357,6 @@
						.externalOrMutualAuthenticateData.challengeResponse;					
				v_cleartextChallenge := vc_simu.documentNumber & vc_simu.challenge & vc_simu.isDhPublicKeyHash;
	 		
				log("documentNumber", vc_simu.documentNumber);
				log("challenge", vc_simu.challenge);
				log("isDhPublicKeyHash", vc_simu.isDhPublicKeyHash);
				log("v_cleartextChallenge", v_cleartextChallenge);
				 		
				if(f_verifySignature(v_cleartextChallenge, v_signature, f_getAtPublickey())) {
					f_pushPassResult(e_aisTerminalAuthentication);
					vc_simu.securityStatus := e_terminalAuthenticated;
@@ -441,8 +436,6 @@
    			v_logicalChannel := f_getLogicalChannel(v_readCommand.class);
    			if(vc_simu.currentFiles[v_logicalChannel] == c_noFileInfo) {
    				//TODO
    				log("vc_simu.currentFiles[v_logicalChannel]: ", vc_simu.currentFiles[v_logicalChannel]);
    				log("c_noFileInfo", c_noFileInfo); 
    				mrtdport.send(m_responseNOK(c_w1w2NoCurrentEF));
    				t_ac.start;
    				repeat;
@@ -451,8 +444,7 @@
    			v_offset := v_readCommand.params.longOffset.offset;
    			v_dataLength := v_readCommand.lengthE;
    			
    			v_result := f_readFileData(vc_simu.currentFiles[v_logicalChannel],
    			 	v_offset, v_dataLength, v_data);
    			v_result := f_readFileData(vc_simu.currentFiles[v_logicalChannel], v_offset, v_dataLength, v_data);
        		mrtdport.send(m_responseReadWithStatus(v_data, v_result));
    			t_ac.start; 
    			repeat;			
@@ -477,13 +469,12 @@
    			// set current file for logical channel
        		v_logicalChannel := f_getLogicalChannel(v_readCommand.class);
        		vc_simu.currentFiles[v_logicalChannel] := getFileByShortId(p_file.shortFileId);
        		log("vc_simu.currentFiles[v_logicalChannel] ", vc_simu.currentFiles[v_logicalChannel]);
        		log("**** Reading file: ", vc_simu.currentFiles[v_logicalChannel], " ****");
        					
    			v_offset := v_readCommand.params.fileIdAndOffset.offset;
    			v_dataLength := v_readCommand.lengthE;
      		
        		v_result := f_readFileData(vc_simu.currentFiles[v_logicalChannel], 
        			v_offset, v_dataLength, v_data);
        		v_result := f_readFileData(vc_simu.currentFiles[v_logicalChannel], v_offset, v_dataLength, v_data);
        		if(v_data == ''O ) {
        		    mrtdport.send(m_responseNOK(v_result));
        		}
@@ -519,8 +510,6 @@
    			v_logicalChannel := f_getLogicalChannel(v_readCommand.class);
    			if(match(vc_simu.currentFiles[v_logicalChannel], c_noFileInfo)) {
    			    //TODO
    				log("vc_simu.currentFiles[v_logicalChannel]: ", vc_simu.currentFiles[v_logicalChannel]);
    				log("c_noFileInfo", c_noFileInfo); 
    				mrtdport.send(m_responseNOK(c_w1w2NoCurrentEF));
    				t_ac.start;
    				repeat;
@@ -556,12 +545,13 @@
        		v_logicalChannel := f_getLogicalChannel(v_readCommand.class);
				v_shortFileId := bit2oct(v_readCommand.params.fileIdAndOffset.fileId);				
        		vc_simu.currentFiles[v_logicalChannel] :=  getFileByShortId(v_shortFileId);
        		log("vc_simu.currentFiles[v_logicalChannel] ", vc_simu.currentFiles[v_logicalChannel]);
        		log("**** Reading file: ", vc_simu.currentFiles[v_logicalChannel], " ****");
        		       					
    			v_offset := v_readCommand.params.fileIdAndOffset.offset;
    			v_dataLength := v_readCommand.lengthE;
      		
        		v_result := f_readFileData(vc_simu.currentFiles[v_logicalChannel], v_offset, v_dataLength, v_data);
        		
        		if(v_data == ''O ) {
        		    mrtdport.send(m_responseNOK(v_result));
        		}
+18 −38
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
	//LibCommon
	import from LibCommon_DataStrings all;
	import from LibCommon_TextStrings all;	
	import from LibCommon_Time all;

	//Ats
	import from ePassport_TestSystem all;
@@ -292,12 +293,6 @@
    	
    	function f_verifySignature(in octetstring p_message, in octetstring p_signature, in octetstring p_publicKey) 
    	return boolean {
    	    
    	    log("p_message: ", p_message);
    	    log("p_signature: ", p_signature);
    	    log("p_publicKey: ", p_publicKey);
    	    
    		//return true;
    		return fx_verifySignature(p_message, p_signature, p_publicKey);
    	} // end f_verifySignature
    	
@@ -380,11 +375,8 @@
        	var octetstring v_ssc;
    		
	        v_encryptedIfdLength := lengthof(p_challengeResponse) - c_bacMacSize;
	        log("v_encryptedIfdLength: ", v_encryptedIfdLength);
			v_encryptedIfd := substr(p_challengeResponse, 0, v_encryptedIfdLength);
			log("v_encryptedIfd: ", v_encryptedIfd);
    		v_macIfd := substr(p_challengeResponse, v_encryptedIfdLength, c_bacMacSize);
    		log("v_macIfd: ", v_macIfd);
			
			// a) Check the checksum M_IFD of the cryptogram E_IFD.
			v_computedMacIfd := f_cryptographicChecksum(vc_simu.kMac, v_encryptedIfd);
@@ -396,15 +388,11 @@
			
    		// b) Decrypt the cryptogram E_IFD.
			v_s := f_decrypt3Des(f_build3DesKey(vc_simu.kEnc), v_encryptedIfd);	
			log("v_s: ", v_s);
			
    		// c) Extract RND.ICC from S and check if IFD returned the correct value.
    		v_rndIfd := substr(v_s, 0, c_bacNonceSize);
    		log("v_rndIfd: ", v_rndIfd);
    		v_receivedRndIcc := substr(v_s, c_bacNonceSize, c_bacNonceSize); 
    		log("v_receivedRndIcc: ", v_receivedRndIcc);
    		v_keyIfd := substr(v_s, 2*c_bacNonceSize, c_bacKeySize); 
    		log("v_keyIfd: ", v_keyIfd);
    		if(not match(v_receivedRndIcc, p_rndIcc)) {
    			//TODO
    			return ''O;
@@ -412,34 +400,25 @@
    		
    		// d) Generate keying material K.ICC.
    		v_keyIcc := f_generateRandomOctetstring(c_bacKeySize);
    		log("v_keyIcc: ", v_keyIcc);
    		
    		// e) Generate the concatenation R = RND.ICC || RND.IFD || K.ICC
    		v_r := p_rndIcc & v_rndIfd & v_keyIcc;
    		log("v_r: ", v_r);
    		
    		// f) Compute the cryptogram E_ICC = E[K_ENC](R).
    		v_encryptedIcc := f_encrypt3Des(f_build3DesKey(vc_simu.kEnc), v_r);
    		log("v_encryptedIcc: ", v_encryptedIcc);
    		
    		// g) Compute the checksum M_ICC = MAC[K_MAC](E_ICC).
    		v_macIcc := f_cryptographicChecksum(vc_simu.kMac, v_encryptedIcc);
    		log("v_macIcc: ", v_macIcc);
    		
    		// h) Send the response using the data E_ICC || M_ICC.
    		v_respData :=  v_encryptedIcc & v_macIcc;
    		log("v_respData: ", v_respData);
    		
 			// i) compute new K.SEED and derive keys
 			v_kSeed := bit2oct(oct2bit(v_keyIfd) xor4b oct2bit(v_keyIcc));
 			log("v_kSeed: ", v_kSeed);
 			f_deriveKeys(v_kSeed, vc_simu.kEnc, vc_simu.kMac);
 			log("vc_simu.kEnc: ", vc_simu.kEnc);
 			log("vc_simu.kMac: ", vc_simu.kMac);
  			f_setKeysForSecureMessaging(vc_simu.kEnc & vc_simu.kMac);
 			
 			v_ssc := substr(p_rndIcc, 4, 4) & substr(v_rndIfd, 4, 4);
 			log("v_ssc: ", v_ssc);
 			f_setInitialSscForMessageAuthentication(v_ssc);
 			
 			return v_respData;
@@ -483,9 +462,7 @@
			//FIXME
			
			// encrypt message representative
			log("Read c_filePrAA: ", f_readFileData(c_filePrAA, 0, -1, v_aaPrivateKey));
			log("DG15.sk: ", v_aaPrivateKey);
			log("v_f: ", v_f);
			f_readFileData(c_filePrAA, 0, -1, v_aaPrivateKey);
			return f_encrypt(e_rsa, v_aaPrivateKey, v_f); //FIXME Algorithm!
	   	}
    	
@@ -499,10 +476,8 @@
			var octetstring v_dg14PrivateKey;
			
			// a) The shared secret K = KA(SKPICC;^PKPCD;DPICC) = KA(^SKPCD;PKPICC;DPICC)
			log("Read c_fileDG14: ", f_readFileData(c_fileDG14, 0, -1, v_dg14)); 
			log("DG14: ", v_dg14);
			log("Read c_filePrCA: ", f_readFileData(c_filePrCA, 0, -1, v_dg14PrivateKey));
			log("DG14.sk: ", v_dg14PrivateKey);
			f_readFileData(c_fileDG14, 0, -1, v_dg14);
			f_readFileData(c_filePrCA, 0, -1, v_dg14PrivateKey);
			v_algo := f_extractPublicKey(v_dg14, v_dummy); // Is it possible to set a function parameter optional?
			v_k := f_computeSharedSecret(v_dg14PrivateKey, v_algo, p_publicKeyPcd);
								
@@ -535,9 +510,7 @@
			in integer p_dataLength, 
			out octetstring p_data)
		return W1W2Status {

			return fx_readFileData(p_fileInfo.filename, p_offset, p_dataLength, p_data);
			
		} //end f_readFileData

		function getFileByLongId(in LongFileId p_longFileId) return FileInfo {
@@ -623,7 +596,7 @@
    
    
        //function for initializing the system and start the ePassport procedure
        function f_initializeIS() runs on MRTD {
        function f_initializeIS(in charstring p_specialOperatorMessage) runs on MRTD {
            
			var charstring v_opticalMrzLine1 := oct2char(substr(vc_simu.mrz, 0, lengthof(vc_simu.mrz)/2));            
			var charstring v_opticalMrzLine2 := oct2char(substr(vc_simu.mrz, lengthof(vc_simu.mrz)/2, lengthof(vc_simu.mrz)/2));
@@ -632,6 +605,12 @@
            f_activateProbe();
          
            if(not(PXT_AUTOMATIC_TEST_INTERFACE)) {
                if(p_specialOperatorMessage != "") {
                    action(p_specialOperatorMessage);
                    log("**** ", p_specialOperatorMessage, " ****");
        	    	f_sleepIgnoreDef(10.0);
                }
                
				action(
					"Please ensure that IS starts inspection procedure." & c_CRLF & c_CRLF
					& "Optical MRZ: " & c_CRLF
@@ -639,8 +618,8 @@
					& v_opticalMrzLine2 & c_CRLF
				);
				
				log("Optical MRZ Line 1: ", v_opticalMrzLine1);
				log("Optical MRZ Line 2: ", v_opticalMrzLine2);
				log("**** Optical MRZ Line 1: ", v_opticalMrzLine1, " ****");
				log("**** Optical MRZ Line 2: ", v_opticalMrzLine2, " ****");
			}
        	
        } // end f_initializeIS
@@ -653,6 +632,7 @@
	    	
	    	// Dectivate antenna
            f_deactivateProbe();	        
	        stop;
	        
	    } // end f_cleanUp
	    
+14 −17
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ module ePassport_Testcases {
            var template IsVerdictList vt_expectedFailResults := {};
        	var template IsVerdictList vt_expectedPassResults := {
        	    e_aisNoFailure,
        	    e_aisPassiveAuthentication,
        	    e_aisBacAuthentication,
        	    e_aisCommunication
        	};
@@ -43,7 +44,7 @@ module ePassport_Testcases {
    		// Preamble
    	   	f_cfUp();
        	f_initializeMRTD("CFG.DFLT.BAC");
        	f_initializeIS(); 
        	f_initializeIS(""); 
    	
    		// Test Body
    		t_ac.start(PXT_TWAIT);
@@ -91,7 +92,7 @@ module ePassport_Testcases {
    		// Preamble
    	   	f_cfUp();
        	f_initializeMRTD("CFG.DFLT.EAC");
        	f_initializeIS(); 
        	f_initializeIS(""); 
    	
    		// Test Body
    		t_ac.start(PXT_TWAIT);
@@ -139,7 +140,7 @@ module ePassport_Testcases {
    		// Preamble
    	   	f_cfUp();
        	f_initializeMRTD("CFG.EAC.ISO7816.E06");
        	f_initializeIS(); 
        	f_initializeIS(""); 
    	
    		// Test Body
    		t_ac.start(PXT_TWAIT);
@@ -183,7 +184,7 @@ module ePassport_Testcases {
    		// Preamble
    	   	f_cfUp();
        	f_initializeMRTD("CFG.EAC.ISO7816.E08");
        	f_initializeIS(); 
        	f_initializeIS(""); 
    	
    		// Test Body
    		t_ac.start(PXT_TWAIT);
@@ -230,7 +231,7 @@ module ePassport_Testcases {
        	// Modify Document number 
        	vc_simu.documentNumber := char2oct("M11T002JM4"); 
        	
        	f_initializeIS();
        	f_initializeIS("");
    		    	
    		// Test Body
    		t_ac.start(PXT_TWAIT);
@@ -256,7 +257,7 @@ module ePassport_Testcases {
        // Purpose: This test case verifies that the inspection system shows the correct behaviour if
        // IS certificate contains wrong signature.
        // Profile: AIP
        // Configuration file: default EAC + add a wrong certificate to the IS (IS_Cert_01)
        // Configuration file: default EAC + add a wrong certificate to the IS (IS_Cert_11)
        // Expected results: "Terminal authentication failure"
        // Interface: BAC: PASS, PA: PASS, AA: NP, TA: FAIL, CA: PASS, COM: PASS        
        testcase TC_ISO7816_E18() runs on MRTD system MRTD_System {
@@ -274,8 +275,7 @@ module ePassport_Testcases {
    		// Preamble
    	   	f_cfUp();
        	f_initializeMRTD("CFG.DFLT.EAC");        	  	
        	f_initializeIS();
        	//TODO: add a wrong certificate to the IS (IS_Cert_01);
        	f_initializeIS("WARNING: Ensure that IS uses IS_Cert_11");
    	
    		// Test Body
    		t_ac.start(PXT_TWAIT);
@@ -323,7 +323,7 @@ module ePassport_Testcases {
    		// Preamble
    	   	f_cfUp();
        	f_initializeMRTD("CFG.EAC.ISO7816.F05");
        	f_initializeIS(); 
        	f_initializeIS(""); 
    	
    		// Test Body
    		t_ac.start(PXT_TWAIT);
@@ -369,10 +369,7 @@ module ePassport_Testcases {
    		// Preamble
    	   	f_cfUp();
        	f_initializeMRTD("CFG.BAC.LDS.B25");
        	f_initializeIS(); 
    
    		//TODO: ModifyMRZ; 
        	//	was:	v_cfg.mrz:=PXT_MRZ_LDS_B25;
        	f_initializeIS("WARNING: This testcase uses a special optical MRZ"); 
    	
    		// Test Body
    		t_ac.start(PXT_TWAIT);
@@ -421,7 +418,7 @@ module ePassport_Testcases {
    		// Preamble
    	   	f_cfUp();
        	f_initializeMRTD("CFG.EAC.LDS.D12");
        	f_initializeIS(); 
        	f_initializeIS(""); 
        	
    		// Test Body
    		t_ac.start(PXT_TWAIT);
@@ -470,7 +467,7 @@ module ePassport_Testcases {
    		// Preamble
    	   	f_cfUp();
        	f_initializeMRTD("CFG.EAC.LDS.F04");
        	f_initializeIS(); 
        	f_initializeIS(""); 
        	
    		// Test Body
    		t_ac.start(PXT_TWAIT);
@@ -519,7 +516,7 @@ module ePassport_Testcases {
    		// Preamble
    	   	f_cfUp();
        	f_initializeMRTD("CFG.EAC.LDS.H37");
        	f_initializeIS(); 
        	f_initializeIS(""); 
        	
    		// Test Body
    		t_ac.start(PXT_TWAIT);