Skip to content

Commit

Permalink
security: Move issuer_is_self() to CertificateView
Browse files Browse the repository at this point in the history
  • Loading branch information
xweissada committed Nov 17, 2024
1 parent 7273031 commit b93fb2f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions vanetza/security/v3/certificate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ boost::optional<HashedId8> CertificateView::issuer_digest() const
return digest;
}

bool CertificateView::issuer_is_self() const
{
return m_cert->issuer.present == Vanetza_Security_IssuerIdentifier_PR_self;
}

bool CertificateView::has_region_restriction() const
{
return m_cert ? m_cert->toBeSigned.region != nullptr : false;
Expand Down Expand Up @@ -704,11 +709,6 @@ void Certificate::set_signature(const SomeEcdsaSignature& signature)
m_struct->signature = boost::apply_visitor(signature_visitor(), signature);
}

bool Certificate::issuer_is_self() const
{
return m_struct->issuer.present == Vanetza_Security_IssuerIdentifier_PR_self;
}

Certificate fake_certificate()
{
Certificate certi;
Expand Down
8 changes: 6 additions & 2 deletions vanetza/security/v3/certificate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class CertificateView
*/
boost::optional<HashedId8> issuer_digest() const;

/**
* Check if certificate is self-signed
* \return true if certificate is self-signed
*/
bool issuer_is_self() const;

/**
* Check if certificate is a Certification Authority certificate
* \return true if certificate is a CA certificate
Expand Down Expand Up @@ -136,8 +142,6 @@ struct Certificate : public asn1::asn1c_oer_wrapper<asn1::EtsiTs103097Certificat
void add_cert_permission(asn1::PsidGroupPermissions* group_permission);

void set_signature(const SomeEcdsaSignature& signature);

bool issuer_is_self() const;
};

/**
Expand Down

0 comments on commit b93fb2f

Please sign in to comment.