Skip to content

Commit

Permalink
security: fix inclusion of certificate requests in v3::SecuredMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
riebl committed Sep 10, 2024
1 parent 6f7cf39 commit b2c2703
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions vanetza/security/v3/secured_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,24 +179,29 @@ void SecuredMessage::set_generation_location(const asn1::ThreeDLocation& locatio
void SecuredMessage::set_inline_p2pcd_request(std::list<HashedId3> requests)
{
if (m_struct->content->present == Vanetza_Security_Ieee1609Dot2Content_PR_signedData) {
ASN_STRUCT_FREE_CONTENTS_ONLY(
asn_DEF_Vanetza_Security_SequenceOfHashedId3,
&(m_struct->content->choice.signedData->tbsData->headerInfo.inlineP2pcdRequest)
);
assert(m_struct->content->choice.signedData);
assert(m_struct->content->choice.signedData->tbsData);

if (m_struct->content->choice.signedData->tbsData->headerInfo.inlineP2pcdRequest) {
ASN_STRUCT_RESET(asn_DEF_Vanetza_Security_SequenceOfHashedId3,
&m_struct->content->choice.signedData->tbsData->headerInfo.inlineP2pcdRequest);
}

for (HashedId3 request : requests) {
this->add_inline_p2pcd_request(request);
}
}

}

void SecuredMessage::add_inline_p2pcd_request(HashedId3 unkown_certificate_digest)
void SecuredMessage::add_inline_p2pcd_request(HashedId3 unknown_certificate_digest)
{
if (m_struct->content->present == Vanetza_Security_Ieee1609Dot2Content_PR_signedData) {
if (m_struct->content->choice.signedData->tbsData->headerInfo.inlineP2pcdRequest == nullptr) {
if (m_struct->content->choice.signedData->tbsData->headerInfo.inlineP2pcdRequest == nullptr) {
m_struct->content->choice.signedData->tbsData->headerInfo.inlineP2pcdRequest = asn1::allocate<asn1::SequenceOfHashedId3>();
}
ASN_SEQUENCE_ADD(&(m_struct->content->choice.signedData->tbsData->headerInfo.inlineP2pcdRequest), &unkown_certificate_digest);
Vanetza_Security_HashedId3_t* asn_digest = OCTET_STRING_new_fromBuf(&asn_DEF_Vanetza_Security_HashedId3,
reinterpret_cast<char*>(unknown_certificate_digest.data()), unknown_certificate_digest.size());
ASN_SEQUENCE_ADD(m_struct->content->choice.signedData->tbsData->headerInfo.inlineP2pcdRequest, asn_digest);
}
}

Expand Down

0 comments on commit b2c2703

Please sign in to comment.