Commit 919a3f42 authored by garciay's avatar garciay
Browse files

Add support of AcSecPrimitive for CAM & DENM

parent b8fe1ca2
Loading
Loading
Loading
Loading
+66 −4
Original line number Original line Diff line number Diff line
@@ -42,6 +42,7 @@ module LibItsPki_Functions {
  
  
  // LibItsHttp
  // LibItsHttp
  import from LibItsHttp_TypesAndValues all;
  import from LibItsHttp_TypesAndValues all;
  import from LibItsHttp_Templates all;
  import from LibItsHttp_TestSystem all;
  import from LibItsHttp_TestSystem all;
  
  
  // LibItsPki
  // LibItsPki
@@ -71,6 +72,8 @@ module LibItsPki_Functions {
      
      
      f_prepareCertificates(p_certificateId, vc_aaCertificate, vc_atCertificate);
      f_prepareCertificates(p_certificateId, vc_aaCertificate, vc_atCertificate);
      f_readCertificate(p_certificateId, vc_eaCertificate);
      f_readCertificate(p_certificateId, vc_eaCertificate);
      
      activate(a_default_pki());
    } // End of function f_cfUp
    } // End of function f_cfUp
    
    
    /**
    /**
@@ -96,8 +99,21 @@ module LibItsPki_Functions {
      f_readEncryptingKey(p_certificateId, vc_eaPrivateEncKey);
      f_readEncryptingKey(p_certificateId, vc_eaPrivateEncKey);
      f_getCertificateDigest(p_certificateId, vc_eaHashedId8);
      f_getCertificateDigest(p_certificateId, vc_eaHashedId8);
      f_getCertificateHash(p_peerCertificateId, vc_eaPeerWholeHash);
      f_getCertificateHash(p_peerCertificateId, vc_eaPeerWholeHash);
      
      activate(a_default_pki_http());
    } // End of function f_cfHttpUp
    } // End of function f_cfHttpUp
    
    
    function f_cfUp_itss(
                         in charstring p_certificateId := "CERT_TS_A_EA" // TODO Use a constant
                         ) runs on ItsPkiItss /* TITAN TODO: system ItsPkiItssSystem */ {
      
      f_cfUp();
      
      map(self:geoNetworkingPort, system:geoNetworkingPort);
      
      activate(a_default_pki());
    } // End of function f_cfUp_itss
    
    /**
    /**
     * @desc    Deletes default configuration 
     * @desc    Deletes default configuration 
     */
     */
@@ -115,6 +131,15 @@ module LibItsPki_Functions {
      f_disconnect4SelfOrClientSync();
      f_disconnect4SelfOrClientSync();
    } // End of function f_cfHttpDown
    } // End of function f_cfHttpDown
    
    
    /**
     * @desc    Deletes default configuration 
     */
    function f_cfDown_itss() runs on ItsPkiItss /* TITAN TODO: system ItsPkiItssSystem */ {
      unmap(self:geoNetworkingPort, system:geoNetworkingPort);
      
      f_cfDown();
    } // End of function f_cfDown
    
    /**
    /**
     * @desc Initialise secure mode if required
     * @desc Initialise secure mode if required
     */
     */
@@ -446,7 +471,7 @@ module LibItsPki_Functions {
                                  in octetstring p_issuer,
                                  in octetstring p_issuer,
                                  in Certificate p_peer_certificate,
                                  in Certificate p_peer_certificate,
                                  in Ieee1609Dot2Data p_ieee1609dot2_encrypted_and_signed_data,
                                  in Ieee1609Dot2Data p_ieee1609dot2_encrypted_and_signed_data,
                                  in boolean p_check_signature := true,
                                  in boolean p_check_security := true,
                                  out EtsiTs102941Data p_etsi_ts_102941_data
                                  out EtsiTs102941Data p_etsi_ts_102941_data
                                  ) return boolean {
                                  ) return boolean {
      // Local variables
      // Local variables
@@ -456,7 +481,7 @@ module LibItsPki_Functions {
      var boolean v_ret;
      var boolean v_ret;
      
      
      // 1. Decrypt the data
      // 1. Decrypt the data
      if (f_decrypt(v_private_enc_key, p_ieee1609dot2_encrypted_and_signed_data, v_ieee1609dot2_signed_data) == false) {
      if ((p_check_security == true) and (f_decrypt(v_private_enc_key, p_ieee1609dot2_encrypted_and_signed_data, v_ieee1609dot2_signed_data) == false)) {
        return false;
        return false;
      }
      }
      log("v_ieee1609dot2_signed_data= ", v_ieee1609dot2_signed_data);
      log("v_ieee1609dot2_signed_data= ", v_ieee1609dot2_signed_data);
@@ -478,7 +503,7 @@ module LibItsPki_Functions {
                                                     p_peer_certificate.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.compressed_y_1,
                                                     p_peer_certificate.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.compressed_y_1,
                                                     1);
                                                     1);
      }
      }
      if ((v_ret == false) and (p_check_signature == true)) {
      if ((v_ret == false) and (p_check_security == true)) {
        return false;
        return false;
      }
      }


@@ -488,7 +513,7 @@ module LibItsPki_Functions {
        return false;
        return false;
      }
      }


      if (p_etsi_ts_102941_data.version != PkiProtocolVersion) {
      if ((p_check_security == true) and (p_etsi_ts_102941_data.version != PkiProtocolVersion)) {
        return false;
        return false;
      }
      }
      
      
@@ -497,4 +522,41 @@ module LibItsPki_Functions {


  } // End of group inner_ec_xxx
  } // End of group inner_ec_xxx
  
  
  group altstes {
    
    altstep a_default_pki() runs on ItsPki {
      [] pkiPort.receive {
        tc_ac.stop;
        log("*** a_default: ERROR: Unexpected PKI message received ***");
        f_selfOrClientSyncAndVerdict("error", e_error);
      }
    }
    
    altstep a_default_pki_http() runs on ItsPkiHttp {
      [] httpPort.receive( 
                          mw_http_response(
                                           mw_http_response_ko
                                           )) {
        tc_ac.stop;
        log("*** a_default: ERROR: HTTP Server error ***");
        f_selfOrClientSyncAndVerdict("error", e_error);
      }
      [] httpPort.receive(mw_http_request) {
        tc_ac.stop;
        log("*** a_default: ERROR: Unexpected HTTP Request received ***");
        f_selfOrClientSyncAndVerdict("error", e_error);
      }
      [] httpPort.receive(mw_http_response) {
        tc_ac.stop;
        log("*** a_default: ERROR: Unexpected HTTP Response received ***");
        f_selfOrClientSyncAndVerdict("error", e_error);
      }
      [] httpPort.receive {
        tc_ac.stop;
        log("*** a_default: ERROR: Unexpected HTTP message received ***");
        f_selfOrClientSyncAndVerdict("error", e_error);
      }
    }
  }
  
} // End of module LibItsPki_Functions 
} // End of module LibItsPki_Functions 
+4 −4
Original line number Original line Diff line number Diff line
@@ -60,7 +60,8 @@ module LibItsPki_TestSystem {
  type component ItsPkiHttpSystem extends HttpTestAdapter{
  type component ItsPkiHttpSystem extends HttpTestAdapter{
  } // End of component ItsPkiHttpSystem
  } // End of component ItsPkiHttpSystem
  
  
  type component ItsPkiItssSystem extends ItsPkiSystem, ItsGeoNetworking {
  type component ItsPkiItssSystem extends ItsPkiSystem {
    port GeoNetworkingPort geoNetworkingPort;
  } // End of component ItsPkiItssSystem
  } // End of component ItsPkiItssSystem
  
  
  type component ItsPki extends ItsSecurityBaseComponent, ItsBaseMtc {
  type component ItsPki extends ItsSecurityBaseComponent, ItsBaseMtc {
@@ -78,9 +79,8 @@ module LibItsPki_TestSystem {
    var octetstring vc_eaPeerWholeHash;     /** IUT EA whole-hash for signature check */
    var octetstring vc_eaPeerWholeHash;     /** IUT EA whole-hash for signature check */
  } // End of component ItsPki
  } // End of component ItsPki
  
  
  type component ItsPkiItss extends ItsGeoNetworking {
  type component ItsPkiItss extends ItsPki {
    port AdapterControlPkiPort acPkiPort;
    port GeoNetworkingPort geoNetworkingPort;
    port PkiPort pkiPort;
  } // End of component ItsPkiItss
  } // End of component ItsPkiItss
  
  
} // End of module LibItsPki_TestSystem 
} // End of module LibItsPki_TestSystem