Commits (2)
......@@ -490,6 +490,8 @@ module LibItsSecurity_Templates {
regions := ?
}
}
template (present) HashAlgorithm mw_validEtsiTs103097HashAlgorithm := (sha256, sha384);
} // End of group basicFormatElementsRecv
......@@ -638,7 +640,36 @@ module LibItsSecurity_Templates {
extDataHash := { sha256HashedData := p_extDataHash },
omitted := omit
} // End of template m_signedDataPayload_ext
template (present) SignedDataPayload mw_signedDataPayload_ext(
in template (present) HashedData p_extDataHash := ?
) := {
data := omit,
extDataHash := p_extDataHash,
omitted := omit
} // End of template m_signedDataPayload_ext
template (present) HashedData mw_sha256HashedData (in template (present) octetstring p_extDataHash := ?
) := {
sha256HashedData := p_extDataHash
}
template (present) HashedData mw_sha384HashedData (in template (present) octetstring p_extDataHash := ?
) := {
sha384HashedData := p_extDataHash
}
template (present) HashedData mw_sm3HashedData (in template (present) octetstring p_extDataHash := ?
) := {
sm3HashedData := p_extDataHash
}
template (present) HashedData mw_anyAlgHashedData (in template (present) octetstring p_extDataHash := ?
) := ( mw_sha256HashedData(p_extDataHash), mw_sha384HashedData(p_extDataHash), mw_sm3HashedData(p_extDataHash) );
template (present) HashedData mw_etsiTs103097SupportedAlgHashedData (in template (present) octetstring p_extDataHash := ?
) := ( mw_sha256HashedData(p_extDataHash), mw_sha384HashedData(p_extDataHash) );
} // End of group signedData
/**
......
......@@ -92,6 +92,74 @@ module LibItsSecurity_Functions {
return ''O;
} // End of function f_signWithEcdsa
function f_verifySignedMessageECDSA(
in Ieee1609Dot2Data p_msg,
in template (omit) EtsiTs103097Certificate p_signer := omit,
in template(omit) PublicVerificationKey p_verification_key := omit
) return boolean {
var octetstring v_signer_hash;
var PublicVerificationKey v_verification_key;
if(ischosen(p_msg.content.signedData.signer.self_)){
if(not ispresent(p_verification_key)){
return false; // unsupported yet
}
v_verification_key := valueof(p_verification_key);
select(f_getHashAlgorithmOfVerificationKey(v_verification_key)){
case (sha256){
v_signer_hash := f_hashWithSha256(''O);
}
case (sha384){
v_signer_hash := f_hashWithSha384(''O);
}
case else {
return false;
}
}
}else{
var EtsiTs103097Certificate v_signer;
if(ischosen(p_msg.content.signedData.signer.certificate)){
var integer v_length := lengthof(p_msg.content.signedData.signer.certificate);
if(v_length < 1) {
return false;
}
v_signer := p_msg.content.signedData.signer.certificate[v_length - 1];
}else if(ischosen(p_msg.content.signedData.signer.digest)){
if(ispresent(p_signer)) {
v_signer := valueof(p_signer);
}else{
var charstring v_certificate_id;
if(not f_getCertificateFromDigest(p_msg.content.signedData.signer.digest, v_signer, v_certificate_id)){
return false;
}
}
}else{
return false;
}
if(not ischosen(v_signer.toBeSigned.verifyKeyIndicator.verificationKey)){
return false;
}
v_verification_key := v_signer.toBeSigned.verifyKeyIndicator.verificationKey;
select(f_getHashAlgorithmOfVerificationKey(v_verification_key)){
case (sha256){
v_signer_hash := f_hashWithSha256(bit2oct(encvalue(v_signer)));
}
case (sha384){
v_signer_hash := f_hashWithSha384(bit2oct(encvalue(v_signer)));
}
case else {
return false;
}
}
}
return f_verifyEcdsa(
bit2oct(encvalue(p_msg.content.signedData.tbsData)),
v_signer_hash,
p_msg.content.signedData.signature_,
v_verification_key);
}
function f_verifyEcdsa(
in octetstring p_tbs,
in octetstring p_issuer,
......