Skip to content
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

der: introduce an AnyLike trait to mark parameters #1415

Closed
wants to merge 7 commits into from

Conversation

baloo
Copy link
Member

@baloo baloo commented May 23, 2024

This newly defined AnyLike trait would help to make sure the parameters of spki::AlgorithmIdentifier are serialized as Any.

spki/src/lib.rs Outdated
//! use spki::{AlgorithmIdentifier, ObjectIdentifier};
//!
//! let alg_oid = "1.2.840.10045.2.1".parse::<ObjectIdentifier>().unwrap();
//! let params_oid = "1.2.840.10045.3.1.7".parse::<ObjectIdentifier>().unwrap();
//!
//! let alg_id = AlgorithmIdentifier {
//! oid: alg_oid,
//! parameters: Some(params_oid)
//! parameters: Some(Any::encode_from(&params_oid).unwrap())
Copy link
Member Author

Choose a reason for hiding this comment

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

I believe this was a regression introduced in #769

Copy link
Member

Choose a reason for hiding this comment

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

How is this a regression? The change seems like a regression.

@baloo baloo force-pushed the baloo/der/anylike branch from 8fb7e3f to 52ce7fd Compare May 23, 2024 03:30
@baloo
Copy link
Member Author

baloo commented May 23, 2024

Last set of CI errors are related to #799 I think.

@baloo
Copy link
Member Author

baloo commented May 23, 2024

cc @lumag

That last commit partially reverts #799 and #1010

I can't really find a way to keep the new_with_label functions in RsaOaepParams and RsaPssParams

@baloo baloo force-pushed the baloo/der/anylike branch from e1e7d61 to e28a8ea Compare May 23, 2024 20:21
@baloo baloo force-pushed the baloo/der/anylike branch from 17948e6 to 68cef0e Compare May 24, 2024 02:58
@tarcieri
Copy link
Member

tarcieri commented May 24, 2024

I'm not sure I understand the purpose of this trait or why you're adding bounds for it, nearly all of which seem unused?

parameters of spki::AlgorithmIdentifier are serialized as Any.

...but ANY represents... any type, so this is definitionally always true.

@tarcieri
Copy link
Member

tarcieri commented May 24, 2024

I guess your goal here is to try to constrain the parameters specifically to the der crate's Any and AnyRef types....

...but that seems needlessly restrictive. The ASN.1 concept of ANY allows for any type in that position. It's closer in concept to the original generic parameter.

Is there a specific motivation for this change?

@tarcieri
Copy link
Member

tarcieri commented May 24, 2024

Notably this precludes using e.g. PemReader in a heapless no_std environment to decode Params to an owned, stack-allocated type, which seems like a regression.

@baloo
Copy link
Member Author

baloo commented May 24, 2024

The motivation was to compare the parameter to AnyRef::NULL or Any::null() (get access to is_null()). But I guess I forgot the typesystem was already telling that to me 🤷
Sorry for the noise and the distraction.

@baloo baloo closed this May 24, 2024
@baloo baloo deleted the baloo/der/anylike branch May 24, 2024 15:38
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