Skip to content

Expose algorithm field on PublicKey #281

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

Merged
merged 1 commit into from
Jun 30, 2024
Merged

Conversation

rickvanprim
Copy link
Contributor

Fixes #280.

Copy link
Member

@cpu cpu left a comment

Choose a reason for hiding this comment

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

This seems reasonable to me. AIUI this is a capability callers had before #205

@rickvanprim
Copy link
Contributor Author

This seems reasonable to me. AIUI this is a capability callers had before #205

My code on the older version of rcgen did do the algorithm check as it was exposed as part of CertificateParams 🙂

Copy link
Member

@est31 est31 left a comment

Choose a reason for hiding this comment

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

I think it would be better to add it as a function on PublicKey instead, then mut access doesn't allow you to generate invalid configurations.

Also, I wonder whether it makes sense to additionally expose the PublicKeyData trait to the public (I don't like APIs that require you to import a trait, ideally the functions are available both through traits and inherent functions, unless it is a lot of API surface that's covered). Maybe that's a separate discussion though.

@cpu
Copy link
Member

cpu commented Jun 29, 2024

I think it would be better to add it as a function on PublicKey instead, then mut access doesn't allow you to generate invalid configurations.

Sounds reasonable to me.

Also, I wonder whether it makes sense to additionally expose the PublicKeyData trait to the public

I like this direction less personally. I think this trait is a bit awkward (but have a hard time articulating why). I think exposing it in the existing API will make it harder to smooth out any rough edges.

@rickvanprim rickvanprim force-pushed the public_key branch 3 times, most recently from 2c631bc to 843bd7f Compare June 29, 2024 23:40
@rickvanprim
Copy link
Contributor Author

@est31 / @cpu, I changed to a method on PublicKey, which is a copy paste of the method for PublicKeyData. I could make the PublicKeyData method call the method on PublicKey as well if that's preferred, but given how they're both trivial accessors, I'm not sure that serves much point. Please let me know if any further changes are desired 🙂

One small discrepancy I just noticed while adding this to test_csr_roundtrip() is KeyPair::algorithm() vs PublicKeyData::alg().

Copy link
Member

@est31 est31 left a comment

Choose a reason for hiding this comment

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

Thanks!

@rickvanprim rickvanprim changed the title Expose alg field on PublicKey Expose algorithm field on PublicKey Jun 30, 2024
Copy link
Member

@cpu cpu left a comment

Choose a reason for hiding this comment

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

Thanks!

@est31 est31 added this pull request to the merge queue Jun 30, 2024
Merged via the queue into rustls:main with commit 00040fb Jun 30, 2024
15 checks passed
@rickvanprim rickvanprim deleted the public_key branch June 30, 2024 23:32
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.

Expose alg on PublicKey
4 participants