LibItsSecurity_Templates.ttcn3 56.5 KB
Newer Older
garciay's avatar
garciay committed
/**
 *  @author   ETSI / STF481
 *  @version  $URL$
 *            $Id$
 *  @desc     Module containing templates for Security Protocol
 *
 */
module LibItsSecurity_Templates {
    
    // LibCommon
    import from LibCommon_BasicTypesAndValues {
        type 
garciay's avatar
garciay committed
            UInt8, UInt16,  
garciay's avatar
garciay committed
            Int32        
    }
    import from LibCommon_DataStrings {
        type 
            Oct2        
    // LibIts
    import from CAM_PDU_Descriptions language "ASN.1:1997" {
        type CAM
    }
    import from DENM_PDU_Descriptions language "ASN.1:1997" {
        type DENM
    }
        
garciay's avatar
garciay committed
    // LibItsSecurity
    import from LibItsSecurity_TypesAndValues all;
    import from LibItsSecurity_Pixits all;
garciay's avatar
garciay committed
    import from LibItsSecurity_TestSystem {
garciay's avatar
garciay committed
        type
garciay's avatar
garciay committed
            GnSecurityReq, GnSecurityInd
garciay's avatar
garciay committed
    }
garciay's avatar
garciay committed
    
    template (value) GnSecurityReq m_gnSecurityReq(
                                                   in template (value) SecuredMessage p_msgReq
    ) := {
        msgReq := p_msgReq
    } // End of template m_gnSecurityReq
    
    template (present) GnSecurityInd mw_gnSecurityInd(
                                                      in template (present) SecuredMessage p_msgInd
    ) := {
        msgInd := p_msgInd
    } // End of template mw_gnSecurityIng
garciay's avatar
garciay committed
    /**
     * @desc Constants declaration
     */
    group constants {
        
        /**
         * @desc Protocol version
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.1 SecuredMessage
         */
        const UInt8 c_protocol_version := 2;
        
        /**
         * @desc Security profile identifier for CAMs
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 7.1 Security profile for CAMs
         */
        const UInt8 c_security_profileCAMs := 1;
        
        /**
         * @desc Security profile identifier for DENMs
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 7.2 Security profile for DENMs
         */
        const UInt8 c_security_profileDENMs := 2;
        
        /**
         * @desc Security profile identifier for other messages
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 7.3 Generic security profile for other signed messages
         */
        const UInt8 c_security_profileOthers := 3;
garciay's avatar
garciay committed
        
        /**
         * @desc Certificate version
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 6.1 Certificate
garciay's avatar
garciay committed
         */
        const UInt8 c_certificate_version := 2;
        
    } // End of group constants
garciay's avatar
garciay committed
     * @desc Dummy send/receive templates for security headers
     * @see Draft ETSI TS 103 097 V1.1.6 Clause 4   Basic format elements
garciay's avatar
garciay committed
    group dummyBasicFormatElements {
        
garciay's avatar
garciay committed
         * @desc Dummy send templates for security headers
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2    Specification of basic format elements
garciay's avatar
garciay committed
        group dummyBasicFormatElementsSend {
            
garciay's avatar
garciay committed
            /**
             */
            group algorithms {
                
                /**
                 * @desc Generic send template for EccPoint description
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.6 Table 2: Derivation of field sizes depending on the used algorithm
                 */
                template (value) EccPoint m_eccPoint_dummy := { 
garciay's avatar
garciay committed
                    algorithm       := e_ecdsa_nistp256_with_sha256,
garciay's avatar
garciay committed
                    field_size      := f_int2UInt8(1 + lengthof(PX_ECDSA_X_COORDINATE)), 
garciay's avatar
garciay committed
                    type_           := e_x_coordinate_only,
                    x               := PX_ECDSA_X_COORDINATE,
garciay's avatar
garciay committed
                    y               := omit
                } // End of template m_eccPoint_dummy
                
                /**
                 * @desc Generic send template for AES CCM description
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.6 Table 2: Derivation of field sizes depending on the used algorithm
                 */
                template (value) EccPoint m_aesccm_dummy := { 
                    algorithm       := e_ecies_nistp256,
garciay's avatar
garciay committed
                    field_size      := f_int2UInt8(1 + lengthof(PX_AESCCM_X_COORDINATE)), 
                    type_           := e_uncompressed,
                    x               := PX_AESCCM_X_COORDINATE,
                    y               := {
                        y := PX_AESCCM_Y_COORDINATE // WARNING siseof(y) == siseof(x)
garciay's avatar
garciay committed
                    } // End of field y
                } // End of template m_aesccm_dummy
garciay's avatar
garciay committed
                /**
                 * @desc Generic send template for AES CCM encryption parameters
garciay's avatar
garciay committed
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.7    EncryptionParameters
garciay's avatar
garciay committed
                 */
garciay's avatar
garciay committed
                template (value) EncryptionParameters m_encryptionParameters_dummy := {
                    symm_algorithm := e_aes_128_ccm,
                    public_key := {
                        nonce := PX_AESCCM_NONCE
                    }
                } // End of template m_encryptionParameters_dummy
                
            } // End of group algorithms
garciay's avatar
garciay committed
            /**
garciay's avatar
garciay committed
             * @desc Generic send/receive templates for Signature description
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.5   EccPoint
             * @see Draft ETSI TS 103 097 V1.1.6 Table 2: Derivation of field sizes depending on the used algorithm
garciay's avatar
garciay committed
             */
            group signatures {
                
garciay's avatar
garciay committed
                template (value) Signature m_signature(
                                                       in template (value) EcdsaSignature p_ecdsaSignature
                ):= {
garciay's avatar
garciay committed
                    algorithm   := e_ecdsa_nistp256_with_sha256,
                    signature_  := {
garciay's avatar
garciay committed
                        ecdsa_signature := p_ecdsaSignature
garciay's avatar
garciay committed
                    } // End of field signature_
                } // End of template m_signature_ecdsa
                
                template (value) EcdsaSignature m_ecdsaSignature := {
                    algorithm   := e_ecdsa_nistp256_with_sha256,
                    field_size  := f_int2UInt8(1 + lengthof(PX_ECDSA_S)),
                    r           := m_eccPoint_dummy,
                    s           := PX_ECDSA_S
                } // End of template m_ecdsaSignature
                
garciay's avatar
garciay committed
            } // End of group signatures 
            
            group signerInfos {
                
                /**
                 * @desc Send template for self signed message
                 */
                template (value) SignerInfo m_SignerInfo_self := {
                    type_         := e_self,
                    signerInfo    := omit
                } // End of template m_SignerInfo_self
                
                /**
                 * @desc Send template for self signed message
                 */
                template (value) SignerInfo m_SignerInfo_digest(
                                                                in template (value) HashedId8 p_digest
                ) := {
                    type_         := e_certificate_digest_with_ecdsap256,
                    signerInfo    := {
                        digest := p_digest
                    } // End of field signerInfo 
                } // End of template m_SignerInfo_digest
                
                template (value) SignerInfo m_signerInfo_certificate(
                                                                     in template (value) Certificate p_certificate
                ) := {
                    type_         := e_certificate,
                    signerInfo    := {
                        certificate := p_certificate
                    } // End of field signerInfo 
                } // End of template m_signerInfo_certificate
                
                template (value) SignerInfo m_signerInfo_certificates(
                                                                      in template (value) CertificateChain p_certificates
                ) := {
                    type_         := e_certificate_chain,
                    signerInfo    := {
                        certificates := p_certificates
                    } // End of field signerInfo
                } // End of template m_signerInfo_certificates
                
            } // End of group signerInfos
garciay's avatar
garciay committed
            
garciay's avatar
garciay committed
            /**
             * @desc Dummy send template for PublicKey/EccPoint
garciay's avatar
garciay committed
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.4    PublicKey
garciay's avatar
garciay committed
             */
            template (value) PublicKey m_publicKey_eccPoint_dummy := {
                algorithm   := e_ecdsa_nistp256_with_sha256,
                public_key  := {
                    eccPoint := m_eccPoint_dummy
                } // End of field public_key
            } // End of template PublicKey
            
            /**
             * @desc Dummy send template for PublicKey/AES CCM
garciay's avatar
garciay committed
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.4    PublicKey
             */
            template (value) PublicKey m_publicKey_aesccm_dummy := {
                algorithm   := e_ecies_nistp256,
                public_key  := {
                    aesCcm := {
                        supported_symm_alg  := e_aes_128_ccm,
                        eccPoint            := m_aesccm_dummy
                    } // End of field aesCcm
                } // End of field public_key
            } // End of template m_publicKey_aesccm_dummy
            
garciay's avatar
garciay committed
            /**
             * @desc Send template for Time64WithStandardDeviation
             * @param p_time        TODO
             * @param p_log_std_dev TODO
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.17    Time64WithStandardDeviation
             */
            template (value) Time64WithStandardDeviation m_time64WithStandardDeviation(
                                                                                       in template (value) Time64 p_time,
                                                                                       in template (value) UInt8 p_log_std_dev
            ) := {
                time        := p_time,
                log_std_dev := p_log_std_dev
            } // End of template m_time64WithStandardDeviation
            
            /**
             * @desc Send template for TwoDLocation
             * @param p_latitude    Latitude range from  900 000 000 to +900 000 000
             * @param p_longitude   Longitude range from  1 800 000 000 to +1 800 000 000
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.19    TwoDLocation
             */
            template (value) TwoDLocation m_twoDLocation(
                                                         in template (value) Int32 p_latitude,
                                                         in template (value) Int32 p_longitude
            ) := {
                latitude    := p_latitude,
                longitude   := p_longitude
            } // End of template m_twoDLocation
            
            /**
             * @desc Send template for ThreeDLocation
             * @param p_latitude    Latitude range from  900 000 000 to +900 000 000
             * @param p_longitude   Longitude range from  1 800 000 000 to +1 800 000 000
             * @param p_elevation   Elevation relative to the WGS-84 ellipsoid in decimetres
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.20    ThreeDLocation
             */
            template (value) ThreeDLocation m_threeDLocation(
                                                             in template (value) Int32 p_latitude,
                                                             in template (value) Int32 p_longitude,
                                                             in template (value) Oct2 p_elevation
            ) := {
                latitude    := p_latitude,
                longitude   := p_longitude,
                elevation := p_elevation
            } // End of template m_threeDLocation
            
garciay's avatar
garciay committed
            /**
             * @desc Send template circular geographic region
             * @param p_center  Circle center 
             * @param p_radius  Circle radius
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.21  GeographicRegion
             */
            template (value) GeographicRegion m_geographicRegion_circle(
                                                                        in template (value) TwoDLocation p_center,
                                                                        in template (value) UInt16 p_radius
garciay's avatar
garciay committed
            ) := {
garciay's avatar
garciay committed
                region_type := e_circle,
                region := {
                    circular_region := {
                        center := p_center,
                        radius := p_radius 
                    } // End of field circular_region
                } // End of field region
            } // End of template m_geographicRegion_circle
            
            /**
             * @desc Basic send template rectangular geographic region
             * @param p_northwest  Upper left corner 
             * @param p_southeast  Lower rigth corner
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.21  GeographicRegion
             */
            template (value) GeographicRegion m_geographicRegion_rectangle(
                                                                           in template (value) TwoDLocation p_northwest,
                                                                           in template (value) TwoDLocation p_southeast
garciay's avatar
garciay committed
            ) := {
garciay's avatar
garciay committed
                region_type := e_rectangle,
                region := {
                    rectangular_region := {
                        {
                            northwest := p_northwest,
                            southeast := p_southeast 
                        }
                    } // End of field rectangular_region
                } // End of field region
            } // End of template m_geographicRegion_rectangle
garciay's avatar
garciay committed
            
            /**
             * @desc Send template polygonial geographic region
             * @param p_polygonal_region  Polygonial region description
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.21  GeographicRegion
             */
            template (value) GeographicRegion m_geographicRegion_polygonial(
                                                                            in template (value) PolygonalRegion p_polygonal_region
garciay's avatar
garciay committed
            ) := {
garciay's avatar
garciay committed
                region_type := e_polygon,
                region := {
                    polygonal_region := p_polygonal_region
                } // End of field region
            } // End of template m_geographicRegion_polygonial
            
            /**
             * @desc Send template for geographic identified region
             * @param p_id_region  Indentified region
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.21  GeographicRegion
             */
garciay's avatar
garciay committed
            template (value) GeographicRegion m_geographicRegion_identifiedRegion(
garciay's avatar
garciay committed
                                                                                  in template (value) IdentifiedRegion p_id_region
            ) := {
                region_type := e_id,
garciay's avatar
garciay committed
                region := {
garciay's avatar
garciay committed
                    id_region := p_id_region
garciay's avatar
garciay committed
                } // End of field region
garciay's avatar
garciay committed
            } // End of template m_geographicRegion_identifiedRegion
            
            /**
             * @desc Send template for not specified geographic region
             * @param p_id_region  Indentified region
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.21  GeographicRegion
             */
garciay's avatar
garciay committed
            template (value) GeographicRegion m_geographicRegion_nonce := {
                region_type := e_none,
                region := omit
            } // End of template m_geographicRegion_nonce
garciay's avatar
garciay committed
        } // End of group dummyBasicFormatElementsSend 
        
        /**
         * @desc Dummy receive templates for security headers
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2    Specification of basic format elements
         */
        group dummyBasicFormatElementsRecv {
            
            /**
             * @desc Dummy receive template for PublicKey/EccPoint
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.4    PublicKey
             */
            template (present) PublicKey mw_publicKey_eccPoint_dummy := {
                algorithm   := e_ecdsa_nistp256_with_sha256,
                public_key  := {
                    eccPoint := ?
                } // End of field public_key
            } // End of template PublicKey
garciay's avatar
garciay committed
            /**
             * @desc Dummy send template for PublicKey/AES CCM
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.4    PublicKey
             */
            template (present) PublicKey mw_publicKey_aesccm_dummy := {
                algorithm   := e_ecies_nistp256,
                public_key  := {
                    aesCcm := ?
                } // End of field public_key
            } // End of template m_publicKey_aesccm_dummy
garciay's avatar
garciay committed
            /**
             * @desc Dummy receive template for Time64WithStandardDeviation
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.17    Time64WithStandardDeviation
             */
            template (present) Time64WithStandardDeviation mw_time64WithStandardDeviation_dummy := {
                time        := ?,
                log_std_dev := ?
            } // End of template mw_time64WithStandardDeviation_dummy
            
            /**
             * @desc Receive template for Time64WithStandardDeviation
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.17    Time64WithStandardDeviation
             */
            template (present) Time64WithStandardDeviation mw_time64WithStandardDeviation(
                                                                                          in template (present) Time64 p_time,
                                                                                          in template (present) UInt8 p_log_std_dev
            ) := {
                time        := p_time,
                log_std_dev := p_log_std_dev
            } // End of template mw_time64WithStandardDeviation
            
            /**
             * @desc Dummy receive template for TwoDLocation
             * @param p_latitude    Latitude range from  900 000 000 to +900 000 000
             * @param p_longitude   Longitude range from  1 800 000 000 to +1 800 000 000
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.19    TwoDLocation
             */
            template (present) TwoDLocation mw_twoDLocation_dummy := {
                latitude    := ?,
                longitude   := ?
            } // End of template mw_twoDLocation_dummy
            
            /**
             * @desc Dummy receive template for TwoDLocation
             * @param p_latitude    Latitude range from  900 000 000 to +900 000 000
             * @param p_longitude   Longitude range from  1 800 000 000 to +1 800 000 000
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.19    TwoDLocation
             */
            template (present) TwoDLocation mw_twoDLocation(
                                                            in template (present) Int32 p_latitude,
                                                            in template (present) Int32 p_longitude
            ) := {
                latitude    := p_latitude,
                longitude   := p_longitude
            } // End of template mw_twoDLocation
            
            /**
             * @desc Dummy send template for ThreeDLocation
             * @param p_latitude    Latitude range from  900 000 000 to +900 000 000
             * @param p_longitude   Longitude range from  1 800 000 000 to +1 800 000 000
             * @param p_elevation   Elevation relative to the WGS-84 ellipsoid in decimetres
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.20    ThreeDLocation
             */
            template (present) ThreeDLocation mdw_threeDLocation_dummy := {
                latitude    := ?,
                longitude   := ?,
                elevation   := ?
            } // End of template mdw_threeDLocation_dummy
            
            /**
             * @desc Receive template for ThreeDLocation
             * @param p_latitude    Latitude range from  900 000 000 to +900 000 000
             * @param p_longitude   Longitude range from  1 800 000 000 to +1 800 000 000
             * @param p_elevation   Elevation relative to the WGS-84 ellipsoid in decimetres
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.20    ThreeDLocation
             */
            template (present) ThreeDLocation mw_threeDLocation(
                                                                in template (present) Int32 p_latitude,
                                                                in template (present) Int32 p_longitude,
                                                                in template (present) Oct2 p_elevation
            ) := {
                latitude    := p_latitude,
                longitude   := p_longitude,
                elevation   := p_elevation
            } // End of template mw_threeDLocation
            
garciay's avatar
garciay committed
            /**
             * @desc Receive template circular geographic region
             * @param p_center  Circle center 
             * @param p_radius  Circle radius
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.21  GeographicRegion
             */
            template (present) GeographicRegion mw_geographicRegion_circle(
                                                                           in template (present) TwoDLocation p_center,
                                                                           in template (present) UInt16 p_radius
garciay's avatar
garciay committed
            ) := {
garciay's avatar
garciay committed
                region_type := e_circle,
                region := {
                    circular_region := {
                        center := p_center,
                        radius := p_radius 
                    } // End of field circular_region
                } // End of field region
            } // End of template mw_geographicRegion_circle
            
            /**
             * @desc Basic receive template rectangular geographic region
             * @param p_northwest  Upper left corner 
             * @param p_southeast  Lower rigth corner
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.21  GeographicRegion
             */
            template (present) GeographicRegion mw_geographicRegion_rectangle_dummy(
                                                                                    in template (present) TwoDLocation p_northwest,
                                                                                    in template (present) TwoDLocation p_southeast
garciay's avatar
garciay committed
            ) := {
garciay's avatar
garciay committed
                region_type := e_rectangle,
                region := {
                    rectangular_region := {
                        {
                            northwest := p_northwest,
                            southeast := p_southeast 
                        }
                    } // End of field rectangular_region
                } // End of field region
            } // End of template mw_geographicRegion_rectangle_dummy
            
            /**
             * @desc Receive template polygonial geographic region
             * @param p_polygonal_region  Polygonial region description
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.21  GeographicRegion
             */
            template (present) GeographicRegion mw_geographicRegion_polygonial(
                                                                               in template (present) PolygonalRegion p_polygonal_region
garciay's avatar
garciay committed
            ) := {
garciay's avatar
garciay committed
                region_type := e_polygon,
                region := {
                    polygonal_region := p_polygonal_region
                } // End of field region
            } // End of template mw_geographicRegion_polygonial
            
            /**
             * @desc Receive template for geographic identified region
             * @param p_id_region  Indentified region
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.21  GeographicRegion
             */
garciay's avatar
garciay committed
            template (present) GeographicRegion mww_geographicRegion_identifiedRegion(
                                                                                      in template (present) IdentifiedRegion p_id_region
            ) := {
                region_type := e_id,
                region := {
                    id_region := p_id_region
                } // End of field region
            } // End of template mw_geographicRegion_identifiedRegion
            
            /**
             * @desc Receive template for not specified geographic region
             * @param p_id_region  Indentified region
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.21  GeographicRegion
             */
garciay's avatar
garciay committed
            template (present) GeographicRegion mw_geographicRegion_nonce := {
                region_type := e_none,
                region := omit
garciay's avatar
garciay committed
            } // End of template mw_geographicRegion_nonce
            
garciay's avatar
garciay committed
        } // End of group dummyBasicFormatElementsRecv
        
garciay's avatar
garciay committed
    } // End of group dummyBasicFormatElements 
    
garciay's avatar
garciay committed
     * @desc Dummy send/receive templates for security headers
     * @see Draft ETSI TS 103 097 V1.1.6 Clause 5   Specification of security header
garciay's avatar
garciay committed
    group dummyMessages {
        
garciay's avatar
garciay committed
         * @desc Dummy send templates for security headers
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 5   Specification of security header
         */
        group dummyMessagesSend {
            
            /**
garciay's avatar
garciay committed
             * @desc Generic send template for Security profile for CAMs
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 7.1  Security profile for CAMs
             */
            template (value) SecuredMessage m_secureMessageCAMs_dummy := {
                protocol_version     := c_protocol_version,
                security_profile     := c_security_profileCAMs,
                header_fields        := {
                    m_header_field_signer_info(
                        m_SignerInfo_self
                    )
                },
                payload_fields        := { },
                trailer_fields        := { }
            } // End of template m_secureMessageCAMs_dummy
            
garciay's avatar
garciay committed
            /**
             * @desc Generic send template for Security profile for DENMs
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 7.2  Security profile for DENMs
             */
            template (value) SecuredMessage m_secureMessageDENMs_dummy := {
                protocol_version     := c_protocol_version,
                security_profile     := c_security_profileDENMs,
                header_fields        := { 
                    m_header_field_signer_info(
                        m_SignerInfo_self
                    )
                },
garciay's avatar
garciay committed
                payload_fields        := { },
                trailer_fields        := { }
            } // End of template m_secureMessageDENMs_dummy
garciay's avatar
garciay committed
            /**
             * @desc Generic send template for Security profile for other messages
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 7.3    Generic security profile for other signed messages
             */
            template (value) SecuredMessage m_secureMessageOthers_dummy := {
                protocol_version     := c_protocol_version,
                security_profile     := c_security_profileOthers,
                header_fields        := { 
                    m_header_field_signer_info(
                        m_SignerInfo_self
                    )
                },
garciay's avatar
garciay committed
                payload_fields        := { },
                trailer_fields        := { }
            } // End of template m_secureMessageCAMs_dummy
garciay's avatar
garciay committed
            
        } // End of group dummyMessagesSend
        
        /**
garciay's avatar
garciay committed
         * @desc Dummy receive templates for security headers
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 5   Specification of security header
garciay's avatar
garciay committed
        group dummyMessagesRecv {
            
            /**
             * @desc Generic received template for SecuredMessage
             */
            template (present) SecuredMessage mw_securedMessage_dummy := {
                protocol_version    := c_protocol_version, 
garciay's avatar
garciay committed
                security_profile    := ?,
                header_fields       := ?,
                payload_fields      := ?,
                trailer_fields      := ?
            } // End of template mw_securedMessage_dummy
            
            /**
             * @desc Generic received template for SecuredMessage
             */
            template (present) Payload mw_signedPayload_dummy := {
garciay's avatar
garciay committed
                type_   := e_signed, 
                data    := ?
garciay's avatar
garciay committed
            } // End of template mw_signedPayload_dummy
            
            /**
             * @desc Generic received template for SecuredMessage
             */
            template (present) Payload mw_unsecuredPayload_dummy := {
garciay's avatar
garciay committed
                type_   := e_unsecured, 
                data    := ?
garciay's avatar
garciay committed
            } // End of template mw_unsecuredPayload_dummy
            
        } // End of group dummyMessagesRecv 
        
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052
        group payloads {
                
            template (value) Payload m_payload_signed_external := {
                type_   := e_signed_external,
                data    := omit
            } // End of template m_payload_signed_external
            
            template (value) Payload m_data_payload_rawPayload(
                                                               in template (value) PayloadType p_type,
                                                               in template (value) octetstring p_rawPayload
            ) := {
                type_   := p_type,
                data    := {
                    rawPayload := p_rawPayload
                } // End of field data
            } // End of template m_data_payload_rawPayload
                            
            group camPayloads {
                
                group camPayloadsSend {
                    
                    template (value) Payload m_payload_unsecured_cam(
                                                                     in template (value) CAM p_camPayload
                    ) := {
                        type_   := e_unsecured,
                        data    := {
                            camPayload := p_camPayload
                        } // End of field data
                    } // End of template m_payload_unsecured_cam
                    
                    template (value) Payload md_payload_signed_cam(
                                                                   in template (value) CAM p_camPayload
                    ) modifies m_payload_unsecured_cam := {
                        type_   := e_signed
                    } // End of template md_payload_signed_cam
                    
                    template (value) Payload md_payload_encrypted_cam(
                                                                      in template (value) CAM p_camPayload
                    ) modifies m_payload_unsecured_cam := {
                        type_   := e_encrypted
                    } // End of template md_payload_encrypted_cam
                    
                    template (value) Payload md_payload_signed_encrypted_cam(
                                                                             in template (value) CAM p_camPayload
                    ) modifies m_payload_unsecured_cam := {
                        type_   := e_signed_and_encrypted
                    } // End of template md_payload_signed_encrypted_cam
                    
                    template (present) Payload mw_payload_unsecured_cam(
                                                                        in template (present) CAM p_camPayload
                    ) := {
                        type_   := e_unsecured,
                        data    := {
                            camPayload := p_camPayload
                        } // End of field data
                    } // End of template mw_payload_unsecured_cam
                    
                } // End of group camPayloadsSend
                
                group camPayloadsRecv {
                    
                    template (present) Payload mdw_payload_signed_cam(
                                                                      in template (present) CAM p_camPayload
                    ) modifies mw_payload_unsecured_cam := {
                        type_   := e_signed
                    } // End of template mdw_payload_signed_cam
                    
                    template (present) Payload mdw_payload_encrypted_cam(
                                                                         in template (present) CAM p_camPayload
                    ) modifies mw_payload_unsecured_cam := {
                        type_   := e_encrypted
                    } // End of template mdw_payload_encrypted_cam
                    
                    template (present) Payload mdw_payload_signed_encrypted_cam(
                                                                                in template (present) CAM p_camPayload
                    ) modifies mw_payload_unsecured_cam := {
                        type_   := e_signed_and_encrypted
                    } // End of template mdw_payload_signed_encrypted_cam
                    
                } // End of group camPayloadsRecv
                
            } // End of group camPayloads
            
            group denmPayloads {
                
                group denmPayloadsSend {
                    
                    template (value) Payload m_payload_unsecured_denm(
                                                                      in template (value) DENM p_denmPayload
                    ) := {
                        type_   := e_unsecured,
                        data    := {
                            denmPayload := p_denmPayload
                        } // End of field data
                    } // End of template m_payload_unsecured_denm
                    
                    template (value) Payload md_payload_signed_denm(
                                                                    in template (value) DENM p_denmPayload
                    ) modifies m_payload_unsecured_denm := {
                        type_   := e_signed
                    } // End of template md_payload_signed_denm
                    
                    template (value) Payload md_payload_encrypted_denm(
                                                                       in template (value) DENM p_denmPayload
                    ) modifies m_payload_unsecured_denm := {
                        type_   := e_encrypted
                    } // End of template md_payload_encrypted_denm
                    
                    template (value) Payload md_payload_signed_encrypted_denm(
                                                                              in template (value) DENM p_denmPayload
                    ) modifies m_payload_unsecured_denm := {
                        type_   := e_signed_and_encrypted
                    } // End of template md_payload_signed_encrypted_denm
                    
                } // End of group denmPayloadsSend
                
                group denmPayloadsRecv {
                    
                    template (present) Payload mw_payload_unsecured_denm(
                                                                         in template (present) DENM p_denmPayload
                    ) := {
                        type_   := e_unsecured,
                        data    := {
                            denmPayload := p_denmPayload
                        } // End of field data
                    } // End of template mw_payload_unsecured_denm
                    
                    template (present) Payload mdw_payload_signed_denm(
                                                                       in template (present) DENM p_denmPayload
                    ) modifies mw_payload_unsecured_denm := {
                        type_   := e_signed
                    } // End of template mdw_payload_signed_denm
                    
                    template (present) Payload mdw_payload_encrypted_denm(
                                                                          in template (present) DENM p_denmPayload
                    ) modifies mw_payload_unsecured_denm := {
                        type_   := e_encrypted
                    } // End of template mdw_payload_encrypted_denm
                    
                    template (present) Payload mdw_payload_signed_encrypted_denm(
                                                                                 in template (present) DENM p_denmPayload
                    ) modifies mw_payload_unsecured_denm := {
                        type_   := e_signed_and_encrypted
                    } // End of template mdw_payload_signed_encrypted_denm
                    
                } // End of group denmPayloadsRecv
                
            } // End of group denmPayloads
            
        } // End of group payloads
        
        group headerFields {
            
            group headerFieldsSend {
                
                /**
                 * @desc Send template for HeaderField with generation time information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (value) HeaderField m_header_field_generation_time(
                                                                            in template (value) Time64 p_generation_time
                ) := {
                    type_       := e_generation_time,
                    headerField := {
                        generation_time := p_generation_time
                    }
                } // End of template m_header_field_generation_time
                
                /**
                 * @desc Send template for HeaderField with generation time and standard deviation information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (value) HeaderField m_header_field_generation_time_with_standard_deviation(
                                                                                                    in template (value) Time64WithStandardDeviation p_generation_time_with_standard_deviation
                ) := {
                    type_       := e_generation_time_standard_deviation,
                    headerField := {
                        generation_time_with_standard_deviation := p_generation_time_with_standard_deviation
                    }
                } // End of template m_header_field_generation_time_with_standard_deviation
                
                /**
                 * @desc Send template for HeaderField with expiration time information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (value) HeaderField m_header_field_expiry_time(
                                                                        in template (value) Time32 p_expiry_time
                ) := {
                    type_       := e_expiration,
                    headerField := {
                        expiry_time := p_expiry_time
                    }
                } // End of template m_header_field_expiry_time
                
                /**
                 * @desc Send template for HeaderField with generation location information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (value) HeaderField m_header_field_generation_location(
                                                                                in template (value) ThreeDLocation p_generation_location
                ) := {
                    type_       := e_generation_location,
                    headerField := {
                        generation_location := p_generation_location
                    }
                } // End of template m_header_field_generation_location
                
                /**
                 * @desc Send template for HeaderField with generation location information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (value) HeaderField m_header_field_digests(
                                                                    in template (value) HashedId3 p_digests
                ) := {
                    type_       := e_request_unrecognized_certificate,
                    headerField := {
                        digests := p_digests
                    }
                } // End of template m_header_field_digests
                
                /**
                 * @desc Send template for HeaderField with generation location information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (value) HeaderField m_header_field_message_type(
                                                                         in template (value) UInt16 p_message_type
                ) := {
                    type_       := e_message_type,
                    headerField := {
                        message_type := p_message_type
                    }
                } // End of template m_header_field_message_type
                
                /**
                 * @desc GSend template for HeaderField with signer information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (value) HeaderField m_header_field_signer_info(
                                                                        in template (value) SignerInfo p_signer
                ) := {
                    type_       := e_signer_info,
                    headerField := {
                        signer := p_signer
                    }
                } // End of template m_header_field_signerInfo_signer_info
                
                /**
                 * @desc Send template for HeaderField with signer information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (value) HeaderField m_header_field_recipient(
                                                                      in template (value) RecipientInfo p_recipient
                ) := {
                    type_       := e_recipient_info,
                    headerField := {
                        recipient := p_recipient
                    }
                } // End of template m_header_field_recipient
                
                /**
                 * @desc Send template for HeaderField with signer information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (value) HeaderField m_header_field_enc_params(
                                                                       in template (value) EncryptionParameters p_enc_params
                ) := {
                    type_       := e_encryption_parameters,
                    headerField := {
                        enc_params := p_enc_params
                    }
                } // End of template m_header_field_enc_params
                
            } // End of group headerFieldsSend
        
            group headerFieldsRecv {
                
                /**
                 * @desc Receive template for HeaderField with generation time information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (present) HeaderField mw_header_field_generation_time(
                                                                               in template (present) Time64 p_generation_time
                ) := {
                    type_       := e_generation_time,
                    headerField := {
                        generation_time := p_generation_time
                    }
                } // End of template mw_header_field_generation_time
                
                /**
                 * @desc Receive template for HeaderField with generation time and standard deviation information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (present) HeaderField mw_header_field_generation_time_with_standard_deviation(
                                                                                                       in template (present) Time64WithStandardDeviation p_generation_time_with_standard_deviation
                ) := {
                    type_       := e_generation_time_standard_deviation,
                    headerField := {
                        generation_time_with_standard_deviation := p_generation_time_with_standard_deviation
                    }
                } // End of template mw_header_field_generation_time_with_standard_deviation
                
                /**
                 * @desc Receive template for HeaderField with expiration time information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (present) HeaderField mw_header_field_expiry_time(
                                                                           in template (present) Time32 p_expiry_time
                ) := {
                    type_       := e_expiration,
                    headerField := {
                        expiry_time := p_expiry_time
                    }
                } // End of template mw_header_field_expiry_time
                
                /**
                 * @desc Receive template for HeaderField with generation location information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (present) HeaderField mw_header_field_generation_location(
                                                                                   in template (present) ThreeDLocation p_generation_location
                ) := {
                    type_       := e_generation_location,
                    headerField := {
                        generation_location := p_generation_location
                    }
                } // End of template mw_header_field_generation_location
                
                /**
                 * @desc Receive template for HeaderField with generation location information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (present) HeaderField mw_header_field_digests(
                                                                       in template (present) HashedId3 p_digests
                ) := {
                    type_       := e_request_unrecognized_certificate,
                    headerField := {
                        digests := p_digests
                    }
                } // End of template mw_header_field_digests
                
                /**
                 * @desc Receive template for HeaderField with generation location information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (present) HeaderField mw_header_field_message_type(
                                                                            in template (present) UInt16 p_message_type
                ) := {
                    type_       := e_message_type,
                    headerField := {
                        message_type := p_message_type
                    }
                } // End of template mw_header_field_message_type
                
                /**
                 * @desc Receive template for HeaderField with signer information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (present) HeaderField mw_header_field_signer_info(
                                                                           in template (present) SignerInfo p_signer
                ) := {
                    type_       := e_signer_info,
                    headerField := {
                        signer := p_signer
                    }
                } // End of template mw_header_field_signerInfo_signer_info
                
                /**
                 * @desc Receive template for HeaderField with signer information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (value) HeaderField mw_header_field_recipient(
                                                                       in template (value) RecipientInfo p_recipient
                ) := {
                    type_       := e_recipient_info,
                    headerField := {
                        recipient := p_recipient
                    }
                } // End of template mw_header_field_recipient
                
                /**
                 * @desc Receive template for HeaderField with signer information
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4    HeaderField
                 */
                template (present) HeaderField mw_header_field_enc_params(
                                                                          in template (present) EncryptionParameters p_enc_params
                ) := {
                    type_       := e_encryption_parameters,
                    headerField := {
                        enc_params := p_enc_params
                    }
                } // End of template mw_header_field_enc_params
                
            } // End of group headerFieldsRecv
        
        } // End of group headerFields
        
        group trailerFields {
            
            template (value) TrailerField m_trailer_field_signature(
                                                                    in template (value) Signature p_signature
            ) := {
                type_           := e_signature,
                trailerField    := {
                    signature_ := p_signature
                }
            } // End of template m_trailer_field_dummy
            
        } // End of group trailerFields
        
garciay's avatar
garciay committed
    } // End of group dummyMessages
    
garciay's avatar
garciay committed
     * @desc Dummy send/receive templates for certificates
     * @see Draft ETSI TS 103 097 V1.1.6 Clause 6   Specification of certificate format
     */
    group dummyCertifices {
        
        /**
garciay's avatar
garciay committed
         * @desc Dummy send templates for certificates
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 6   Specification of certificate format
         */
        group dummyCertificesSend {
            
garciay's avatar
garciay committed
            /**
             * @desc Dummy send certificate template
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 6.1    Certificate
             */
            template (value) Certificate m_certificate_dummy := {
                version                 := c_certificate_version,
garciay's avatar
garciay committed
                signer_info             := { 
garciay's avatar
garciay committed
                    m_SignerInfo_digest(
                        PX_ECDSA_DIGEST
garciay's avatar
garciay committed
                    )
garciay's avatar
garciay committed
                }, // End of field signer_info
garciay's avatar
garciay committed
                subject_info            := m_subject_info_dummy,
                subject_attributes      := { m_subject_attribute_dummy },
                validity_restrictions   := { m_validity_restriction_dummy },
garciay's avatar
garciay committed
                signature_              := m_signature(
                    m_ecdsaSignature
                ) // End of field signature_ 
garciay's avatar
garciay committed
            } // End of template m_certificate_dummy
            
            template (value) SubjectInfo m_subject_info_dummy := {
                subject_type := e_root_ca,
                subject_name := ''O
            } // End of template SubjectInfo
            
            template (value) SubjectAttribute m_subject_attribute_dummy := {
                type_       := e_verification_key,
                attribute   := {
                    key := m_publicKey_eccPoint_dummy
                }
            } // End of template m_subject_attribute_dummy
            
            template (value) ValidityRestriction m_validity_restriction_dummy := {
                type_       := e_time_end,
                validity    :=  {
                    end_validity := 0
                }
            } // End of template m_validity_dummy
            
        } // End of group dummyCertificesSend
        
        /**
garciay's avatar
garciay committed
         * @desc Dummy receive templates for certificates
         * @see Draft ETSI TS 103 097 V1.1.6 Clause 6   Specification of certificate format
         */
        group dummyCertificesRecv {
            
garciay's avatar
garciay committed
            /**
             * @desc Dummy receive certificate template
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 6.1    Certificate
             */
            template (present) Certificate mw_certificate_dummy := {
                version                 := c_certificate_version,
                signer_info             := ?,
                subject_info            := ?,
                subject_attributes      := ?,
                validity_restrictions   := ?,
                signature_              := ?
            } // End of template mw_certificate_dummy
garciay's avatar
garciay committed
            
        } // End of group dummyCertificesRecv
        
    } // End of group dummyCertifices
    
    /**
     */
garciay's avatar
garciay committed
    group securityProfiles {
        
        /**
         */
        group securityProfilesCAMs {
            
            /**
             */
            group securityProfilesCAMsSend {
                
                /**
garciay's avatar
garciay committed
                 * @desc Generic send template for Security profile for CAMs
                 */
                template (value) SecuredMessage md_secureMessageCAMs(
                                                                     in template (value) HeaderFields p_header_fields,
                                                                     in template (value) Payloads p_payload_fields,
                                                                     in template (value) TrailerFields p_trailer_fields
                ) modifies m_secureMessageCAMs_dummy := {
                    security_profile    := c_security_profileCAMs,
                    header_fields       := p_header_fields,
                    payload_fields      := p_payload_fields,
                    trailer_fields      := p_trailer_fields
                } // End of template md_secureMessageCAMs
                
                template (value) HeaderField m_header_field_signer_info_ecdsa(
                                                                              in template (value) SignerInfo p_signer
                ) modifies m_header_field_signer_info := {
garciay's avatar
garciay committed
                    headerField := {
                        signer := p_signer
                } // End of template m_header_field_signer_info_ecdsa
                
            } // End of group securityProfilesCAMsSend
garciay's avatar
garciay committed
            group securityProfilesCAMsRecv {
                
                /**
                 * @desc Generic received template for Security profile for CAMs
                 */
                template (present) SecuredMessage mdw_secureMessageCAMs_dummy
                modifies mw_securedMessage_dummy := {
                    security_profile    := c_security_profileCAMs
                } // End of template mw_securedMessage_dummy
                
                /**
                 * @desc Generic received template for Security profile for CAMs
                 */
                template (present) SecuredMessage mdw_secureMessageCAMs
                modifies mdw_secureMessageCAMs_dummy := { // TODO To be continued
                    security_profile    := ?,
                    header_fields       := ?,
                    payload_fields      := ?,
                    trailer_fields      := ?
                } // End of template mw_securedMessage_dummy
                
            } // End of group mdw_secureMessageCAMs_dummy
            
        } // End of group securityProfilesCAMs
garciay's avatar
garciay committed
        
        group denmSecurityProfiles {
            
        } // End of group denmSecurityProfiles
        
        group otherSecurityProfiles {
            
        } // End of group otherSecurityProfiles
        
    } // End of group securityProfiles
garciay's avatar
garciay committed
    
    group utPrimitives {
        
    } // End of group utPrimitives
    
garciay's avatar
garciay committed
    /**
     * @desc Function helpers for static_cast<> operation (to reduce warning in TTWB)
     */
    group typeConverters {
        
        function f_int2UInt8(in integer p_value) return UInt8 {
            return p_value;
        }
        
    }
    
garciay's avatar
garciay committed
} // End of module LibItsSecurity_Templates