Skip to content

Improve RFC 3779 extension api #4890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arckoor
Copy link
Contributor

@arckoor arckoor commented May 27, 2025

#4699 added x509 extensions for RFC 3779. While working on #4877 I realized that the api for actually using them is kind of horrible.

Comment on lines +1513 to +1516
if (!m_asnum.has_value() && !m_rdi.has_value()) {
throw Encoding_Error("One of asnum, rdi must be present");
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When just doing auto ext = std::make_unique<ASBlocks>(), nothing is set initially, so the (std::nullopt, std::nullopt) case that was previously caught by the ASIdentifiers constructor now needs to be caught here too

Comment on lines 751 to 755
ASIdOrRange() = default;

ASIdOrRange(asnum_t id) : m_min(id), m_max(id) {}

ASIdOrRange(asnum_t min, asnum_t max) : m_min(min), m_max(max) {
if(max < min) {
throw Decoding_Error("AS range numbers must be sorted");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to make these constructors private too, but that clashes both with our helper methods in x509_ext.cpp as well as with BER_Decoder

@arckoor
Copy link
Contributor Author

arckoor commented May 27, 2025

I'm not sure why we didn't do it this way in the first place, sorry about that. I think doing it this way is way nicer for the user, because they don't need to understand the semantic of a random std::nullopt somewhere, they can just say "please inherit". I'm still a little unsure how to do it cleanly for the IPAddressBlocks extension with its high usage of templates, but I'll see what comes up.

@coveralls
Copy link

Coverage Status

coverage: 90.972% (-0.003%) from 90.975%
when pulling 831bec7 on arckoor:improve-rfc3779-api
into 5fbcc7d on randombit:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants