Commit 8fa5e0d9 authored by garciay's avatar garciay
Browse files

STF525: Add encryption support in Test System

STF545: Start TestSystem support
parent eba7a6ba
Loading
Loading
Loading
Loading
+47 −0
Original line number Original line Diff line number Diff line
/**
 *    @author     ETSI / STF545
 *    @version     $URL$
 *                $Id$
 *    @desc        Test System module for ITS PKI
 *    @copyright   ETSI Copyright Notification
 *                 No part may be reproduced except as authorized by written permission.
 *                 The copyright and the foregoing restriction extend to reproduction in all media.
 *                 All rights reserved.
 *
 */
module LibItsPki_TestSystem {
    
    // LibItsCommon
    import from LibItsCommon_TestSystem all;
    
    // LibIts
    import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
    import from IEEE1609dot2 language "ASN.1:1997" all;
    import from EtsiTs103097Module language "ASN.1:1997" all;
    import from EtsiTs102941Its_sMessages language "ASN.1:1997" all;
    import from EtsiTs102941OfflineDataStructures language "ASN.1:1997" all;
    
    // LibItsPki
    
    type port PkiPort message {
        in PkiInd;
        out PkiReq;
    } // End of port PkiPort
    
    type component ItsPkiSystem {
        port PkiPort pkiPort;
    } // End of component ItsPkiSystem
    
    type component ItsPki extends ItsBaseComponent {
        port PkiPort pkiPort;
    } // End of component ItsPki
    
    type record PkiReq {
        
    } // End of type PkiReq
    
    type record PkiInd {
        
    } // End of type PkiInd
    
} // End of module LibItsPki_TestSystem 
+13 −6
Original line number Original line Diff line number Diff line
@@ -110,7 +110,7 @@ module LibItsSecurity_Functions {
                           in EtsiTs103097Data    p_encrypedSecuredMessage,
                           in EtsiTs103097Data    p_encrypedSecuredMessage,
                           out EtsiTs103097Data   p_decrypedSecuredMessage
                           out EtsiTs103097Data   p_decrypedSecuredMessage
        ) return boolean {
        ) return boolean {
            if (not(ischosen(p_encrypedSecuredMessage.content.encryptedData))) {
            if (ischosen(p_encrypedSecuredMessage.content.encryptedData)) {
                var PKRecipientInfo v_pKRecipientInfo;
                var PKRecipientInfo v_pKRecipientInfo;
                var RecipientInfo v_recipientInfo := p_encrypedSecuredMessage.content.encryptedData.recipients[0];
                var RecipientInfo v_recipientInfo := p_encrypedSecuredMessage.content.encryptedData.recipients[0];
                
                
@@ -127,6 +127,7 @@ module LibItsSecurity_Functions {
                v_pKRecipientInfo := p_encrypedSecuredMessage.content.encryptedData.recipients[0].signedDataRecipInfo;
                v_pKRecipientInfo := p_encrypedSecuredMessage.content.encryptedData.recipients[0].signedDataRecipInfo;
                  // Read the certificate based on the recipientId
                  // Read the certificate based on the recipientId
                } else {
                } else {
                  log("*** " & testcasename() & ":ERROR: Unsupported RecipientInfo variant ***");
                  return false;
                  return false;
                }
                }
                
                
@@ -146,6 +147,8 @@ module LibItsSecurity_Functions {
                    var bitstring v_decode := oct2bit(v_decryptedSecuredMessage);
                    var bitstring v_decode := oct2bit(v_decryptedSecuredMessage);
                    if (decvalue(v_decode, p_decrypedSecuredMessage) == 0) {
                    if (decvalue(v_decode, p_decrypedSecuredMessage) == 0) {
                      return true;
                      return true;
                    } else {
                      log("*** " & testcasename() & ":ERROR: Faild to decode secured message ***");
                    }
                    }
                  }
                  }
                } else if (ischosen(v_pKRecipientInfo.encKey.eciesBrainpoolP256r1)) {
                } else if (ischosen(v_pKRecipientInfo.encKey.eciesBrainpoolP256r1)) {
@@ -164,9 +167,13 @@ module LibItsSecurity_Functions {
                    var bitstring v_decode := oct2bit(v_decryptedSecuredMessage);
                    var bitstring v_decode := oct2bit(v_decryptedSecuredMessage);
                    if (decvalue(v_decode, p_decrypedSecuredMessage) == 0) {
                    if (decvalue(v_decode, p_decrypedSecuredMessage) == 0) {
                      return true;
                      return true;
                    } else {
                      log("*** " & testcasename() & ":ERROR: Faild to decode secured message ***");
                    }
                    }
                  }
                  }
                }
                }
            } else {
              log("*** " & testcasename() & ":ERROR: Message not encrypted ***");
            }
            }
            
            
            return false;
            return false;