Commits (1)
...@@ -117,6 +117,19 @@ module LibItsCommon_Functions { ...@@ -117,6 +117,19 @@ module LibItsCommon_Functions {
return v_timeStamp; return v_timeStamp;
} }
/**
* @desc Gets the current time since 01/01/1970 in UTC format
* @return The current time since 01/01/1970 in UTC format
*/
function f_getCurrentTimeUtc() return UInt64 {
var UInt64 v_time := 0;
// log("*** f_getCurrentTimeUtc: INFO: calling fx_getCurrentTimeUtc() ***");
v_time := fx_getCurrentTimeUtc();
return v_time;
}
/** /**
* @desc Gets the current time since 01/01/2004 * @desc Gets the current time since 01/01/2004
* @return TimeMark - tenths of a second in the current or next hour in units of 1/10th second from UTC time * @return TimeMark - tenths of a second in the current or next hour in units of 1/10th second from UTC time
...@@ -228,6 +241,12 @@ module LibItsCommon_Functions { ...@@ -228,6 +241,12 @@ module LibItsCommon_Functions {
*/ */
external function fx_getCurrentTime() return UInt64; external function fx_getCurrentTime() return UInt64;
/**
* @desc Gets the current time since 01/01/1970 in UTC format
* @return The current time since 01/01/1970 in UTC format
*/
external function fx_getCurrentTimeUtc() return UInt64;
/** /**
* @desc Gets the tenths of a second in the current or next hour in units of 1/10th second from UTC time * @desc Gets the tenths of a second in the current or next hour in units of 1/10th second from UTC time
* @return TimeMark - tenths of a second in the current or next hour in units of 1/10th second from UTC time * @return TimeMark - tenths of a second in the current or next hour in units of 1/10th second from UTC time
...@@ -288,4 +307,4 @@ module LibItsCommon_Functions { ...@@ -288,4 +307,4 @@ module LibItsCommon_Functions {
} // end externalFunctions } // end externalFunctions
} // end of module } // end of module
\ No newline at end of file
...@@ -89,8 +89,10 @@ module LibItsPki_Functions { ...@@ -89,8 +89,10 @@ module LibItsPki_Functions {
f_prepareCertificates(p_certificateId, vc_aaCertificate, vc_atCertificate); f_prepareCertificates(p_certificateId, vc_aaCertificate, vc_atCertificate);
f_readCertificate(p_certificateId, vc_eaCertificate); f_readCertificate(p_certificateId, vc_eaCertificate);
f_readSigningKey(p_certificateId, vc_eaPrivateKey);
f_getCertificateDigest(p_certificateId, vc_eaHashedId8);
} // End of function f_cfHttpUp } // End of function f_cfHttpUp
/** /**
* @desc Deletes default configuration * @desc Deletes default configuration
*/ */
...@@ -210,7 +212,7 @@ module LibItsPki_Functions { ...@@ -210,7 +212,7 @@ module LibItsPki_Functions {
), ),
m_headerInfo_inner_ec_request( m_headerInfo_inner_ec_request(
c_its_aid_SCR, c_its_aid_SCR,
f_getCurrentTime()) f_getCurrentTimeUtc())
); );
// Signed the encoded InnerEcRequestSignedForPop // Signed the encoded InnerEcRequestSignedForPop
v_tbs_signed := f_signWithEcdsaNistp256WithSha256(bit2oct(encvalue(v_tbs)), int2oct(0, 32), p_private_key); v_tbs_signed := f_signWithEcdsaNistp256WithSha256(bit2oct(encvalue(v_tbs)), int2oct(0, 32), p_private_key);
...@@ -238,9 +240,21 @@ module LibItsPki_Functions { ...@@ -238,9 +240,21 @@ module LibItsPki_Functions {
} // End of group inner_ec_xxx } // End of group inner_ec_xxx
group pki_functions { group pki_functions {
/**
* @desc Build a signed and encrypted PKI message
* @param p_private_key Private key for signature
* @param p_signer_identifier Signer identifier for signature, could be self or certificate HashedId8
* @param p_recipientId Recipient identifier to be inclued in encrypted layer.
* If value is int2oct(0. 8), the recipient id is the HashedId8 of the symmetric key used by the sender to encrypt the message to which the response is built
* @param p_publicKeyCompressed The public compressed key (canonical form) for encryption
* @param p_compressedMode The compressed mode of the public compressed key (canonical form) for encryption
* @param p_pki_message The PKI message to be secured
* @param p_ieee1609dot2_signed_and_encrypted_data The secured message
* @return true on success, false otherwise
*/
function f_build_pki_secured_message( function f_build_pki_secured_message(
in Oct32 p_private_key, in octetstring p_private_key,
in SignerIdentifier p_signer_identifier, in SignerIdentifier p_signer_identifier,
in HashedId8 p_recipientId, in HashedId8 p_recipientId,
in Oct32 p_publicKeyCompressed, in Oct32 p_publicKeyCompressed,
...@@ -261,13 +275,13 @@ module LibItsPki_Functions { ...@@ -261,13 +275,13 @@ module LibItsPki_Functions {
var Oct32 v_publicEphemeralKeyCompressed; var Oct32 v_publicEphemeralKeyCompressed;
var integer v_ephemeralKeyModeCompressed; var integer v_ephemeralKeyModeCompressed;
var octetstring v_encrypted_inner_ec_request; var octetstring v_encrypted_inner_ec_request;
// Signed the encoded PKI message // Signed the encoded PKI message
v_tbs := m_toBeSignedData( v_tbs := m_toBeSignedData(
m_signedDataPayload( m_signedDataPayload(
m_etsiTs103097Data_unsecured(p_pki_message) m_etsiTs103097Data_unsecured(p_pki_message)
), ),
m_headerInfo_inner_ec_request(12345, f_getCurrentTime()) // TODO Use PIXIT m_headerInfo_inner_ec_request(12345, f_getCurrentTimeUtc()) // TODO Use PIXIT
); );
if (ischosen(p_signer_identifier.self_)) { if (ischosen(p_signer_identifier.self_)) {
v_tbs_signed := f_signWithEcdsaNistp256WithSha256(bit2oct(encvalue(v_tbs)), int2oct(0, 32), p_private_key); v_tbs_signed := f_signWithEcdsaNistp256WithSha256(bit2oct(encvalue(v_tbs)), int2oct(0, 32), p_private_key);
......
...@@ -116,7 +116,7 @@ module LibItsPki_Templates { ...@@ -116,7 +116,7 @@ module LibItsPki_Templates {
in template (omit) GeographicRegion p_region := omit, in template (omit) GeographicRegion p_region := omit,
in template (omit) SubjectAssurance p_assuranceLevel := omit in template (omit) SubjectAssurance p_assuranceLevel := omit
) := { ) := {
id := { none_ := NULL }, id := { none_ := NULL },
validityPeriod := p_validityPeriod, validityPeriod := p_validityPeriod,
region := p_region, region := p_region,
assuranceLevel := p_assuranceLevel, assuranceLevel := p_assuranceLevel,
......
...@@ -72,6 +72,8 @@ module LibItsPki_TestSystem { ...@@ -72,6 +72,8 @@ module LibItsPki_TestSystem {
type component ItsPkiHttp extends ItsSecurityBaseComponent, HttpComponent { type component ItsPkiHttp extends ItsSecurityBaseComponent, HttpComponent {
var Certificate vc_eaCertificate; /** Test Adapter EA certificate */ var Certificate vc_eaCertificate; /** Test Adapter EA certificate */
var octetstring vc_eaPrivateKey; /** Test Adapter EA proivate key for signature */
var HashedId8 vc_eaHashedId8; /** Test Adapter EA HashedId8 for RecipientId */
} // End of component ItsPki } // End of component ItsPki
type component ItsPkiItss extends ItsGeoNetworking { type component ItsPkiItss extends ItsGeoNetworking {
......
...@@ -1008,7 +1008,7 @@ module LibItsSecurity_Templates { ...@@ -1008,7 +1008,7 @@ module LibItsSecurity_Templates {
template (omit) HeaderInfo m_headerInfo_inner_ec_request( template (omit) HeaderInfo m_headerInfo_inner_ec_request(
in template (value) Psid p_psid := c_its_aid_GN, in template (value) Psid p_psid := c_its_aid_GN,
in template (value) Time64 p_generationTime in template (value) Time64 p_generationTime
) modifies m_ieee1609Dot2_headerInfo := {}; ) modifies m_headerInfo_gn := {};
} // End of group headerFields } // End of group headerFields
......