Commit ef0c952b authored by garciay's avatar garciay
Browse files

Add Brainpool Security support

parent d18229fc
Loading
Loading
Loading
Loading
+8 −34
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@ module LibItsSecurity_EncdecDeclarations {
    
    
    external function fx_dec_CertificateBase(inout bitstring b, out IEEE1609dot2.CertificateBase p) return integer
    external function fx_dec_CertificateBase(inout bitstring b, out IEEE1609dot2.CertificateBase p) return integer
        with {extension "prototype(sliding) decode(PER)"}
        with {extension "prototype(sliding) decode(PER)"}
    
    /**
    /**
     * @desc Encoding function for IEEE1609dot2.ToBeSignedCertificate
     * @desc Encoding function for IEEE1609dot2.ToBeSignedCertificate
     * @param p The ToBeSign part of the certificate
     * @param p The ToBeSign part of the certificate
@@ -33,46 +34,19 @@ module LibItsSecurity_EncdecDeclarations {
    external function fx_enc_Ieee1609Dot2Data(in IEEE1609dot2.Ieee1609Dot2Data p) return bitstring
    external function fx_enc_Ieee1609Dot2Data(in IEEE1609dot2.Ieee1609Dot2Data p) return bitstring
    with {extension "prototype(convert) encode(PER)"}
    with {extension "prototype(convert) encode(PER)"}


    external function fx_dec_Ieee1609Dot2Data(inout bitstring p_data, out IEEE1609dot2.Ieee1609Dot2Data p_ieee1609Dot2Data) return integer
        with {extension "prototype(sliding) decode(PER)"}
    
    
    
    external function fx_enc_SspCAM (LibItsSecurity_TypesAndValues.SspCAM p_ssp) return bitstring
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    //encoding functions
/*    external function fx_enc_SecuredMessage (LibItsSecurity_TypesAndValues.SecuredMessage p) return bitstring
        with {extension "prototype(convert) encode(LibItsSecurity)"}
    
    external function fx_enc_ToBeSignedSecuredMessage (LibItsSecurity_TypesAndValues.ToBeSignedSecuredMessage p) return bitstring
        with {extension "prototype(convert) encode(LibItsSecurity)"}
    
    external function fx_enc_Certificate (LibItsSecurity_TypesAndValues.Certificate p) return bitstring
        with {extension "prototype(convert) encode(LibItsSecurity)"}
    
    external function fx_enc_ToBeSignedCertificate_ (LibItsSecurity_TypesAndValues.ToBeSignedCertificate p) return bitstring
        with {extension "prototype(convert) encode(LibItsSecurity)"}
        with {extension "prototype(convert) encode(LibItsSecurity)"}
    
    
    //decoding functions
    external function fx_dec_SspCAM (inout bitstring p_data, out LibItsSecurity_TypesAndValues.SspCAM p_ssp) return integer
    external function fx_dec_SecuredMessage (inout bitstring b, out LibItsSecurity_TypesAndValues.SecuredMessage p) return integer
        with {extension "prototype(sliding) decode(LibItsSecurity)"}
        with {extension "prototype(sliding) decode(LibItsSecurity)"}
    
    
    external function fx_dec_ToBeSignedSecuredMessage (inout bitstring b, out LibItsSecurity_TypesAndValues.ToBeSignedSecuredMessage p) return integer
    external function fx_enc_SspDENM (LibItsSecurity_TypesAndValues.SspDENM p_ssp) return bitstring
        with {extension "prototype(sliding) decode(LibItsSecurity)"}
        with {extension "prototype(convert) encode(LibItsSecurity)"}
    
    
    external function fx_dec_Certificate (inout bitstring b, out LibItsSecurity_TypesAndValues.Certificate p) return integer
    external function fx_dec_SspDENM (inout bitstring p_data, out LibItsSecurity_TypesAndValues.SspDENM p_ssp) return integer
        with {extension "prototype(sliding) decode(LibItsSecurity)"}
        with {extension "prototype(sliding) decode(LibItsSecurity)"}
    
    
    external function fx_dec_ToBeSignedCertificate (inout bitstring b, out LibItsSecurity_TypesAndValues.ToBeSignedCertificate p) return integer
        with {extension "prototype(sliding) decode(LibItsSecurity)"}*/
    
} // End of module LibItsSecurity_EncdecDeclarations 
} // End of module LibItsSecurity_EncdecDeclarations 
+93 −9
Original line number Original line Diff line number Diff line
@@ -55,7 +55,7 @@ module LibItsSecurity_Functions {
        } // End of function f_hashWithSha256
        } // End of function f_hashWithSha256
        
        
        /**
        /**
         * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signaturee
         * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
         * @param   p_toBeSignedSecuredMessage    The data to be signed
         * @param   p_toBeSignedSecuredMessage    The data to be signed
         * @return  The signature value
         * @return  The signature value
         */
         */
@@ -70,6 +70,22 @@ module LibItsSecurity_Functions {
            
            
        } // End of function f_signWithEcdsaNistp256WithSha256
        } // End of function f_signWithEcdsaNistp256WithSha256
        
        
        /**
         * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
         * @param   p_toBeSignedSecuredMessage    The data to be signed
         * @return  The signature value
         */
        function f_signWithEcdsaBrainpoolp256WithSha256(
                                                        in octetstring p_toBeSignedSecuredMessage,
                                                        in Oct32 p_privateKey
        ) runs on ItsSecurityBaseComponent return octetstring {
            return fx_signWithEcdsaBrainpoolp256WithSha256(
                p_toBeSignedSecuredMessage,
                p_privateKey
            );
            
        } // End of function f_signWithEcdsaBrainpoolp256WithSha256
        
        /**
        /**
         * @desc Compute the HashedId8 value from the hash value
         * @desc Compute the HashedId8 value from the hash value
         * @param p_hash The hash value
         * @param p_hash The hash value
@@ -128,12 +144,44 @@ 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
         */
         */
        function f_generate_key_pair(
        function f_generate_key_pair_nistp256(
                                              out octetstring p_privateKey,
                                              out octetstring p_publicKeyX,
                                              out octetstring p_publicKeyY
                                             ) return boolean {
          return fx_generateKeyPair_nistp256(p_privateKey, p_publicKeyX, p_publicKeyY);
        }
        
        /**
         * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
         *          This function should not be used by the ATS
         * @param   p_privateKey    The new private key value
         * @param   p_publicKeyX    The new public key value (x coordinate)
         * @param   p_publicKeyX    The new public key value (y coordinate)
         * @return  true on success, false otherwise
         */
        function f_generate_key_pair_brainpoolp256(
                                                   out octetstring p_privateKey,
                                                   out octetstring p_publicKeyX,
                                                   out octetstring p_publicKeyY
                                                  ) return boolean {
          return fx_generateKeyPair_brainpoolp256(p_privateKey, p_publicKeyX, p_publicKeyY);
        }
        
        /**
         * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
         *          This function should not be used by the ATS
         * @param   p_privateKey    The new private key value
         * @param   p_publicKeyX    The new public key value (x coordinate)
         * @param   p_publicKeyX    The new public key value (y coordinate)
         * @return  true on success, false otherwise
         */
        function f_generate_key_pair_brainpoolp384(
                                                   out octetstring p_privateKey,
                                                   out octetstring p_privateKey,
                                                   out octetstring p_publicKeyX,
                                                   out octetstring p_publicKeyX,
                                                   out octetstring p_publicKeyY
                                                   out octetstring p_publicKeyY
                                                  ) return boolean {
                                                  ) return boolean {
          return fx_generateKeyPair(p_privateKey, p_publicKeyX, p_publicKeyY);
          return fx_generateKeyPair_brainpoolp384(p_privateKey, p_publicKeyX, p_publicKeyY);
        }
        }
        
        
        /**
        /**
@@ -1441,13 +1489,29 @@ module LibItsSecurity_Functions {
            external function fx_hashWithSha384(in octetstring p_toBeHashedData) return Oct48;
            external function fx_hashWithSha384(in octetstring p_toBeHashedData) return Oct48;
            
            
            /**
            /**
             * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signaturee
             * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
             * @param   p_toBeSignedSecuredMessage    The data to be signed
             * @param   p_toBeSignedSecuredMessage    The data to be signed
             * @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_toBeSignedSecuredMessage, in octetstring/*UInt64*/ p_privateKey) return octetstring;
            external function fx_signWithEcdsaNistp256WithSha256(in octetstring p_toBeSignedSecuredMessage, in octetstring/*UInt64*/ p_privateKey) return octetstring;


            /**
             * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
             * @param   p_toBeSignedSecuredMessage    The data to be signed
             * @param   p_privateKey        The private key
             * @return  The signature value
             */
            external function fx_signWithEcdsaBrainpoolp256WithSha256(in octetstring p_toBeSignedSecuredMessage, in octetstring/*UInt64*/ p_privateKey) return octetstring;
            
            /**
             * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signature
             * @param   p_toBeSignedSecuredMessage    The data to be signed
             * @param   p_privateKey        The private key
             * @return  The signature value
             */
            external function fx_signWithEcdsaBrainpoolp384WithSha384(in octetstring p_toBeSignedSecuredMessage, in octetstring/*UInt64*/ p_privateKey) return octetstring;
            
            /**
            /**
             * @desc    Verify the signature of the specified data
             * @desc    Verify the signature of the specified data
             * @param   p_toBeVerifiedData          The data to be verified
             * @param   p_toBeVerifiedData          The data to be verified
@@ -1466,7 +1530,27 @@ 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 octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean;
            external function fx_generateKeyPair_nistp256(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean;
            
            /**
             * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
             *          This function should not be used by the ATS
             * @param   p_privateKey    The new private key value
             * @param   p_publicKeyX    The new public key value (x coordinate)
             * @param   p_publicKeyX    The new public key value (y coordinate)
             * @return  true on success, false otherwise
             */
            external function fx_generateKeyPair_brainpoolp256(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean;
            
            /**
             * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
             *          This function should not be used by the ATS
             * @param   p_privateKey    The new private key value
             * @param   p_publicKeyX    The new public key value (x coordinate)
             * @param   p_publicKeyX    The new public key value (y coordinate)
             * @return  true on success, false otherwise
             */
            external function fx_generateKeyPair_brainpoolp384(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean;
            
            
        } // End of group signing
        } // End of group signing
        
        
+19 −82
Original line number Original line Diff line number Diff line
@@ -1278,21 +1278,7 @@ module LibItsSecurity_Templates {
        
        
    } // End of group validityRestriction
    } // End of group validityRestriction
    
    
    group ssp {/*
    group ssp {
        
        group sspTest {
            
            template (present) ServiceSpecificPermissions m_sspTest := {
                version         := '00'O,
                sspContainer    := omit
            } // End of template mw_sspTest
            
            template (present) ServiceSpecificPermissions mw_sspTest := {
                version         := '00'O,
                sspContainer    := *
            } // End of template mw_sspTest
            
        } // End of group sspTest 
        
        
        group sspCam {
        group sspCam {
                
                
@@ -1313,8 +1299,7 @@ module LibItsSecurity_Templates {
                    noPassing                               := '1'B,
                    noPassing                               := '1'B,
                    noPassingForTrucks                      := '1'B,
                    noPassingForTrucks                      := '1'B,
                    speedLimit                              := '1'B,
                    speedLimit                              := '1'B,
                    reserved1                               := '0'B,
                    reserved                                := '000000000000000000'B
                    reserved2                               := '0'B
                } // End of template m_sspCAMContainer_sign_all
                } // End of template m_sspCAMContainer_sign_all
                
                
                template (value) SspCAM m_sspCAMContainer_vehicle 
                template (value) SspCAM m_sspCAMContainer_vehicle 
@@ -1326,19 +1311,11 @@ module LibItsSecurity_Templates {
                    speedLimit                              := '0'B
                    speedLimit                              := '0'B
                } // End of template m_sspCAMContainer_vehicle
                } // End of template m_sspCAMContainer_vehicle
                
                
                template (value) ServiceSpecificPermissions m_sspCAM_sign_all := {
                template (value) ServiceSpecificPermissions m_sspCAM(
                    version         := '01'O,
                                                                     in template (value) BitmapSsp p_bitmapSsp
                    sspContainer    := {
                ) := {
                        sspCAM := m_sspCAMContainer_sign_all
                    bitmapSsp := p_bitmapSsp
                    } // End of field sspContainer
                } // End of template m_sspCAM
                } // End of template m_sspCAM_sign_all
                
                template (value) ServiceSpecificPermissions m_sspCAM_vehicle 
                modifies m_sspCAM_sign_all := {
                    sspContainer    := {
                        sspCAM := m_sspCAMContainer_vehicle
                    } // End of field sspContainer
                } // End of template m_sspCAM_vehicle
                
                
            } // End of group sspCamSend
            } // End of group sspCamSend
            
            
@@ -1359,16 +1336,11 @@ module LibItsSecurity_Templates {
                    noPassing                               := ?,
                    noPassing                               := ?,
                    noPassingForTrucks                      := ?,
                    noPassingForTrucks                      := ?,
                    speedLimit                              := ?,
                    speedLimit                              := ?,
                    reserved1                               := ?,
                    reserved                                := '000000000000000000'B
                    reserved2                               := ?
                } // End of template mw_sspCAMContainer_dummy
                } // End of template mw_sspCAMContainer_dummy
                
                

                template (present) ServiceSpecificPermissions mw_sspCAM_dummy := {
                template (present) ServiceSpecificPermissions mw_sspCAM_dummy := {
                    version         := '01'O,
                    bitmapSsp := ?
                    sspContainer    := {
                        sspCAM := mw_sspCAMContainer_dummy
                    }
                } // End of template mw_sspCAM_dummy
                } // End of template mw_sspCAM_dummy
                
                
            } // End of group sspCamRecv
            } // End of group sspCamRecv
@@ -1403,7 +1375,8 @@ module LibItsSecurity_Templates {
                    hazardousLocation_DangerousCurve                := '1'B,
                    hazardousLocation_DangerousCurve                := '1'B,
                    collisionRisk                                   := '1'B,
                    collisionRisk                                   := '1'B,
                    signalViolation                                 := '1'B,
                    signalViolation                                 := '1'B,
                    dangerousSituation                              := '1'B
                    dangerousSituation                              := '1'B,
                    reserved                                        := '00000000'B
                } // End of template m_sspDENMContainer_sign_all
                } // End of template m_sspDENMContainer_sign_all
                
                
                template (value) SspDENM m_sspDENMContainer_vehicle 
                template (value) SspDENM m_sspDENMContainer_vehicle 
@@ -1444,27 +1417,11 @@ module LibItsSecurity_Templates {
                    dangerousSituation                              := '0'B
                    dangerousSituation                              := '0'B
                } // End of template m_sspDENMContainer_roadSideUnit
                } // End of template m_sspDENMContainer_roadSideUnit
                
                
                template (value) ServiceSpecificPermissions m_sspDENM_sign_all := {
                template (value) ServiceSpecificPermissions m_sspDENM(
                    version         := '01'O,
                                                                      in template (value) BitmapSsp p_bitmapSsp
                    sspContainer    := {
                ) := {
                        sspDENM := m_sspDENMContainer_sign_all
                    bitmapSsp := p_bitmapSsp
                    } // End of field sspContainer
                } // End of template m_sspDENM
                } // End of template m_sspDENM_sign_all
                

                template (value) ServiceSpecificPermissions m_sspDENM_vehicle 
                modifies m_sspDENM_sign_all := {
                    sspContainer    := {
                        sspDENM := m_sspDENMContainer_vehicle
                    } // End of field sspContainer
                } // End of template m_sspDENM_vehicle
                
                template (value) ServiceSpecificPermissions m_sspDENM_roadSideUnit 
                modifies m_sspDENM_sign_all := {
                    sspContainer    := {
                        sspDENM := m_sspDENMContainer_vehicle
                    } // End of field sspContainer
                } // End of template m_sspDENM_roadSideUnit
                
                
            } // End of group sspDenmSend
            } // End of group sspDenmSend
            
            
@@ -1494,7 +1451,8 @@ module LibItsSecurity_Templates {
                    hazardousLocation_DangerousCurve                := ?,
                    hazardousLocation_DangerousCurve                := ?,
                    collisionRisk                                   := ?,
                    collisionRisk                                   := ?,
                    signalViolation                                 := ?,
                    signalViolation                                 := ?,
                    dangerousSituation                              := ?
                    dangerousSituation                              := ?,
                    reserved                                        := '00000000'B
                } // End of template mw_sspDENMContainer_dummy
                } // End of template mw_sspDENMContainer_dummy
                
                
                template (present) SspDENM mw_sspDENMContainer_vehicle
                template (present) SspDENM mw_sspDENMContainer_vehicle
@@ -1535,32 +1493,11 @@ module LibItsSecurity_Templates {
                    dangerousSituation                              := '0'B
                    dangerousSituation                              := '0'B
                } // End of template m_sspDENMContainer_roadSideUnit
                } // End of template m_sspDENMContainer_roadSideUnit
                
                
                template (present) ServiceSpecificPermissions mw_sspDENM_dummy := {
                    version         := '01'O,
                    sspContainer    := {
                        sspDENM := mw_sspDENMContainer_dummy
                    }
                } // End of template mw_sspDENM_dummy
                
                template (present) ServiceSpecificPermissions mw_sspDENM_vehicle
                modifies mw_sspDENM_dummy := {
                    sspContainer    := {
                        sspDENM := mw_sspDENMContainer_vehicle
                    }
                } // End of template mw_sspDENM_vehicle
                
                template (present) ServiceSpecificPermissions mw_sspDENM_roadSideUnit
                modifies mw_sspDENM_dummy := {
                    sspContainer    := {
                        sspDENM := mw_sspDENMContainer_roadSideUnit
                    }
                } // End of template mw_sspDENM_roadSideUnit
                
            } // End of group sspDenmRecv
            } // End of group sspDenmRecv
            
            
        } // End of group sspDenm
        } // End of group sspDenm
        
        
    */} // End of group ssp
    } // End of group ssp


    group utPrimitives {
    group utPrimitives {
        
        
+8 −3
Original line number Original line Diff line number Diff line
@@ -45,8 +45,9 @@ module LibItsSecurity_TypesAndValues {
            Bit1        noPassing,
            Bit1        noPassing,
            Bit1        noPassingForTrucks,
            Bit1        noPassingForTrucks,
            Bit1        speedLimit,
            Bit1        speedLimit,
            Bit1        reserved1,
            Bit18       reserved
            Bit1        reserved2
        } with {
          variant "FIELDORDER(msb)"
        } // End of type SspCAM
        } // End of type SspCAM
        
        
        /**
        /**
@@ -102,7 +103,10 @@ module LibItsSecurity_TypesAndValues {
            Bit1        hazardousLocation_DangerousCurve,
            Bit1        hazardousLocation_DangerousCurve,
            Bit1        collisionRisk,
            Bit1        collisionRisk,
            Bit1        signalViolation,
            Bit1        signalViolation,
            Bit1        dangerousSituation
            Bit1        dangerousSituation,
            Bit8        reserved
        } with {
          variant "FIELDORDER(msb)"
        } // End of type SspDENM
        } // End of type SspDENM
        
        
    } // End of group certificateSpecification
    } // End of group certificateSpecification
@@ -157,5 +161,6 @@ module LibItsSecurity_TypesAndValues {
    } // End of group utPrimitives
    } // End of group utPrimitives
        
        
} with {
} with {
    variant ""
    encode "LibItsSecurity"
    encode "LibItsSecurity"
} // End of module LibItsSecurity_TypesAndValues
} // End of module LibItsSecurity_TypesAndValues