LibItsSecurity_Templates.ttcn3 134 KB
Newer Older
garciay's avatar
garciay committed
/**
 *  @version  $URL$
 *            $Id$
 *  @desc     Module containing templates for Security Protocol
garciay's avatar
garciay committed
 *  @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.
garciay's avatar
garciay committed
 *
 */
module LibItsSecurity_Templates {
    
    // LibCommon
    import from LibCommon_BasicTypesAndValues all;
    import from LibCommon_DataStrings all;
garciay's avatar
garciay committed
    
    // LibItsCommon
    import from LibItsCommon_TypesAndValues all;
garciay's avatar
garciay committed
    // LibItsSecurity
    import from LibItsSecurity_TypesAndValues all;
    import from LibItsSecurity_Pixits all;
garciay's avatar
garciay committed
    /**
     * @desc Constants declaration
     */
    group constants {
        
        /**
         * @desc Protocol version
         * @see Draft ETSI TS 103 097 V1.1.14 Clause 5.1 SecuredMessage
         */
        const UInt8 c_protocol_version := 2;
        
        /**
         * @desc Certificate version
         * @see Draft ETSI TS 103 097 V1.1.14 Clause 6.1 Certificate
        const UInt8 c_certificate_version := 2;
        /**
         * @desc Its AID for Other
         * @see Draft ETSI TS 103 097 V1.1.14 Clause 7.3 Security profile for DENMs
         */
        const IntX c_its_aid_Other := PX_OTHER_ITS_AID;
garciay's avatar
garciay committed
        
        /**
         * @desc Minimal value of Longitude
garciay's avatar
garciay committed
         */
        const Int32 c_minLongitude := -1800000000;
         * @desc Maximal value of Longitude
        const Int32 c_maxLongitude :=  1800000000;
         * @desc Minimal value of Latitude
filatov's avatar
filatov committed
        const Int32 c_minLatitude  := -900000000; 
        
        /**
         * @desc Maximal value of Latitude
         */
filatov's avatar
filatov committed
        const Int32 c_maxLatitude  :=  900000000;
        
        /**
         * @desc List of ISO-3166 country codes
         */
        const RegionIdentifiers c_iso3166Codes := {
filatov's avatar
filatov committed
            4,   8,  10,  12,  16,  20,  24,  28,  31,  32,  36,  40,  44,  48,  50,  51,  52,  56,
           60,  64,  68,  70,  72,  74,  76,  84,  86,  90,  92,  96, 100, 104, 108, 112, 116, 120,
          124, 132, 136, 140, 144, 148, 152, 156, 158, 162, 166, 170, 174, 175, 178, 180, 184, 188,
          191, 192, 196, 203, 204, 208, 212, 214, 218, 222, 226, 231, 232, 233, 234, 238, 239, 242,
          246, 248, 250, 254, 258, 260, 262, 266, 268, 270, 275, 276, 288, 292, 296, 300, 304, 308,
          312, 316, 320, 324, 328, 332, 334, 336, 340, 344, 348, 352, 356, 360, 364, 368, 372, 376,
          380, 384, 388, 392, 398, 400, 404, 408, 410, 414, 417, 418, 422, 426, 428, 430, 434, 438,
          440, 442, 446, 450, 454, 458, 462, 466, 470, 474, 478, 480, 484, 492, 496, 498, 499, 500,
          504, 508, 512, 516, 520, 524, 528, 531, 533, 534, 535, 540, 548, 554, 558, 562, 566, 570,
          574, 578, 580, 581, 583, 584, 585, 586, 591, 598, 600, 604, 608, 612, 616, 620, 624, 626,
          630, 634, 638, 642, 643, 646, 652, 654, 659, 660, 662, 663, 666, 670, 674, 678, 682, 686,
          688, 690, 694, 702, 703, 704, 705, 706, 710, 716, 724, 728, 729, 732, 740, 744, 748, 752,
          756, 760, 762, 764, 768, 772, 776, 780, 784, 788, 792, 795, 796, 798, 800, 804, 807, 810,
          818, 826, 831, 832, 833, 834, 840, 850, 854, 858, 860, 862, 876, 882, 887, 894 
        /**
         * @desc List of United Nations Statistics Division country codes
         */
        const RegionIdentifiers c_unStatsAdditionalCodes := {
            1,   2,   5,   9,  11,  13,  14,  15,  17,  18,  19,  21,  29,  30,  34,  35,  39,  53,
           54,  57,  61, 142, 143, 145, 150, 151, 154, 155, 199, 419, 432, 680, 722, 830
       };
    } // 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.14 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.14 Clause 4.2    Specification of basic format elements
garciay's avatar
garciay committed
        group dummyBasicFormatElementsSend {
            
garciay's avatar
garciay committed
            /**
garciay's avatar
garciay committed
             * @desc Generic Send/Receive templates for security algorithm descriptions
garciay's avatar
garciay committed
             */
            group dummyAlgorithms {
            } // End of group dummyAlgorithms
            
        } // End of group dummyBasicFormatElementsSend 
        
        /**
         * @desc Dummy receive templates for security headers
         * @see Draft ETSI TS 103 097 V1.1.14 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.14 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 mw_publicKey_eccPoint_dummy
            
            /**
             * @desc Dummy send template for PublicKey/AES CCM
             * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.4    PublicKey
             */
            template (present) PublicKey mw_publicKey_aesccm_dummy := {
                algorithm   := e_ecies_nistp256,
                public_key  := {
                    aesCcm := ?
                } // End of field public_key
garciay's avatar
garciay committed
            } // End of template mw_publicKey_aesccm_dummy
            
            /**
             * @desc Dummy receive template for Time64WithStandardDeviation
             * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.17    Time64WithStandardDeviation
             */
            template (present) Time64WithStandardDeviation mw_time64WithStandardDeviation_dummy := {
                time        := ?,
                log_std_dev := ?
            } // End of template mw_time64WithStandardDeviation_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.14 Clause 4.2.19    TwoDLocation
             */
            template (present) TwoDLocation mw_twoDLocation_dummy := {
                latitude    := ?,
                longitude   := ?
            } // End of template mw_twoDLocation_dummy
            
            /**
             * @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.14 Clause 4.2.20    ThreeDLocation
             */
            template (present) ThreeDLocation mdw_threeDLocation_dummy := {
                latitude    := ?,
                longitude   := ?,
                elevation   := ?
            } // End of template mdw_threeDLocation_dummy
            
        } // End of group dummyBasicFormatElementsRecv
        
    } // End of group dummyBasicFormatElements 
    
    /**
     * @desc Send/receive templates for security headers
     * @see Draft ETSI TS 103 097 V1.1.14 Clause 4   Basic format elements
     */
    group basicFormatElements {
        
        /**
         * @desc Send templates for security headers
         * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2    Specification of basic format elements
         */
        group basicFormatElementsSend {
            
            /**
             * @desc Send templates for security algorithm descriptions
garciay's avatar
garciay committed
                 * @desc Send template for EccPoint description based on x_coordinate_only type
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.14 Table 2: Derivation of field sizes depending on the used algorithm
                 */
                template (value) EccPoint m_eccPointecdsa_nistp256_with_sha256_x_coordinate_only(
garciay's avatar
garciay committed
                                                                                                  in template (value) octetstring p_x
                ) := { 
                    type_           := e_x_coordinate_only,
                    x               := p_x,
                    y               := omit
                } // End of template m_eccPointecdsa_nistp256_with_sha256_x_coordinate_only
                
                /**
                 * @desc Send template for EccPoint description based on y_coordinate_only type
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.14 Table 2: Derivation of field sizes depending on the used algorithm
                 */
                template (value) EccPoint m_eccPointecdsa_nistp256_with_sha256_y_coordinate_only(
                                                                                                  in template (value) octetstring p_x
                ) := { 
                    type_           := e_compressed_lsb_y_0,
                    x               := p_x,
                    y               := omit
                } // End of template m_eccPointecdsa_nistp256_with_sha256_y_coordinate_only
                
garciay's avatar
garciay committed
                 * @desc Send template for EccPoint description based on uncompressed type
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.14 Table 2: Derivation of field sizes depending on the used algorithm
garciay's avatar
garciay committed
                template (value) EccPoint m_eccPointecdsa_nistp256_with_sha256_uncompressed(
                                                                                            in template (value) octetstring p_x,
                                                                                            in template (value) octetstring p_y
                ) := {
                    type_           := e_uncompressed,
                    x               := p_x,
                    y               := {
                        y := p_y
garciay's avatar
garciay committed
                    }
                } // End of template m_eccPointecdsa_nistp256_with_sha256_uncompressed
                
                /**
                 * @desc Information regarding AES CCM encryption
                 * @param p_eccPoint   The EccPoint used in the PublicKey
                 */
                template (value) AesCcm m_aesccm(
                                                 in template (value) EccPoint p_eccPoint
                ) := {
                    supported_symm_alg  := e_aes_128_ccm,
                    eccPoint            := p_eccPoint
                } // End of template m_aesccm
                
garciay's avatar
garciay committed
                 * @desc Send template for AES CCM encryption parameters
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.7    EncryptionParameters
                 */
                template (value) EncryptionParameters m_encryptionParameters_aes_128_ccm(
                                                                                         in template (value) Oct12 p_nonce
garciay's avatar
garciay committed
                ) := {
                    symm_algorithm := e_aes_128_ccm,
                    public_key := {
                        nonce := p_nonce
                    }
                } // End of template m_encryptionParameters_aes_128_ccm
            } // End of group algorithms
garciay's avatar
garciay committed
            /**
             * @desc Send template for PublicKey/EccPoint
             * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.4    PublicKey
garciay's avatar
garciay committed
             */
            template (value) PublicKey m_publicKey_eccPoint(
                                                            in template (value) EccPoint p_eccPoint
            ) := {
                algorithm   := e_ecdsa_nistp256_with_sha256,
                public_key  := {
                    eccPoint := p_eccPoint
                } // End of field public_key
            } // End of template m_publicKey_eccPoint
            
            /**
             * @desc Send template for PublicKey/AES CCM
             * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.4    PublicKey
garciay's avatar
garciay committed
             */
            template (value) PublicKey m_publicKey_aesccm(
                                                          in template (value) AesCcm p_aesCcm
            ) := {
                algorithm   := e_ecies_nistp256,
                public_key  := {
                    aesCcm := p_aesCcm
                } // End of field public_key
            } // End of template m_publicKey_aesccm
            
garciay's avatar
garciay committed
            /**
             * @desc Send templates for Signature description
             * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.9   Signature
             * @see Draft ETSI TS 103 097 V1.1.14 Table 2: Derivation of field sizes depending on the used algorithm
garciay's avatar
garciay committed
             */
            group signatures {
                
garciay's avatar
garciay committed
                /**
                 * @desc Send template for signatures based on ECDSA algorithm
                 * @member p_ecdsaSignature The ECDSA based signature
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.9   Signature
garciay's avatar
garciay committed
                 */
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
                
garciay's avatar
garciay committed
                /**
                 * @desc Send template for ECDSA based signature
                 * @member p_r          The coordinate of the elliptic curve point resulting from multiplying the generator element by the ephemeral private key
                 * @member p_s          The signature
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.10   EcdsaSignature
garciay's avatar
garciay committed
                 */
                template (value) EcdsaSignature m_ecdsaSignature(
                                                                 in template (value) EccPoint p_r,
                                                                 in template (value) octetstring p_s
                ) := {
                    r           := p_r,
                    s           := p_s
garciay's avatar
garciay committed
                } // End of template m_ecdsaSignature
                
garciay's avatar
garciay committed
                /**
                 * @desc Send template for signatures based on unknown algorithm
                 * @member p_signature The unknown signature
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.9   Signature
                 */
                template (value) Signature m_unknownSignature(
                                                              in template (value) octetstring p_signature
                ):= {
                    algorithm   := e_unknown,
                    signature_  := {
                        signature_ := p_signature
                    } // End of field signature_
                } // End of template m_unknownSignature
                
garciay's avatar
garciay committed
            } // End of group signatures 
            
            group signerInfos {
                
                /**
                 * @desc Send template for self signed message
                 */
                template (value) SignerInfo m_signerInfo_self := {
garciay's avatar
garciay committed
                    type_         := e_self,
                    signerInfo    := omit
                } // End of template m_signerInfo_self
garciay's avatar
garciay committed
                
                /**
                 * @desc Send template for self signed message
                 */
                template (value) SignerInfo m_signerInfo_digest(
garciay's avatar
garciay committed
                                                                in template (value) HashedId8 p_digest
                ) := {
                    type_         := e_certificate_digest_with_sha256,
garciay's avatar
garciay committed
                    signerInfo    := {
                        digest := p_digest
                    } // End of field signerInfo 
                } // End of template m_signerInfo_digest
garciay's avatar
garciay committed
                /**
                 * @desc Send template for certificate signed message
                 */
garciay's avatar
garciay committed
                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
                
garciay's avatar
garciay committed
                /**
                 * @desc Send template for certificate chain signed message
                 */
garciay's avatar
garciay committed
                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
                
garciay's avatar
garciay committed
                /**
                 * @desc Send template for other certificate signed message
                 */
garciay's avatar
garciay committed
                template (value) SignerInfo m_signerInfo_other_certificates(
                                                                            in template (value) CertificateWithAlgo p_certificateWithAlgo
                ) := {
                    type_         := e_certificate_digest_with_other_algorithm,
                    signerInfo    := {
                        certificateWithAlgo := p_certificateWithAlgo
                    } // End of field signerInfo
                } // End of template m_signerInfo_other_certificates
                
                template (value) CertificateWithAlgo m_certificateWithAlgo_ecdsa(
                                                                                 in template (value) HashedId8 p_digest
                ) := {
                    algorithm := e_ecdsa_nistp256_with_sha256,
                    digest := p_digest
                } // End of m_certificateWithAlgo
                
garciay's avatar
garciay committed
                /**
                 * @desc Send template for unknown signed message
                 */
                template (value) SignerInfo m_signerInfo_unknown(
                                                                 in template (value) octetstring p_info
                ) := {
                    type_         := e_unknown,
                    signerInfo    := {
                        info := p_info
                    } // End of field signerInfo
                } // End of template m_signerInfo_unknown
                
garciay's avatar
garciay committed
            } // End of group signerInfos
garciay's avatar
garciay committed
            
garciay's avatar
garciay committed
            /**
             * @desc Send template for Time64WithStandardDeviation
garciay's avatar
garciay committed
             * @param p_time        Time in microseconds
             * @param p_log_std_dev Estimate standard deviation (unit: nanoseconds)
             * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.17    Time64WithStandardDeviation
garciay's avatar
garciay committed
             */
            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 Duration (in seconds)
             * @param p_duration    The duration value
             * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.18  Duration
             */
            template (value) Duration m_duration_in_seconds(
                                                            in template (value) Int13 p_duration
            ) := {
                unit        := e_seconds,
garciay's avatar
garciay committed
                duration_   := p_duration
            } // End of template m_duration_in_seconds
            
garciay's avatar
garciay committed
            /**
             * @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.14 Clause 4.2.19    TwoDLocation
garciay's avatar
garciay committed
             */
            template (value) TwoDLocation m_twoDLocation(
                                                         in template (value) WGSLatitude p_latitude,
                                                         in template (value) WGSLongitude p_longitude
garciay's avatar
garciay committed
            ) := {
                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.14 Clause 4.2.20    ThreeDLocation
garciay's avatar
garciay committed
             */
            template (value) ThreeDLocation m_threeDLocation(
                                                             in template (value) WGSLatitude p_latitude,
                                                             in template (value) WGSLongitude p_longitude,
garciay's avatar
garciay committed
                                                             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.14 Clause 4.2.21  GeographicRegion
garciay's avatar
garciay committed
             */
            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 Send template rectangular geographic region
garciay's avatar
garciay committed
             * @param p_northwest  Upper left corner 
             * @param p_southeast  Lower rigth corner
             * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.21  GeographicRegion
garciay's avatar
garciay committed
             */
            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.14 Clause 4.2.21  GeographicRegion
garciay's avatar
garciay committed
             */
            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.14 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.14 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
        } // End of group basicFormatElementsSend 
garciay's avatar
garciay committed
        
        /**
         * @desc Receive templates for security headers
         * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2    Specification of basic format elements
garciay's avatar
garciay committed
         */
        group basicFormatElementsRecv {
            /**
             * @desc Receive templates for security algorithm descriptions
             */
            group algorithms {
                
                /**
                 * @desc Receive template for EccPoint description based on x_coordinate_only type
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.14 Table 2: Derivation of field sizes depending on the used algorithm
                 */
                template (present) EccPoint mw_eccPointecdsa_nistp256_with_sha256_x_coordinate_only(
                                                                                                    in template (present) octetstring p_x := ?
                ) := { 
                    type_           := e_x_coordinate_only,
                    x               := p_x,
                    y               := omit
                } // End of template mw_eccPointecdsa_nistp256_with_sha256_x_coordinate_only
                
                /**
                 * @desc Receive template for EccPoint description based on y_coordinate_only type
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.14 Table 2: Derivation of field sizes depending on the used algorithm
                 */
                template (present) EccPoint mw_eccPointecdsa_nistp256_with_sha256_y0_coordinate_only(
                                                                                                     in template (present) octetstring p_x := ? 
                ) := { 
                    type_           := e_compressed_lsb_y_0,
                    x               := p_x,
                    y               := omit
                } // End of template mw_eccPointecdsa_nistp256_with_sha256_y0_coordinate_only
                
                /**
                 * @desc Receive template for EccPoint description based on y_coordinate_only type
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.14 Table 2: Derivation of field sizes depending on the used algorithm
                 */
                template (present) EccPoint mw_eccPointecdsa_nistp256_with_sha256_y1_coordinate_only(
                                                                                                     in template (present) octetstring p_x := ? 
                ) := { 
                    type_           := e_compressed_lsb_y_1,
                    x               := p_x,
                    y               := omit
                } // End of template mw_eccPointecdsa_nistp256_with_sha256_y1_coordinate_only
                
                /**
                 * @desc Receive template for EccPoint description based on uncompressed type
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.5   EccPoint
                 * @see Draft ETSI TS 103 097 V1.1.14 Table 2: Derivation of field sizes depending on the used algorithm
                 */
                template (present) EccPoint mw_eccPointecdsa_nistp256_with_sha256_uncompressed(
                                                                                               in template (present) octetstring p_x := ?,
                                                                                               in template (present) octetstring p_y := ?
                ) := { 
                    type_           := e_uncompressed,
                    x               := p_x,
                    y               := {
garciay's avatar
garciay committed
                        y := p_y
                    }
                } // End of template mw_eccPointecdsa_nistp256_with_sha256_uncompressed
                
            } // End of group algorithms
            
            group signerInfos {
                
                /**
                 * @desc Recv template for message signed with digest 
                 */
                template (present) SignerInfo mw_signerInfo_digest(
                                                                   in template (present) HashedId8 p_digest  := ?
                    type_         := e_certificate_digest_with_sha256,
                    signerInfo    := {
                        digest := p_digest
                    } // End of field signerInfo 
                } // End of template mw_signerInfo_digest
                
                template (present) SignerInfo mw_signerInfo_certificate(
                                                                        in template (present) Certificate p_certificate  := ?
                ) := {
                    type_         := e_certificate,
                    signerInfo    := {
                        certificate := p_certificate
                    } // End of field signerInfo 
                } // End of template m_signerInfo_certificate
                
                template (present) SignerInfo mw_signerInfo_certificates(
                                                                         in template (present) CertificateChain p_certificates := ?
                ) := {
                    type_         := e_certificate_chain,
                    signerInfo    := {
                        certificates := p_certificates
                    } // End of field signerInfo
garciay's avatar
garciay committed
                } // End of template mw_signerInfo_certificates
                
            } // End of group signerInfos
            
            
            /**
             * @desc Receive templates for Signature description
             * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.9   Signature
             * @see Draft ETSI TS 103 097 V1.1.14 Table 2: Derivation of field sizes depending on the used algorithm
             */
            group signatures {
                
                /**
                 * @desc Receive template for signatures based on ECDSA algorithm
                 * @member p_ecdsaSignature The ECDSA based signature
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.9   Signature
                 */
                template (present) Signature mw_signature(
                                                          in template (present) EcdsaSignature p_ecdsaSignature := ?
                ):= {
                    algorithm   := e_ecdsa_nistp256_with_sha256,
                    signature_  := {
                        ecdsa_signature := p_ecdsaSignature
                    } // End of field signature_
                } // End of template mw_signature
                
                /**
                 * @desc Receive template for ECDSA based signature
                 * @member p_r          The coordinate of the elliptic curve point resulting from multiplying the generator element by the ephemeral private key
                 * @member p_s          The signature
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.10   EcdsaSignature
                 */
                template (present) EcdsaSignature mw_ecdsaSignature(
                                                                    in template (present) EccPoint p_r := ?,
                                                                    in template (present) octetstring p_s := ?
                ) := {
                    r           := p_r,
                    s           := p_s
                } // End of template mw_ecdsaSignature
                
            } // End of group signatures 
            
garciay's avatar
garciay committed
            /**
             * @desc Receive template for Time64WithStandardDeviation
             * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.17    Time64WithStandardDeviation
garciay's avatar
garciay committed
             */
            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 Receive template for Duration (in seconds)
             * @param p_duration    The duration value
             * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.18  Duration
             */
            template (present) Duration mw_duration_in_seconds(
                                                               in template (present) Int13 p_duration
            ) := {
                unit        := e_seconds,
garciay's avatar
garciay committed
                duration_   := p_duration
            } // End of template mw_duration_in_seconds
            
garciay's avatar
garciay committed
            /**
             * @desc Receive template for TwoDLocation
garciay's avatar
garciay committed
             * @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.14 Clause 4.2.19    TwoDLocation
garciay's avatar
garciay committed
             */
            template (present) TwoDLocation mw_twoDLocation(
                                                            in template (present) WGSLatitude p_latitude,
                                                            in template (present) WGSLongitude p_longitude
garciay's avatar
garciay committed
            ) := {
                latitude    := p_latitude,
                longitude   := p_longitude
            } // End of template mw_twoDLocation
            
            /**
             * @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.14 Clause 4.2.20    ThreeDLocation
garciay's avatar
garciay committed
             */
            template (present) ThreeDLocation mw_threeDLocation(
                                                                in template (present) WGSLatitude p_latitude,
                                                                in template (present) WGSLongitude p_longitude,
garciay's avatar
garciay committed
                                                                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.14 Clause 4.2.21  GeographicRegion
garciay's avatar
garciay committed
             */
            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.14 Clause 4.2.21  GeographicRegion
            template (present) GeographicRegion mw_geographicRegion_rectangular(
                                                                                in template (present) TwoDLocation p_northwest := ?,
                                                                                in template (present) TwoDLocation p_southeast := ?
            ) := {
                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_rectangular
garciay's avatar
garciay committed
            /**
             * @desc Receive template polygonial geographic region
             * @param p_polygonal_region  Polygonial region description
             * @see Draft ETSI TS 103 097 V1.1.14 Clause 4.2.21  GeographicRegion
garciay's avatar
garciay committed
             */
            template (present) GeographicRegion mw_geographicRegion_polygonal(
                                                                              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.14 Clause 4.2.21  GeographicRegion
            template (present) GeographicRegion mw_geographicRegion_identified(
                                                                               in template (present) IdentifiedRegion p_id_region := ?
garciay's avatar
garciay committed
            ) := {
                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.14 Clause 4.2.21  GeographicRegion
filatov's avatar
filatov committed
            template (present) GeographicRegion mw_geographicRegion_none := {
garciay's avatar
garciay committed
                region_type := e_none,
                region := omit
garciay's avatar
garciay committed
            } // End of template mw_geographicRegion_nonce
filatov's avatar
filatov committed

            template (present) IdentifiedRegion mw_identifiedRegion_iso3166_any
            := {
                region_dictionary := e_iso_3166_1,
                region_identifier := (all from c_iso3166Codes),
                local_region := ?
            }
            template (present) IdentifiedRegion mw_identifiedRegion_un_stats_any
            := {
                region_dictionary := e_un_stats,
                region_identifier := ((all from c_iso3166Codes), (all from c_unStatsAdditionalCodes)),
                local_region := ?
            }
            
        } // End of group basicFormatElementsRecv
garciay's avatar
garciay committed
        
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.14 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.14 Clause 5   Specification of security header
         */
        group dummyMessagesSend {
            
garciay's avatar
garciay committed
            /**
             * @desc Generic send template for Security profile for other messages
             * @see Draft ETSI TS 103 097 V1.1.14 Clause 7.3    Generic security profile for other signed messages
garciay's avatar
garciay committed
             */
            template (value) SecuredMessage m_secureMessage_dummy := {
garciay's avatar
garciay committed
                protocol_version     := c_protocol_version,
                header_fields        := { 
                    m_header_field_signer_info(
                        m_signerInfo_self
                payload_field        := m_payload_signed_external,
                trailer_fields       := { }
            } // End of template m_secureMessage_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.14 Clause 5   Specification of security header
garciay's avatar
garciay committed
        group dummyMessagesRecv {
            
            /**
             * @desc Generic received template for SecuredMessage
             */
            template (present) SecuredMessage mdw_securedMessage_dummy := {
                protocol_version    := c_protocol_version, 
garciay's avatar
garciay committed
                header_fields       := ?,
garciay's avatar
garciay committed
                trailer_fields      := ?
            } // End of template mdw_securedMessage_dummy
        } // End of group dummyMessagesRecv 
        
        group dummyPayloads {
            
garciay's avatar
garciay committed
            /**
             * @desc Generic received template for unsecured payload
garciay's avatar
garciay committed
             */
            template (present) SecPayload mw_unsecuredPayload_dummy := {
garciay's avatar
garciay committed
                type_   := e_unsecured, 
                data    := ?
garciay's avatar
garciay committed
            } // End of template mw_unsecuredPayload_dummy
            
             * @desc Generic received template for SecuredMessage
            template (present) SecPayload mw_signedPayload_dummy := {
                type_   := e_signed, 
            } // End of template mw_signedPayload_dummy
            
        } // End of group payloads
        
        group dummyEciesEncryptedKey {
            
            group dummyEciesEncryptedKeyRecv {
                
                /**
                 * @desc Basic receive template for an ECIES-encrypted symmetric key as defined in IEEE Std 1363a 2004 
                 * @see Draft ETSI TS 103 097 V1.1.14 Clause 5.9 EciesEncryptedKey
                 */
                template (present) EciesEncryptedKey mw_eciesEncryptedKey_dummy := {
                    v               := ?,
                    c               := ?,
                    t               := ?
                } // End of template mw_eciesEncryptedKey_dummy
                
            } // End of group dummyEciesEncryptedKeyRecv
            
        } // End of group dummyEciesEncryptedKey
        
    } // End of group dummyMessages
    
    /**
     * @desc Send/receive templates for security headers
     * @see Draft ETSI TS 103 097 V1.1.14 Clause 5   Specification of security header
     */
    group messages {
        
        /**
         * @desc Send templates for security headers
         * @see Draft ETSI TS 103 097 V1.1.14 Clause 5   Specification of security header
berge's avatar
berge committed
             * @desc Generic send template for secured message
            template (value) SecuredMessage m_securedMessage(
                                                             in template (value) HeaderFields p_header_fields,
                                                             in template (value) SecPayload p_payload_field,
                                                             in template (value) TrailerFields p_trailer_fields
            ) := {
                protocol_version    := c_protocol_version,
                header_fields       := p_header_fields,
                payload_field       := p_payload_field,
                trailer_fields      := p_trailer_fields
            } // End of template m_securedMessage
garciay's avatar
garciay committed
            
            /**
             * @desc Generic send template for secured message
             */
            template (value) SecuredMessage m_securedMessage_wrong_protocol(
                                                                            in template (value) UInt8 p_protocol_version := c_protocol_version,
                                                                            in template (value) HeaderFields p_header_fields,
                                                                            in template (value) SecPayload p_payload_field,
                                                                            in template (value) TrailerFields p_trailer_fields
            ) := {
                protocol_version    := p_protocol_version,
                header_fields       := p_header_fields,
                payload_field       := p_payload_field,
                trailer_fields      := p_trailer_fields
            } // End of template m_securedMessage
            
        } // End of group messagesSend
        
        /**
         * @desc Receive templates for security headers
         * @see Draft ETSI TS 103 097 V1.1.14 Clause 5   Specification of security header
berge's avatar
berge committed

            /**
             * @desc Generic received template for SecuredMessage
             */
            template (present) SecuredMessage mdw_securedMessage(
                                                                 in template (present) HeaderFields p_header := ?,
                                                                 in template (present) SecPayload p_payload := ?, 
                                                                 in template (present) TrailerFields p_trailer := ? 
            ) modifies mdw_securedMessage_dummy := {
berge's avatar
berge committed
                header_fields       := p_header,
                payload_field       := p_payload,
berge's avatar
berge committed
                trailer_fields      := p_trailer
            } // End of template mdw_securedMessage