Skip to content
LibItsSecurity_Functions.ttcn3 6.35 KiB
Newer Older
garciay's avatar
garciay committed
/**
 *  @author   ETSI / STF481
 *  @version  $URL$
 *            $Id$
 *  @desc     Module containing functions for Security Protocol
 *
 */
module LibItsSecurity_Functions {
garciay's avatar
garciay committed
    // LibItsSecurity
    
//    group configurationFunctions {
//        
//       /**
//        * @desc 
//        */
//        function f_cf01Up() runs on ItsGnSecurity {
//            
//            // Map
//            map(self:acPort, system:acPort);
//            map(self:utPort, system:utPort);
//            map(self:gnSecurityPort, system:gnSecurityPort);
//            
//            // Connect
//            f_connect4SelfOrClientSync();
//            activate(a_cf01Down());
//            
//            // Initialze the IUT/DUT
//            f_initialState();
//            
//        } // End of function f_cf01Up
//        
//        function f_cf01Down() runs on ItsGnSecurity {
//            
//            // Unmap
//            unmap(self:acPort, system:acPort);
//            unmap(self:utPort, system:utPort);
//            unmap(self:gnSecurityPort, system:gnSecurityPort);
//            
//            // Disconnect
//            f_disconnect4SelfOrClientSync();
//        } // End of function f_cf01Down
//        
//    } // End of group configurationFunctions
//    
//    group preambles {
//        
//        /**
//         * @desc Brings the IUT into an initial state.
//         */
//        function f_initialState() runs on ItsBaseGnSecurity {
//            // TODO
//        }
//        
//    } // End of group preambles
//    
//    group postambles {
//        
//    } // End of group postambles
//    
//    group securityAltsteps {
//        
//        /**
//         * @desc The base default behavior.
//         */
//        altstep a_default() runs on ItsGnSecurity {
//            [] gnSecurityPort.receive(mw_gnSecurityInd(?)) {
//                log("*** a_default: WARNING: Received an unexpected message ***");
//                repeat;
//            }
//            [] gnSecurityPort.receive {
//                log("*** a_default: WARNING: Received an unexpected message ***");
//                repeat;
//            }
//            [] tc_wait.timeout {
//                log("*** a_default: ERROR: Timeout while awaiting reaction of the IUT prior to Upper Tester action ***");
//                f_selfOrClientSyncAndVerdict("error", e_timeout);
//            }
//            [] tc_ac.timeout {
//                log("*** a_default: ERROR: Timeout while awaiting the reception of a message ***");
//                f_selfOrClientSyncAndVerdict("error", e_timeout);
//            }
//            [] a_shutdown() {
//                log("*** a_default: INFO: TEST COMPONENT NOW STOPPING ITSELF! ***");
//                stop;
//            }
//        } // End of 'altstep' statement
//        
//        altstep a_cf01Down() runs on ItsGnSecurity {
//            [] a_shutdown() {
//                f_cf01Down();
//                log("*** a_cf01Down: INFO: TEST COMPONENT NOW STOPPING ITSELF! ***");
//                stop;
//            }
//        } // End of 'altstep' statement
//        
//    } // End of group securityAltsteps
//    
garciay's avatar
garciay committed
    group helpersFunctions {
        
        /**
         * @desc    Produces a 256-bit (32-byte) hash value
         * @param   TODO
         * @return  TODO
         */
        function f_hashWithSha256(in octetstring p_toBeHashedData) {
            
        }
        
        /**
         * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signaturee
         * @param   TODO
         * @return  TODO
         */
        function f_signWithEcdsaNistp256WithSha256() {
            
        }
        
        /**
         * @desc    Verify the signature of the specified data
         * @param   TODO
         * @return  true on success, false otherwise
         */
        function f_verifyWithEcdsaNistp256WithSha256() return boolean {
            return false;
        }
        
        /**
         * @desc    Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm
         * @param   TODO
         * @return  true on success, false otherwise
         */
        function f_generateKeyPair() return boolean {
            return false;
        }
        
    } // End of group helpersFunctions
    
    group externalFunctions {
        
        /**
         * @desc    Produces a 256-bit (32-byte) hash value
         * @param   p_toBeHashedData Data to be used to calculate the hash value
         * @return  The hash value
         */
garciay's avatar
garciay committed
        external function fx_hashWithSha256(in octetstring p_toBeHashedData) return octetstring;
        
        /**
         * @desc    Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signaturee
         * @param   p_toBeSignedData    The data to be signed
         * @param   p_privateKey        The private key
         * @return  The signature value
         */
garciay's avatar
garciay committed
        external function fx_signWithEcdsaNistp256WithSha256(in octetstring p_toBeSignedData, in octetstring/*UInt64*/ p_privateKey) return octetstring;
        
        /**
         * @desc    Verify the signature of the specified data
         * @param   p_toBeVerifiedData          The data to be verified
         * @param   p_signature                 The signature
         * @param   p_ecdsaNistp256PublicKeyX   The public key (x coordinate)
         * @param   p_ecdsaNistp256PublicKeyY   The public key (y coordinate)
         * @return  true on success, false otherwise
         */
garciay's avatar
garciay committed
        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
         * @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
         */
garciay's avatar
garciay committed
        external function fx_generateKeyPair(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean;
        
    } // End of group externalFunctions
    
garciay's avatar
garciay committed
} // End of module LibItsSecurity_Functions