Skip to content
LibItsSecurity_Templates.ttcn3 56.5 KiB
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
Loading full blame...