Loading etc/TestCodec/TestCodec.cfg +3 −2 Original line number Diff line number Diff line Loading @@ -126,7 +126,7 @@ system.utPort.params := "UT_GN/UDP(dst_ip=192.168.56.1,dst_port=12346,src_ip=192 #TestCodec_GeoNetworking.tc_GeoNet_Port_acPort_pass_beaconing_2 # GeoNetworking port tests # To run the GeoNetworking port tests, use the offline mode and the test data provided. Use PcapLayer.save_mode to save sent packet into a file TestCodec_GeoNetworking.tc_GeoNet_Port_1 # Use simulator of file to run this test #TestCodec_GeoNetworking.tc_GeoNet_Port_1 # Use simulator of file to run this test # Used to test device_mode=0,beaconing=1,beacon codec # No startPassBeaconing #TestCodec_GeoNetworking.tc_GeoNet_Port_2 # Use simulator of file to run this test Loading Loading @@ -254,8 +254,9 @@ TestCodec_GeoNetworking.tc_GeoNet_Port_1 # Use simulator of file to run #TestCodec_SecuredMessages.tc_ssp_denm #TestCodec_SecuredMessages.tc_secured_message_unsecured #TestCodec_SecuredMessages.tc_secured_message_signed_1 #TestCodec_SecuredMessages.tc_secured_message_signed_2 # Chain of certificates #TestCodec_ChainOfCertificates.tc_full_check_certificate_1 TestCodec_ChainOfCertificates.tc_full_check_certificate_1 [MAIN_CONTROLLER] # The options herein control the behavior of MC. Loading ttcn/AtsAutoInterop/ItsAutoInterop_Pixits.ttcn +6 −6 Original line number Diff line number Diff line Loading @@ -32,14 +32,14 @@ module ItsAutoInterop_Pixits { */ modulepar EutDescriptions PX_EUT_DESC := { { '000000000001'O, 111, '000000000001'O '04e548000001'O, 10171, '04e548000001'O }, // EUT_1 { '000000000002'O, 222, '000000000003'O '70b3d5791b48'O, 10031, '70b3d5791b48'O }, // EUT_2 { '000000000003'O, Loading ttcn/AtsAutoInterop/ItsAutoInterop_TestCases.ttcn +1 −1 Original line number Diff line number Diff line Loading @@ -1438,7 +1438,7 @@ module ItsAutoInterop_TestCases { mw_denm( mw_denmMgmtCon_with_relevances( ?, -, LibItsCommon_ASN1_NamedNumbers.StationType_roadSideUnit_, -, -, -, Loading ttcn/TestCodec/TestCodec_ChainOfCertificates.ttcn +114 −27 Original line number Diff line number Diff line Loading @@ -9,6 +9,11 @@ module TestCodec_ChainOfCertificates { import from IEEE1609dot2 language "ASN.1:1997" all; import from EtsiTs103097Module language "ASN.1:1997" all; // LibItsGeoNetworking import from LibItsGeoNetworking_EncdecDeclarations all; import from LibItsGeoNetworking_TypesAndValues all; import from LibItsGeoNetworking_Templates all; // LibItsSecurity import from LibItsSecurity_EncdecDeclarations all; import from LibItsSecurity_TypesAndValues all; Loading Loading @@ -36,6 +41,9 @@ module TestCodec_ChainOfCertificates { testcase tc_full_check_certificate_1() runs on TCType system TCType { var chain_sec_info v_chain_sec_info; var bitstring v_enc_msg := ''B; var template (value) GnNonSecuredPacket v_gnNonSecuredPacket; var template (value) EtsiTs103097Data v_secured_data; var template (value) GeoNetworkingPdu v_gnSecuredPacket; // Generate CA certificate v_chain_sec_info.ca.cert := f_create_ca_certificate_sha256_1(v_chain_sec_info.ca); Loading @@ -45,7 +53,7 @@ module TestCodec_ChainOfCertificates { v_enc_msg := encvalue(v_chain_sec_info.ca.cert.toBeSigned); if (f_verifyWithEcdsaNistp256WithSha256( bit2oct(v_enc_msg), v_chain_sec_info.ca.cert.signature_.ecdsaNistP256Signature.rSig.x_only & v_chain_sec_info.ca.cert.signature_.ecdsaNistP256Signature.sSig, v_chain_sec_info.ca.cert.signature_.ecdsaNistP256Signature.sSig, v_chain_sec_info.ca.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.x, v_chain_sec_info.ca.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.y ) == false) { Loading @@ -62,9 +70,9 @@ module TestCodec_ChainOfCertificates { v_enc_msg := encvalue(v_chain_sec_info.ea.cert.toBeSigned); if (f_verifyWithEcdsaNistp256WithSha256( bit2oct(v_enc_msg), v_chain_sec_info.ea.cert.signature_.ecdsaNistP256Signature.rSig.x_only & v_chain_sec_info.ea.cert.signature_.ecdsaNistP256Signature.sSig, v_chain_sec_info.ea.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.x, v_chain_sec_info.ea.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.y v_chain_sec_info.ea.cert.signature_.ecdsaNistP256Signature.sSig, v_chain_sec_info.ca.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.x, v_chain_sec_info.ca.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.y ) == false) { setverdict(fail); } else { Loading @@ -75,25 +83,57 @@ module TestCodec_ChainOfCertificates { v_chain_sec_info.at.cert := f_create_at_certificate_sha256_1(v_chain_sec_info.ea, v_chain_sec_info.at); v_enc_msg := encvalue(v_chain_sec_info.at.cert); v_chain_sec_info.at.hashid8 := f_HashedId8FromSha256(f_hashWithSha256(bit2oct(v_enc_msg))); // Verify signature of EA certificate by CA certificate // Verify signature of AT certificate by EA certificate v_enc_msg := encvalue(v_chain_sec_info.at.cert.toBeSigned); if (f_verifyWithEcdsaNistp256WithSha256( bit2oct(v_enc_msg), v_chain_sec_info.at.cert.signature_.ecdsaNistP256Signature.rSig.x_only & v_chain_sec_info.at.cert.signature_.ecdsaNistP256Signature.sSig, v_chain_sec_info.at.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.x, v_chain_sec_info.at.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.y v_chain_sec_info.at.cert.signature_.ecdsaNistP256Signature.sSig, v_chain_sec_info.ea.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.x, v_chain_sec_info.ea.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.y ) == false) { setverdict(fail); } else { setverdict(pass) } // Create a basic CAM message log("tc_full_check_certificate_1: Final chain = ", v_chain_sec_info); // And sign it // Create a basic GeoNetworking message v_gnNonSecuredPacket := m_geoNwShbPacket( LongPosVector: { gnAddr := { typeOfAddress := e_manual, stationType := e_roadSideUnit, stationCountryCode := 33, mid := 'a4fedecabeef'O }, timestamp_ := 123456, latitude := 4856, longitude := 675, pai := '1'B, speed := 55, heading := 9876 } ); // Build the secured message and sign it v_secured_data := f_build_and_sign_secured_message_sha256(v_gnNonSecuredPacket, v_chain_sec_info.at); // Finalyse the GeoNetworking message v_gnSecuredPacket := m_geoNwSecPdu(v_gnNonSecuredPacket, v_secured_data); log("tc_full_check_certificate_1: Final GeoNetworking secured message: ", v_gnSecuredPacket); // Verify signature of EA certificate by CA certificate if (f_verifyWithEcdsaNistp256WithSha256( valueof(v_gnSecuredPacket.gnPacket.securedMsg.content.signedData.tbsData.payload.data.content.unsecuredData), valueof(v_gnSecuredPacket.gnPacket.securedMsg.content.signedData.signature_.ecdsaNistP256Signature.sSig), v_chain_sec_info.at.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.x, v_chain_sec_info.at.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.y ) == false) { setverdict(fail); } else { setverdict(pass) } // And encrypt it // TODO Add encryption support } // End of testcase tc_full_check_certificate_1 Loading Loading @@ -146,7 +186,6 @@ module TestCodec_ChainOfCertificates { ) ); // Encode it ==> Get octetstring log("Encode template ", valueof(v_cert)); v_enc_msg := encvalue(v_cert.toBeSigned); // Sign the certificate using ECDSA/SHA-256 (NIST p-256) v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_enc_msg), p_ca_sec_info.private_key); Loading @@ -159,6 +198,8 @@ module TestCodec_ChainOfCertificates { v_sig ) ); log("f_create_ca_certificate_sha256_1: Signed template ", valueof(v_cert)); // Final CA certificate return valueof(v_cert); } // End of function f_create_ca_certificate_sha256_1 Loading Loading @@ -208,7 +249,6 @@ module TestCodec_ChainOfCertificates { ) ); // Encode it ==> Get octetstring log("Encode template ", valueof(v_cert)); v_enc_msg := encvalue(v_cert.toBeSigned); // Sign the certificate using ECDSA/SHA-256 (NIST p-256) v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_enc_msg), p_ca_sec_info.private_key); Loading @@ -221,6 +261,8 @@ module TestCodec_ChainOfCertificates { v_sig ) ); log("f_create_ea_certificate_sha256_1: Signed template ", valueof(v_cert)); // Final EA certificate return valueof(v_cert); } // End of function f_create_ea_certificate_sha256_1 Loading Loading @@ -283,9 +325,54 @@ module TestCodec_ChainOfCertificates { v_sig ) ); // Final EA certificate log("f_create_at_certificate_sha256_1: Signed template ", valueof(v_cert)); // Final AT certificate return valueof(v_cert); } // End of function f_create_at_certificate_sha256_1 function f_build_and_sign_secured_message_sha256( in template (value) GnNonSecuredPacket p_gnNonSecuredPacket, in sec_info p_at_sec_info ) runs on TCType return EtsiTs103097Data { var octetstring v_raw_payload_to_be_signed; var template (value) ToBeSignedData v_toBeSignedData; var Oct32 v_sig := '0000000000000000000000000000000000000000000000000000000000000000'O; var template (value) EtsiTs103097Data v_secured_data; // Build the message to be signed v_raw_payload_to_be_signed := bit2oct(encvalue(p_gnNonSecuredPacket)); v_toBeSignedData := m_toBeSignedData( m_signedDataPayload( m_etsiTs103097Data_unsecured(v_raw_payload_to_be_signed) ), m_headerInfo_gn( -, 12345, 123456 ) ); // Signed it v_sig := f_signWithEcdsaNistp256WithSha256(v_raw_payload_to_be_signed, p_at_sec_info.private_key); // Finalize the secured message v_secured_data := m_etsiTs103097Data_signed( m_signedData( sha256, v_toBeSignedData, { digest := p_at_sec_info.hashid8 }, m_signature_ecdsaNistP256( m_ecdsaNistP256Signature( m_eccP256CurvePoint_x_only( p_at_sec_info.public_key_x ), v_sig ) ) ) ); log("f_build_and_sign_secured_message_sha256: v_secured_data = ", v_secured_data); return valueof(v_secured_data); } // End of function f_build_and_sign_secured_message_sha256 } // End of module TestCodec_ChainOfCertificates ttcn/TestCodec/TestCodec_SecuredMessages.ttcn +205 −188 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ module TestCodec_SecuredMessages { // LibItsGeoNetworking import from LibItsGeoNetworking_EncdecDeclarations all; import from LibItsGeoNetworking_TypesAndValues all; import from LibItsGeoNetworking_Templates all; // LibItsSecurity import from LibItsSecurity_EncdecDeclarations all; Loading Loading @@ -161,17 +162,33 @@ module TestCodec_SecuredMessages { setverdict(pass, "Decoding passed."); } // End of testcase tc_secured_message_signed_1 // FIXME How to create secured GeoNetworking message? testcase tc_secured_message_signed_2() runs on TCType system TCType { var template (value) EtsiTs103097Data v_secured_data; var EtsiTs103097Data v_secured_data_dec; var template (value) GeoNetworkingPdu v_gnPacket; var octetstring v_raw_payload_to_be_signed; var HashedId8 v_digest := '0000000000000000'O; var bitstring v_encMsg; v_gnPacket := m_geoNwPdu( m_geoNwShbPacket( LongPosVector: { gnAddr := { typeOfAddress := e_manual, stationType := e_roadSideUnit, stationCountryCode := 33, mid := 'a4fedecabeef'O }, timestamp_ := 123456, latitude := 4856, longitude := 675, pai := '1'B, speed := 55, heading := 9876 } ) ); v_raw_payload_to_be_signed := bit2oct(encvalue(v_gnPacket)); v_secured_data := m_etsiTs103097Data_signed( m_signedData( sha256, Loading Loading
etc/TestCodec/TestCodec.cfg +3 −2 Original line number Diff line number Diff line Loading @@ -126,7 +126,7 @@ system.utPort.params := "UT_GN/UDP(dst_ip=192.168.56.1,dst_port=12346,src_ip=192 #TestCodec_GeoNetworking.tc_GeoNet_Port_acPort_pass_beaconing_2 # GeoNetworking port tests # To run the GeoNetworking port tests, use the offline mode and the test data provided. Use PcapLayer.save_mode to save sent packet into a file TestCodec_GeoNetworking.tc_GeoNet_Port_1 # Use simulator of file to run this test #TestCodec_GeoNetworking.tc_GeoNet_Port_1 # Use simulator of file to run this test # Used to test device_mode=0,beaconing=1,beacon codec # No startPassBeaconing #TestCodec_GeoNetworking.tc_GeoNet_Port_2 # Use simulator of file to run this test Loading Loading @@ -254,8 +254,9 @@ TestCodec_GeoNetworking.tc_GeoNet_Port_1 # Use simulator of file to run #TestCodec_SecuredMessages.tc_ssp_denm #TestCodec_SecuredMessages.tc_secured_message_unsecured #TestCodec_SecuredMessages.tc_secured_message_signed_1 #TestCodec_SecuredMessages.tc_secured_message_signed_2 # Chain of certificates #TestCodec_ChainOfCertificates.tc_full_check_certificate_1 TestCodec_ChainOfCertificates.tc_full_check_certificate_1 [MAIN_CONTROLLER] # The options herein control the behavior of MC. Loading
ttcn/AtsAutoInterop/ItsAutoInterop_Pixits.ttcn +6 −6 Original line number Diff line number Diff line Loading @@ -32,14 +32,14 @@ module ItsAutoInterop_Pixits { */ modulepar EutDescriptions PX_EUT_DESC := { { '000000000001'O, 111, '000000000001'O '04e548000001'O, 10171, '04e548000001'O }, // EUT_1 { '000000000002'O, 222, '000000000003'O '70b3d5791b48'O, 10031, '70b3d5791b48'O }, // EUT_2 { '000000000003'O, Loading
ttcn/AtsAutoInterop/ItsAutoInterop_TestCases.ttcn +1 −1 Original line number Diff line number Diff line Loading @@ -1438,7 +1438,7 @@ module ItsAutoInterop_TestCases { mw_denm( mw_denmMgmtCon_with_relevances( ?, -, LibItsCommon_ASN1_NamedNumbers.StationType_roadSideUnit_, -, -, -, Loading
ttcn/TestCodec/TestCodec_ChainOfCertificates.ttcn +114 −27 Original line number Diff line number Diff line Loading @@ -9,6 +9,11 @@ module TestCodec_ChainOfCertificates { import from IEEE1609dot2 language "ASN.1:1997" all; import from EtsiTs103097Module language "ASN.1:1997" all; // LibItsGeoNetworking import from LibItsGeoNetworking_EncdecDeclarations all; import from LibItsGeoNetworking_TypesAndValues all; import from LibItsGeoNetworking_Templates all; // LibItsSecurity import from LibItsSecurity_EncdecDeclarations all; import from LibItsSecurity_TypesAndValues all; Loading Loading @@ -36,6 +41,9 @@ module TestCodec_ChainOfCertificates { testcase tc_full_check_certificate_1() runs on TCType system TCType { var chain_sec_info v_chain_sec_info; var bitstring v_enc_msg := ''B; var template (value) GnNonSecuredPacket v_gnNonSecuredPacket; var template (value) EtsiTs103097Data v_secured_data; var template (value) GeoNetworkingPdu v_gnSecuredPacket; // Generate CA certificate v_chain_sec_info.ca.cert := f_create_ca_certificate_sha256_1(v_chain_sec_info.ca); Loading @@ -45,7 +53,7 @@ module TestCodec_ChainOfCertificates { v_enc_msg := encvalue(v_chain_sec_info.ca.cert.toBeSigned); if (f_verifyWithEcdsaNistp256WithSha256( bit2oct(v_enc_msg), v_chain_sec_info.ca.cert.signature_.ecdsaNistP256Signature.rSig.x_only & v_chain_sec_info.ca.cert.signature_.ecdsaNistP256Signature.sSig, v_chain_sec_info.ca.cert.signature_.ecdsaNistP256Signature.sSig, v_chain_sec_info.ca.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.x, v_chain_sec_info.ca.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.y ) == false) { Loading @@ -62,9 +70,9 @@ module TestCodec_ChainOfCertificates { v_enc_msg := encvalue(v_chain_sec_info.ea.cert.toBeSigned); if (f_verifyWithEcdsaNistp256WithSha256( bit2oct(v_enc_msg), v_chain_sec_info.ea.cert.signature_.ecdsaNistP256Signature.rSig.x_only & v_chain_sec_info.ea.cert.signature_.ecdsaNistP256Signature.sSig, v_chain_sec_info.ea.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.x, v_chain_sec_info.ea.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.y v_chain_sec_info.ea.cert.signature_.ecdsaNistP256Signature.sSig, v_chain_sec_info.ca.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.x, v_chain_sec_info.ca.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.y ) == false) { setverdict(fail); } else { Loading @@ -75,25 +83,57 @@ module TestCodec_ChainOfCertificates { v_chain_sec_info.at.cert := f_create_at_certificate_sha256_1(v_chain_sec_info.ea, v_chain_sec_info.at); v_enc_msg := encvalue(v_chain_sec_info.at.cert); v_chain_sec_info.at.hashid8 := f_HashedId8FromSha256(f_hashWithSha256(bit2oct(v_enc_msg))); // Verify signature of EA certificate by CA certificate // Verify signature of AT certificate by EA certificate v_enc_msg := encvalue(v_chain_sec_info.at.cert.toBeSigned); if (f_verifyWithEcdsaNistp256WithSha256( bit2oct(v_enc_msg), v_chain_sec_info.at.cert.signature_.ecdsaNistP256Signature.rSig.x_only & v_chain_sec_info.at.cert.signature_.ecdsaNistP256Signature.sSig, v_chain_sec_info.at.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.x, v_chain_sec_info.at.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.y v_chain_sec_info.at.cert.signature_.ecdsaNistP256Signature.sSig, v_chain_sec_info.ea.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.x, v_chain_sec_info.ea.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.y ) == false) { setverdict(fail); } else { setverdict(pass) } // Create a basic CAM message log("tc_full_check_certificate_1: Final chain = ", v_chain_sec_info); // And sign it // Create a basic GeoNetworking message v_gnNonSecuredPacket := m_geoNwShbPacket( LongPosVector: { gnAddr := { typeOfAddress := e_manual, stationType := e_roadSideUnit, stationCountryCode := 33, mid := 'a4fedecabeef'O }, timestamp_ := 123456, latitude := 4856, longitude := 675, pai := '1'B, speed := 55, heading := 9876 } ); // Build the secured message and sign it v_secured_data := f_build_and_sign_secured_message_sha256(v_gnNonSecuredPacket, v_chain_sec_info.at); // Finalyse the GeoNetworking message v_gnSecuredPacket := m_geoNwSecPdu(v_gnNonSecuredPacket, v_secured_data); log("tc_full_check_certificate_1: Final GeoNetworking secured message: ", v_gnSecuredPacket); // Verify signature of EA certificate by CA certificate if (f_verifyWithEcdsaNistp256WithSha256( valueof(v_gnSecuredPacket.gnPacket.securedMsg.content.signedData.tbsData.payload.data.content.unsecuredData), valueof(v_gnSecuredPacket.gnPacket.securedMsg.content.signedData.signature_.ecdsaNistP256Signature.sSig), v_chain_sec_info.at.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.x, v_chain_sec_info.at.cert.toBeSigned.verifyKeyIndicator.verificationKey.ecdsaNistP256.uncompressedP256.y ) == false) { setverdict(fail); } else { setverdict(pass) } // And encrypt it // TODO Add encryption support } // End of testcase tc_full_check_certificate_1 Loading Loading @@ -146,7 +186,6 @@ module TestCodec_ChainOfCertificates { ) ); // Encode it ==> Get octetstring log("Encode template ", valueof(v_cert)); v_enc_msg := encvalue(v_cert.toBeSigned); // Sign the certificate using ECDSA/SHA-256 (NIST p-256) v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_enc_msg), p_ca_sec_info.private_key); Loading @@ -159,6 +198,8 @@ module TestCodec_ChainOfCertificates { v_sig ) ); log("f_create_ca_certificate_sha256_1: Signed template ", valueof(v_cert)); // Final CA certificate return valueof(v_cert); } // End of function f_create_ca_certificate_sha256_1 Loading Loading @@ -208,7 +249,6 @@ module TestCodec_ChainOfCertificates { ) ); // Encode it ==> Get octetstring log("Encode template ", valueof(v_cert)); v_enc_msg := encvalue(v_cert.toBeSigned); // Sign the certificate using ECDSA/SHA-256 (NIST p-256) v_sig := f_signWithEcdsaNistp256WithSha256(bit2oct(v_enc_msg), p_ca_sec_info.private_key); Loading @@ -221,6 +261,8 @@ module TestCodec_ChainOfCertificates { v_sig ) ); log("f_create_ea_certificate_sha256_1: Signed template ", valueof(v_cert)); // Final EA certificate return valueof(v_cert); } // End of function f_create_ea_certificate_sha256_1 Loading Loading @@ -283,9 +325,54 @@ module TestCodec_ChainOfCertificates { v_sig ) ); // Final EA certificate log("f_create_at_certificate_sha256_1: Signed template ", valueof(v_cert)); // Final AT certificate return valueof(v_cert); } // End of function f_create_at_certificate_sha256_1 function f_build_and_sign_secured_message_sha256( in template (value) GnNonSecuredPacket p_gnNonSecuredPacket, in sec_info p_at_sec_info ) runs on TCType return EtsiTs103097Data { var octetstring v_raw_payload_to_be_signed; var template (value) ToBeSignedData v_toBeSignedData; var Oct32 v_sig := '0000000000000000000000000000000000000000000000000000000000000000'O; var template (value) EtsiTs103097Data v_secured_data; // Build the message to be signed v_raw_payload_to_be_signed := bit2oct(encvalue(p_gnNonSecuredPacket)); v_toBeSignedData := m_toBeSignedData( m_signedDataPayload( m_etsiTs103097Data_unsecured(v_raw_payload_to_be_signed) ), m_headerInfo_gn( -, 12345, 123456 ) ); // Signed it v_sig := f_signWithEcdsaNistp256WithSha256(v_raw_payload_to_be_signed, p_at_sec_info.private_key); // Finalize the secured message v_secured_data := m_etsiTs103097Data_signed( m_signedData( sha256, v_toBeSignedData, { digest := p_at_sec_info.hashid8 }, m_signature_ecdsaNistP256( m_ecdsaNistP256Signature( m_eccP256CurvePoint_x_only( p_at_sec_info.public_key_x ), v_sig ) ) ) ); log("f_build_and_sign_secured_message_sha256: v_secured_data = ", v_secured_data); return valueof(v_secured_data); } // End of function f_build_and_sign_secured_message_sha256 } // End of module TestCodec_ChainOfCertificates
ttcn/TestCodec/TestCodec_SecuredMessages.ttcn +205 −188 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ module TestCodec_SecuredMessages { // LibItsGeoNetworking import from LibItsGeoNetworking_EncdecDeclarations all; import from LibItsGeoNetworking_TypesAndValues all; import from LibItsGeoNetworking_Templates all; // LibItsSecurity import from LibItsSecurity_EncdecDeclarations all; Loading Loading @@ -161,17 +162,33 @@ module TestCodec_SecuredMessages { setverdict(pass, "Decoding passed."); } // End of testcase tc_secured_message_signed_1 // FIXME How to create secured GeoNetworking message? testcase tc_secured_message_signed_2() runs on TCType system TCType { var template (value) EtsiTs103097Data v_secured_data; var EtsiTs103097Data v_secured_data_dec; var template (value) GeoNetworkingPdu v_gnPacket; var octetstring v_raw_payload_to_be_signed; var HashedId8 v_digest := '0000000000000000'O; var bitstring v_encMsg; v_gnPacket := m_geoNwPdu( m_geoNwShbPacket( LongPosVector: { gnAddr := { typeOfAddress := e_manual, stationType := e_roadSideUnit, stationCountryCode := 33, mid := 'a4fedecabeef'O }, timestamp_ := 123456, latitude := 4856, longitude := 675, pai := '1'B, speed := 55, heading := 9876 } ) ); v_raw_payload_to_be_signed := bit2oct(encvalue(v_gnPacket)); v_secured_data := m_etsiTs103097Data_signed( m_signedData( sha256, Loading