Commit 4caae706 authored by garciay's avatar garciay
Browse files

Implement external functions

parent 29e91bcd
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -156,7 +156,7 @@ module LibItsSecurity_Functions {
         * @param   p_toBeHashedData Data to be used to calculate the hash value
         * @param   p_toBeHashedData Data to be used to calculate the hash value
         * @return  The hash value
         * @return  The hash value
         */
         */
        external function fx_hashWithSha256(in octetstring p_toBeHashedData) return Oct32;
        external function fx_hashWithSha256(in octetstring p_toBeHashedData) return octetstring;
        
        
        /**
        /**
         * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signaturee
         * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signaturee
@@ -164,7 +164,7 @@ module LibItsSecurity_Functions {
         * @param   p_privateKey        The private key
         * @param   p_privateKey        The private key
         * @return  The signature value
         * @return  The signature value
         */
         */
        external function fx_signWithEcdsaNistp256WithSha256(in octetstring p_toBeSignedData, in UInt64 p_privateKey) return octetstring;
        external function fx_signWithEcdsaNistp256WithSha256(in octetstring p_toBeSignedData, in octetstring/*UInt64*/ p_privateKey) return octetstring;
        
        
        /**
        /**
         * @desc    Verify the signature of the specified data
         * @desc    Verify the signature of the specified data
@@ -174,7 +174,7 @@ module LibItsSecurity_Functions {
         * @param   p_ecdsaNistp256PublicKeyY   The public key (y coordinate)
         * @param   p_ecdsaNistp256PublicKeyY   The public key (y coordinate)
         * @return  true on success, false otherwise
         * @return  true on success, false otherwise
         */
         */
        external function fx_verifyWithEcdsaNistp256WithSha256(in octetstring p_toBeVerifiedData, in octetstring p_signature, in Oct32 p_ecdsaNistp256PublicKeyX, in Oct32 p_ecdsaNistp256PublicKeyY) return boolean;
        external function fx_verifyWithEcdsaNistp256WithSha256(in octetstring p_toBeVerifiedData, in octetstring p_signature, in octetstring p_ecdsaNistp256PublicKeyX, in octetstring p_ecdsaNistp256PublicKeyY) return boolean;
        
        
        /**
        /**
         * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm
         * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm
@@ -183,7 +183,7 @@ module LibItsSecurity_Functions {
         * @param   p_publicKeyX    The new public key value (y coordinate)
         * @param   p_publicKeyX    The new public key value (y coordinate)
         * @return  true on success, false otherwise
         * @return  true on success, false otherwise
         */
         */
        external function fx_generateKeyPair(out UInt64 p_privateKey, out UInt64 p_publicKeyX, out UInt64 p_publicKeyY) return boolean;
        external function fx_generateKeyPair(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean;
        
        
    } // End of group externalFunctions
    } // End of group externalFunctions
    
    
+9 −0
Original line number Original line Diff line number Diff line
@@ -8,6 +8,10 @@
module LibItsSecurity_Pixits {
module LibItsSecurity_Pixits {
    
    
    // LibCommon
    // LibCommon
    import from LibCommon_DataStrings {
        type 
            Oct0to12        
    }
    
    
    // LibItsSecurity
    // LibItsSecurity
    import from LibItsSecurity_TypesAndValues {
    import from LibItsSecurity_TypesAndValues {
@@ -44,4 +48,9 @@ module LibItsSecurity_Pixits {
     */
     */
    modulepar HashedId8 PX_ECDSA_DIGEST := '0102030405060708'O;
    modulepar HashedId8 PX_ECDSA_DIGEST := '0102030405060708'O;
    
    
    /**
     * @desc 
     */
    modulepar Oct0to12 PX_AESCCM_NONCE  := '010203040506070808080808'O;
    
} // End of module LibItsSecurity_Pixits
} // End of module LibItsSecurity_Pixits
 No newline at end of file
+263 −74
Original line number Original line Diff line number Diff line
@@ -10,7 +10,12 @@ module LibItsSecurity_Templates {
    // LibCommon
    // LibCommon
    import from LibCommon_BasicTypesAndValues {
    import from LibCommon_BasicTypesAndValues {
        type 
        type 
          UInt8
            UInt8, 
            Int32        
    }
    import from LibCommon_DataStrings {
        type 
            Oct2        
    }
    }
    
    
    // LibItsSecurity
    // LibItsSecurity
@@ -114,6 +119,17 @@ module LibItsSecurity_Templates {
                    } // End of field y
                    } // End of field y
                } // End of template m_aesccm_dummy
                } // End of template m_aesccm_dummy
                				
                				
                /**
                 * @desc Generic send template for AES CCM encryption parameters
                 * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.7	EncryptionParameters
                 */
				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
            } // End of group algorithms
            
            
            /**
            /**
@@ -123,13 +139,16 @@ module LibItsSecurity_Templates {
             */
             */
            group signatures {
            group signatures {
                
                
                template (value) Signature m_signature_ecdsa := {
                template (value) Signature m_signature(
                                                       in template (value) EcdsaSignature p_ecdsaSignature
                ):= {
                    algorithm   := e_ecdsa_nistp256_with_sha256,
                    algorithm   := e_ecdsa_nistp256_with_sha256,
                    signature_  := {
                    signature_  := {
                        ecdsa_signature := m_ecdsaSignature
                        ecdsa_signature := p_ecdsaSignature
                    } // End of field signature_
                    } // End of field signature_
                } // End of template m_signature_ecdsa
                } // End of template m_signature_ecdsa


                
                template (value) EcdsaSignature m_ecdsaSignature := {
                template (value) EcdsaSignature m_ecdsaSignature := {
                    algorithm   := e_ecdsa_nistp256_with_sha256,
                    algorithm   := e_ecdsa_nistp256_with_sha256,
                    field_size  := f_int2UInt8(1 + lengthof(PX_ECDSA_S)),
                    field_size  := f_int2UInt8(1 + lengthof(PX_ECDSA_S)),
@@ -139,6 +158,48 @@ module LibItsSecurity_Templates {
                
                
            } // End of group signatures 
            } // 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
            
            /**
            /**
             * @desc Dummy send template for PublicKey/EccPoint
             * @desc Dummy send template for PublicKey/EccPoint
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.4    PublicKey
             * @see Draft ETSI TS 103 097 V1.1.6 Clause 4.2.4    PublicKey
@@ -164,6 +225,51 @@ module LibItsSecurity_Templates {
                } // End of field public_key
                } // End of field public_key
            } // End of template m_publicKey_aesccm_dummy
            } // End of template m_publicKey_aesccm_dummy
            
            
            /**
             * @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
            
        } // End of group dummyBasicFormatElementsSend 
        } // End of group dummyBasicFormatElementsSend 
        
        
        /**
        /**
@@ -194,6 +300,82 @@ module LibItsSecurity_Templates {
                } // End of field public_key
                } // End of field public_key
            } // End of template m_publicKey_aesccm_dummy
            } // End of template m_publicKey_aesccm_dummy
            
            
            /**
             * @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
            
        } // End of group dummyBasicFormatElementsRecv
        } // End of group dummyBasicFormatElementsRecv
        
        
    } // End of group dummyBasicFormatElements 
    } // End of group dummyBasicFormatElements 
@@ -222,15 +404,45 @@ module LibItsSecurity_Templates {
                trailer_fields        := { }
                trailer_fields        := { }
            } // End of template m_secureMessageCAMs_dummy
            } // End of template m_secureMessageCAMs_dummy
            
            
            /**
             * @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_signerInfo_dummy },
                payload_fields        := { },
                trailer_fields        := { }
            } // End of template m_secureMessageDENMs_dummy
            
            /**
             * @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_signerInfo_dummy },
                payload_fields        := { },
                trailer_fields        := { }
            } // End of template m_secureMessageCAMs_dummy
            
            group headerFields {
                
                template (value) HeaderField m_header_field_signerInfo_dummy := {
                template (value) HeaderField m_header_field_signerInfo_dummy := {
                    type_       := e_signer_info,
                    type_       := e_signer_info,
                    headerField := m_header_field_container_dummy
                    headerField := m_header_field_container_dummy
                } // End of template m_header_field_signerInfo_dummy
                } // End of template m_header_field_signerInfo_dummy
                
                
                template (value) HeaderFieldContainer m_header_field_container_dummy := {
                template (value) HeaderFieldContainer m_header_field_container_dummy := {
                other_header := ''O
                    signer := m_SignerInfo_self
                } // End of template m_header_field_container_dummy
                } // End of template m_header_field_container_dummy
            
            
            } // End of group headerFields
            
            group payloads {
                
                template (value) Payload m_payload_signed_dummy := {
                template (value) Payload m_payload_signed_dummy := {
                    type_   := e_signed,
                    type_   := e_signed,
                    data    := m_data_payload_dummy
                    data    := m_data_payload_dummy
@@ -245,6 +457,10 @@ module LibItsSecurity_Templates {
                    rawPayload := ''O
                    rawPayload := ''O
                } // End of template m_data_payload_dummy
                } // End of template m_data_payload_dummy
                
                
            } // End of group payloads
            
            group trailerFields {
                
                template (value) TrailerField m_trailer_field_dummy := {
                template (value) TrailerField m_trailer_field_dummy := {
                    type_           := e_signature,
                    type_           := e_signature,
                    trailerField    := m_trailer_field_container_dummy
                    trailerField    := m_trailer_field_container_dummy
@@ -254,6 +470,8 @@ module LibItsSecurity_Templates {
                    security_field := ''O
                    security_field := ''O
                } // End of template m_trailer_field_container_dummy
                } // End of template m_trailer_field_container_dummy
                
                
            } // End of group trailerFields
            
        } // End of group dummyMessagesSend
        } // End of group dummyMessagesSend
        
        
        /**
        /**
@@ -312,16 +530,16 @@ module LibItsSecurity_Templates {
            template (value) Certificate m_certificate_dummy := {
            template (value) Certificate m_certificate_dummy := {
                version                 := c_certificate_version,
                version                 := c_certificate_version,
                signer_info             := { 
                signer_info             := { 
                    m_signerInfo_ecdsa256(
                    m_SignerInfo_digest(
                        m_signerInfoContainer_digest(
                        PX_ECDSA_DIGEST
                        PX_ECDSA_DIGEST
                    )
                    )
                    )
                }, // End of field signer_info
                },
                subject_info            := m_subject_info_dummy,
                subject_info            := m_subject_info_dummy,
                subject_attributes      := { m_subject_attribute_dummy },
                subject_attributes      := { m_subject_attribute_dummy },
                validity_restrictions   := { m_validity_restriction_dummy },
                validity_restrictions   := { m_validity_restriction_dummy },
                signature_              := m_signature_ecdsa
                signature_              := m_signature(
                    m_ecdsaSignature
                ) // End of field signature_ 
            } // End of template m_certificate_dummy
            } // End of template m_certificate_dummy
            
            
            template (value) SubjectInfo m_subject_info_dummy := {
            template (value) SubjectInfo m_subject_info_dummy := {
@@ -394,42 +612,13 @@ module LibItsSecurity_Templates {
                    trailer_fields      := p_trailer_fields
                    trailer_fields      := p_trailer_fields
                } // End of template md_secureMessageCAMs
                } // End of template md_secureMessageCAMs
                
                
                template (value) HeaderField m_header_field_signerInfo_ecdsa256(
                template (value) HeaderField m_header_field_signerInfo_ecdsa(
                                                                                in template (value) SignerInfoContainer p_signerInfo
                                                                                in template (value) SignerInfo p_signerInfo
                ) modifies m_header_field_signerInfo_dummy := {
                ) modifies m_header_field_signerInfo_dummy := {
                    headerField := m_header_field_container_ecdsa256(p_signerInfo)
                    headerField := {
                } // End of template m_header_field_signerInfo_ecdsa256
                        signer := p_signerInfo
                
                    }
                template (value) HeaderFieldContainer m_header_field_container_ecdsa256(
                } // End of template m_header_field_signerInfo_ecdsa
                                                                                        in template (value) SignerInfoContainer p_signerInfo
                ) := {
                    signer := m_signerInfo_ecdsa256(p_signerInfo)
                } // End of template m_header_field_container_ecdsa256
                
                template (value) SignerInfo m_signerInfo_ecdsa256(
                                                                  in template (value) SignerInfoContainer p_signerInfo
                ) := {
                    type_       := e_certificate_digest_with_ecdsap256,
                    signerInfo  := p_signerInfo 
                } // End of template m_signerInfo_ecdsa256
                
                template (value) SignerInfoContainer m_signerInfoContainer_certificate(
                                                                                       in template (value) Certificate p_certificate
                ) := {
                    certificate := p_certificate
                } // End of template m_signerInfoContainer_certificate
                
                template (value) SignerInfoContainer m_signerInfoContainer_certificates(
                                                                                        in template (value) CertificateChain p_certificates
                ) := {
                    certificates := p_certificates
                } // End of template m_signerInfoContainer_certificates
                
                template (value) SignerInfoContainer m_signerInfoContainer_digest(
                                                                                  in template (value) HashedId8 p_digest
                ) := {
                    digest := p_digest
                } // End of template m_signerInfoContainer_digest
                
                
            } // End of group securityProfilesCAMsSend
            } // End of group securityProfilesCAMsSend
            
            
+5 −0
Original line number Original line Diff line number Diff line
@@ -431,6 +431,10 @@ module LibItsSecurity_TypesAndValues {
        
        
        type set of HeaderField HeaderFields;
        type set of HeaderField HeaderFields;
        
        
		/**
		 * @desc Information of interest to the security layer
		 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.4	HeaderField
		 */
        type record HeaderField {
        type record HeaderField {
            HeaderFieldType         type_,
            HeaderFieldType         type_,
            HeaderFieldContainer    headerField
            HeaderFieldContainer    headerField
@@ -438,6 +442,7 @@ module LibItsSecurity_TypesAndValues {
        
        
        /**
        /**
         * @desc Supported types of header fields
         * @desc Supported types of header fields
		 * @see Draft ETSI TS 103 097 V1.1.6 Clause 5.5	HeaderFieldType
         */
         */
        type enumerated HeaderFieldType {
        type enumerated HeaderFieldType {
            e_generation_time                       (0),
            e_generation_time                       (0),