RustCrypto / formats

Cryptography-related format encoders/decoders: DER, PEM, PKCS, PKIX
228 stars 121 forks source link

der: introduce an `AnyLike` trait to mark parameters #1415

Closed baloo closed 1 month ago

baloo commented 1 month ago

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

baloo commented 1 month ago

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

baloo commented 1 month ago

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

tarcieri commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 :shrug: Sorry for the noise and the distraction.