Commit 74dc7e50 authored by berge's avatar berge
Browse files

Added structure for handling certificate chains

parent 58d98641
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -149,9 +149,14 @@
				v_dstCAR := v_mseCommand.payload
    						.manageSecurityEnvironmentData.crtDST
    						.crtReferenceOfSecretOrPublicKey.tlvValue;
				// TODO: check CAR exists
				
				if(f_isTrustedCertificate(oct2char(v_dstCAR))) {
					f_setDst(oct2char(v_dstCAR));
					mrtdport.send(m_responseOK);
				}
				else {
					mrtdport.send(m_responseNOK(c_w1w2ReferencedDataOrReferenceDataNotFound));	
				}
				
				repeat;					
			}

@@ -164,8 +169,9 @@
					
				// the correct Certificate must be passed as parameter in the external function
				// in order to verify IS and DV and link CAVA certificates.
				v_certificate := f_getCertificate(v_psoCommand.payload.genericData.data); // FIXME 
				v_signature := f_getSignature(v_psoCommand.payload.genericData.data); // FIXME 
				// FIXME 
				v_certificate := f_getCertificate(v_psoCommand.payload.genericData.data);  
				v_signature := f_getSignature(v_psoCommand.payload.genericData.data);  
				if (f_verifySignature(v_signature, v_dstCAR)) {
					//TODO store certificate and CAR						
		 			mrtdport.send(m_responseOK);
@@ -278,7 +284,7 @@
        		vc_simu.currentFiles[v_logicalChannel] := getFileByShortId(p_file.shortFileId);
        					
    			v_offset := v_readCommand.params.fileIdAndOffset.offset;
    			v_dataLength := v_readCommand.payload.readBinaryData.lengthE;
    			v_dataLength := v_readCommand.lengthE;
      		
        		v_result := f_readFileData(vc_simu.currentFiles[v_logicalChannel], 
        			v_offset, v_dataLength, v_data);
@@ -346,7 +352,7 @@
        		vc_simu.currentFiles[v_logicalChannel] :=  getFileByShortId(v_shortFileId);
        		       					
    			v_offset := v_readCommand.params.fileIdAndOffset.offset;
    			v_dataLength := v_readCommand.payload.readBinaryData.lengthE;
    			v_dataLength := v_readCommand.lengthE;
      		
        		v_result := f_readFileData(vc_simu.currentFiles[v_logicalChannel], 
        			v_offset, v_dataLength, v_data);
+33 −0
Original line number Diff line number Diff line
@@ -499,6 +499,39 @@
		return ''O;					
	} // end f_getCertificate

	group simuParamsFunctions {
		
		function f_isTrustedCertificate(in Chr p_chr) runs on MRTD return boolean {
			var integer i;
			
			if(not ispresent(vc_simu.trustedCertificates)) {
				return false;
			}
			
			for(i:=0; i<sizeof(vc_simu.trustedCertificates); i:=i+1) {
				if(p_chr ==  vc_simu.trustedCertificates[i]) {
					return true;
				}
			} // end f_isTrustedCertificate
			
			return false;			
		}
		
		function f_setDst(in Chr p_chr) runs on MRTD {
			vc_simu.dst := p_chr;	
		}
		
		function f_getDst() runs on MRTD return Chr {
			if(ispresent(vc_simu.dst)) {
				return vc_simu.dst;	
			}
			else {
				return null;
			}
		}
		
	} // end simuParamsFunctions

} // end ePassport_Functions

 
+3 −3
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ module ePassport_Templates {
			payload := {
				readBinaryData := ?
			},
			lengthE := *
			lengthE := ?
        }
         
        template CommandReadBinary mw_readAnyShortEF := {
@@ -219,7 +219,7 @@ module ePassport_Templates {
			payload := {
				readBinaryData := ?
			},
			lengthE := *
			lengthE := ?
        }
        
        template CommandReadBinary mw_readCurrentEF := {
@@ -249,7 +249,7 @@ module ePassport_Templates {
			payload := {
				getChallengeData := ?
			},
			lengthE := *	
			lengthE := ?	
        }

		template CommandExternalOrMutualAuthenticate mw_extAuthenticate := {
+6 −5
Original line number Diff line number Diff line
@@ -53,12 +53,13 @@ module ePassport_TestSystem {
		FileSet currentFiles,
		octetstring kEnc,
		octetstring kMac,
		octetstring dhPrivateKey optional, // DH Private Key - Chip Authentication
		octetstring aaPrivateKey optional, // KPrAA - Active Authentication
		ChrList trustedCAs optional, // list of trusted CAs - derived from EF.CVCA
		ChrList	trustedCertificates optional, // list of trusted certificates
		
		// DH Private Key - Chip Authentication
		octetstring dhPrivateKey,
	
		// KPrAA - Active Authentication
		octetstring aaPrivateKey
		// Security Environment
		Chr	dst optional	
	}
/*
	type component TestAdapter {
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ module ePassport_Values {
		const W1W2Status c_w1w2NormalProcessing := '9000'O;
		const W1W2Status c_w1w2SecurityStatusNotSatisfied := '6982'O;
		const W1W2Status c_w1w2NoCurrentEF := '6986'O;
		const W1W2Status c_w1w2ReferencedDataOrReferenceDataNotFound :='6A88'O;
			
	} // end w1w2Constants