Commit d18229fc authored by garciay's avatar garciay
Browse files

Add signatures support

parent 53ee5178
Loading
Loading
Loading
Loading
+88 −107
Original line number Original line Diff line number Diff line
@@ -43,6 +43,17 @@ module LibItsSecurity_Functions {
            return fx_hashWithSha256(p_toBeHashedData);
            return fx_hashWithSha256(p_toBeHashedData);
        } // End of function f_hashWithSha256
        } // End of function f_hashWithSha256
        
        
        /**
         * @desc    Produces a 384-bit (48-byte) hash value
         * @param   p_toBeHashedData Data to be used to calculate the hash value
         * @return  The hash value
         */
        function f_hashWithSha384(
                                  in octetstring p_toBeHashedData
        ) return Oct48 {
            return fx_hashWithSha384(p_toBeHashedData);
        } // End of function f_hashWithSha256
        
        /**
        /**
         * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signaturee
         * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signaturee
         * @param   p_toBeSignedSecuredMessage    The data to be signed
         * @param   p_toBeSignedSecuredMessage    The data to be signed
@@ -1151,27 +1162,22 @@ module LibItsSecurity_Functions {
            * @param   p_type header field type
            * @param   p_type header field type
            * @return  HeaderInfo of given type if any or null
            * @return  HeaderInfo of given type if any or null
            */
            */
            function f_getMsgHeaderField(
            function f_getMsgHeaderInfo(
                                         in  template(omit) Ieee1609Dot2Data p_securedMessage,
                                         in  template(omit) Ieee1609Dot2Data p_securedMessage,
                                         in  HeaderInfo p_headerInfo,
                                         in  HeaderInfo p_headerInfo,
                                         out HeaderInfo p_return
                                         out HeaderInfo p_return
            ) return boolean {
            ) return boolean {
                /*Spirent splitted*/
                var integer v_length;
                var integer v_length;
                var Ieee1609Dot2Data v_securedMessage;
                var Ieee1609Dot2Data v_securedMessage;
                
                if (not isvalue(p_securedMessage)) {
                if (not isvalue(p_securedMessage)) {
                    testcase.stop(__SCOPE__ & " can not handle omitted secured message values");
                    testcase.stop(__SCOPE__ & " can not handle omitted secured message values");
                }
                }
                v_securedMessage := valueof(p_securedMessage);
                v_securedMessage := valueof(p_securedMessage);
                
                if (ispresent(v_securedMessage.content.signedData)) {
                /*Spirent replaced p_securedMessage with v_securedMessage*/
                    p_return := v_securedMessage.content.signedData.tbsData.headerInfo;
                /* FIXME To be reviewed tv_length := lengthof(v_securedMessage.header_fields);
                for (var integer i := 0; i < v_length; i := i + 1) {
                    if (v_securedMessage.header_fields[i].type_ == p_headerFieldType) {
                        p_return := v_securedMessage.header_fields[i];
                    return true;
                    return true;
                }
                }
                }*/


                log("f_getMsgHeaderField: return false");
                log("f_getMsgHeaderField: return false");
                return false;
                return false;
@@ -1184,14 +1190,10 @@ module LibItsSecurity_Functions {
                                         in template(omit) Ieee1609Dot2Data p_securedMessage,
                                         in template(omit) Ieee1609Dot2Data p_securedMessage,
                                         out SignerIdentifier p_signerIdentifier
                                         out SignerIdentifier p_signerIdentifier
            ) return boolean {
            ) return boolean {
                var HeaderInfo v_hf;
                if (ispresent(p_securedMessage.content.signedData)) {
                
                    p_signerIdentifier := valueof(p_securedMessage.content.signedData.signer);
                /* FIXME To be reviewed tif (f_getMsgHeaderField(p_securedMessage, e_signer_info, v_hf) == true) {
                    if (isbound(v_hf.headerField.signer)) {
                        p_signerIdentifier := v_hf.headerField.signer;
                    return true;
                    return true;
                }
                }
                }*/
                
                
                log("f_getMsgSignerIdentifier: return false");
                log("f_getMsgSignerIdentifier: return false");
                return false;
                return false;
@@ -1340,34 +1342,10 @@ module LibItsSecurity_Functions {
                                                         in template (value) EtsiTs103097Certificate p_cert,
                                                         in template (value) EtsiTs103097Certificate p_cert,
                                                         out ValidityPeriod p_return
                                                         out ValidityPeriod p_return
            ) return boolean {
            ) return boolean {
                
                p_return := valueof(p_cert.toBeSigned.validityPeriod);
                /* FIXME To be reviewed tfor (var integer i := 0; i < lengthof(p_cert.validity_restrictions); i := i + 1) {
//FIXME RGY Titan doesn't support dot notation after valueof at the moment
//                    if (valueof(p_cert).validity_restrictions[i].type_ == p_type) {
//                        p_return := valueof(p_cert).validity_restrictions[i];
                    if (valueof(p_cert.validity_restrictions[i].type_) == p_type) {
                        p_return := valueof(p_cert.validity_restrictions[i]);
                return true;
                return true;
                    }
                } // End of 'for' statement
                
                log("f_getCertificateValidityRestriction: Failed to retrieve ", p_type);*/
                return false;
            } // End of function f_getCertificateValidityRestriction
            } // End of function f_getCertificateValidityRestriction
            
            
            function f_getCertificateSignerIdentifier(
                                                in template (value) EtsiTs103097Certificate p_cert,
                                                out SignerIdentifier p_si
            ) return boolean {
                /* FIXME To be reviewed tif (isbound(valueof(p_cert.signer_info))) {
                    p_si := valueof(p_cert.signer_info);
                    return true;
                }*/
                
                log("f_getCertificateSignerIdentifier: Failed to retrieve ");
                return false;
            }
            
            function f_getCertificateSubjectAttribute(
            function f_getCertificateSubjectAttribute(
                                                      in template (value) EtsiTs103097Certificate p_cert/* FIXME To be reviewed,
                                                      in template (value) EtsiTs103097Certificate p_cert/* FIXME To be reviewed,
                                                      out SubjectAttribute p_return*/
                                                      out SubjectAttribute p_return*/
@@ -1455,6 +1433,13 @@ module LibItsSecurity_Functions {
             */
             */
            external function fx_hashWithSha256(in octetstring p_toBeHashedData) return Oct32;
            external function fx_hashWithSha256(in octetstring p_toBeHashedData) return Oct32;
            
            
            /**
             * @desc    Produces a 384-bit (48-byte) hash value
             * @param   p_toBeHashedData Data to be used to calculate the hash value
             * @return  The hash value
             */
            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) signaturee
             * @param   p_toBeSignedSecuredMessage    The data to be signed
             * @param   p_toBeSignedSecuredMessage    The data to be signed
@@ -1873,8 +1858,6 @@ module LibItsSecurity_Functions {
                                                               in template (value) RectangularRegion p_rectangular_region,
                                                               in template (value) RectangularRegion p_rectangular_region,
                                                               out PolygonalRegion p_region
                                                               out PolygonalRegion p_region
        ) return boolean {
        ) return boolean {
// FIXME (DF) UNUSED
//            var integer v_counter := 0;
            
            
            // Convert rectangular regions to polygons and check polygons
            // Convert rectangular regions to polygons and check polygons
            p_region[0] := valueof(p_rectangular_region.northWest);
            p_region[0] := valueof(p_rectangular_region.northWest);
@@ -1951,8 +1934,6 @@ module LibItsSecurity_Functions {
        ) return boolean {
        ) return boolean {
            var boolean v_ret := false;
            var boolean v_ret := false;
            
            
//FIXME RGY valeuof is missing: argument of select case is Expression (see $19.3.1)
//            select (p_region.region_type) {
            if (ischosen(p_region.circularRegion)) {
            if (ischosen(p_region.circularRegion)) {
                v_ret := f_isLocationInsideCircularRegion(valueof(p_region.circularRegion), p_location);
                v_ret := f_isLocationInsideCircularRegion(valueof(p_region.circularRegion), p_location);
            } else if (ischosen(p_region.rectangularRegion)) {
            } else if (ischosen(p_region.rectangularRegion)) {
+61 −30
Original line number Original line Diff line number Diff line
@@ -1038,10 +1038,12 @@ module LibItsSecurity_Templates {
    
    
    group toBeSignedCertificate {
    group toBeSignedCertificate {
        
        
        template (omit) ToBeSignedCertificate m_toBeSignedCertificate(
        /**
         * @desc Send template for ToBeSignedCertificate with CA restrictions
         * @see ETSI TS 103 097 V1.3.1 Clause 7.2.3 Root CA certificate
         */
        template (omit) ToBeSignedCertificate m_toBeSignedCertificate_ca(
                                                                         in template (value) CertificateId p_id,
                                                                         in template (value) CertificateId p_id,
                                                                      in template (value) HashedId3 p_cracaId,
                                                                      in template (value) CrlSeries p_crlSeries,
                                                                         in template (value) SequenceOfPsidSsp p_appPermissions,
                                                                         in template (value) SequenceOfPsidSsp p_appPermissions,
                                                                         in template (value) SequenceOfPsidGroupPermissions p_certIssuePermissions,
                                                                         in template (value) SequenceOfPsidGroupPermissions p_certIssuePermissions,
                                                                         in template (value) VerificationKeyIndicator p_verifyKeyIndicator,
                                                                         in template (value) VerificationKeyIndicator p_verifyKeyIndicator,
@@ -1052,8 +1054,8 @@ module LibItsSecurity_Templates {
                                                                         in template (omit) PublicEncryptionKey p_encryptionKey := omit
                                                                         in template (omit) PublicEncryptionKey p_encryptionKey := omit
        ) := { 
        ) := { 
            id                     := p_id,
            id                     := p_id,
            cracaId                := p_cracaId,
            cracaId                := '000000'O, // ETSI TS 103 097 V1.3.1 Clause 6 Bullet 2
            crlSeries              := p_crlSeries,
            crlSeries              := 0, // ETSI TS 103 097 V1.3.1 Clause 6 Bullet 3
            validityPeriod         := p_validityPeriod,
            validityPeriod         := p_validityPeriod,
            region                 := p_region,
            region                 := p_region,
            assuranceLevel         := p_assuranceLevel,
            assuranceLevel         := p_assuranceLevel,
@@ -1063,12 +1065,14 @@ module LibItsSecurity_Templates {
            canRequestRollover     := omit,
            canRequestRollover     := omit,
            encryptionKey          := p_encryptionKey,
            encryptionKey          := p_encryptionKey,
            verifyKeyIndicator     := p_verifyKeyIndicator
            verifyKeyIndicator     := p_verifyKeyIndicator
        } // End of template m_toBeSignedCertificate
        } // End of template m_toBeSignedCertificate_ca
        
        
        template ToBeSignedCertificate mw_toBeSignedCertificate(
        /**
         * @desc Receive template for ToBeSignedCertificate with CA restrictions
         * @see ETSI TS 103 097 V1.3.1 Clause 7.2.3 Root CA certificate
         */
        template ToBeSignedCertificate mw_toBeSignedCertificate_ca(
                                                                   template (present) CertificateId p_id := ?,
                                                                   template (present) CertificateId p_id := ?,
                                                                template (present) HashedId3 p_cracaId := ?,
                                                                template (present) CrlSeries p_crlSeries := ?,
                                                                   template (present) SequenceOfPsidSsp p_appPermissions := ?,
                                                                   template (present) SequenceOfPsidSsp p_appPermissions := ?,
                                                                   template (present) SequenceOfPsidGroupPermissions p_certIssuePermissions := ?,
                                                                   template (present) SequenceOfPsidGroupPermissions p_certIssuePermissions := ?,
                                                                   template (present) VerificationKeyIndicator p_verifyKeyIndicator := ?,
                                                                   template (present) VerificationKeyIndicator p_verifyKeyIndicator := ?,
@@ -1079,8 +1083,8 @@ module LibItsSecurity_Templates {
                                                                   template PublicEncryptionKey p_encryptionKey := *
                                                                   template PublicEncryptionKey p_encryptionKey := *
        ) := { 
        ) := { 
            id                     := p_id,
            id                     := p_id,
            cracaId                := p_cracaId,
            cracaId                := '000000'O,
            crlSeries              := p_crlSeries,
            crlSeries              := 0,
            validityPeriod         := p_validityPeriod,
            validityPeriod         := p_validityPeriod,
            region                 := p_region,
            region                 := p_region,
            assuranceLevel         := p_assuranceLevel,
            assuranceLevel         := p_assuranceLevel,
@@ -1092,6 +1096,33 @@ module LibItsSecurity_Templates {
            verifyKeyIndicator     := p_verifyKeyIndicator
            verifyKeyIndicator     := p_verifyKeyIndicator
        } // End of template mw_toBeSignedCertificate
        } // End of template mw_toBeSignedCertificate
        
        
        /**
         * @desc Send template for ToBeSignedCertificate with AT restrictions
         * @see ETSI TS 103 097 V1.3.1 Clause 7.2.1 Authorization tickets
         */
        template (omit) ToBeSignedCertificate m_toBeSignedCertificate_at(
                                                                         in template (value) SequenceOfPsidSsp p_appPermissions,
                                                                         in template (value) VerificationKeyIndicator p_verifyKeyIndicator,
                                                                         in template (omit) SequenceOfPsidGroupPermissions p_certRequestPermissions := omit,
                                                                         in template (omit) ValidityPeriod p_validityPeriod := omit,
                                                                         in template (omit) GeographicRegion p_region := omit,
                                                                         in template (omit) SubjectAssurance p_assuranceLevel := omit,
                                                                         in template (omit) PublicEncryptionKey p_encryptionKey := omit
        ) := { 
            id                     := { none_ := NULL },
            cracaId                := '000000'O, // ETSI TS 103 097 V1.3.1 Clause 6 Bullet 2
            crlSeries              := 0, // ETSI TS 103 097 V1.3.1 Clause 6 Bullet 3
            validityPeriod         := p_validityPeriod,
            region                 := p_region,
            assuranceLevel         := p_assuranceLevel,
            appPermissions         := p_appPermissions,
            certIssuePermissions   := omit,
            certRequestPermissions := p_certRequestPermissions, 
            canRequestRollover     := omit,
            encryptionKey          := p_encryptionKey,
            verifyKeyIndicator     := p_verifyKeyIndicator
        } // End of template m_toBeSignedCertificate_at
        
    } // End of toBeSignedCertificate
    } // End of toBeSignedCertificate
    
    
    group keys {
    group keys {
+1 −1
Original line number Original line Diff line number Diff line
@@ -31,7 +31,7 @@ module LibItsSecurity_TestSystem {
        type component ItsSecurityBaseComponent {
        type component ItsSecurityBaseComponent {
            
            
            // Certificates
            // Certificates
            var Certificate vc_aaCertificate;                                   /** Test Adapter AT certificate */
            var Certificate vc_aaCertificate;                                   /** Test Adapter AA certificate */
            var Certificate vc_atCertificate;                                   /** Test Adapter AT certificate */
            var Certificate vc_atCertificate;                                   /** Test Adapter AT certificate */
            var Certificate vc_lastAtCertificateUsed;                           /** Last Test Adapter certificate used in 'f_buildGnSecuredXXX' functions */
            var Certificate vc_lastAtCertificateUsed;                           /** Last Test Adapter certificate used in 'f_buildGnSecuredXXX' functions */
            var charstring  vc_hashedId8ToBeUsed := PX_IUT_DEFAULT_CERTIFICATE; /** Digest value of the AT certificate to be used by the IUT. Default: CERT_IUT_A_AT */
            var charstring  vc_hashedId8ToBeUsed := PX_IUT_DEFAULT_CERTIFICATE; /** Digest value of the AT certificate to be used by the IUT. Default: CERT_IUT_A_AT */