Skip to content

pkcs1: split der objects into *Ref and *Owned - #2411

Open
dishmaker wants to merge 14 commits into
RustCrypto:masterfrom
dishmaker:dishmaker/pkcs1_rsapublickey_ref_owned
Open

pkcs1: split der objects into *Ref and *Owned#2411
dishmaker wants to merge 14 commits into
RustCrypto:masterfrom
dishmaker:dishmaker/pkcs1_rsapublickey_ref_owned

Conversation

@dishmaker

@dishmaker dishmaker commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Generic Ref and Owned aliases of der objects

  • pkcs1 progress:
    • OtherPrimeInfo
    • RsaOaepParams
    • RsaPrivateKey
    • RsaPssParams
    • RsaPublicKey

Related issue:

@tarcieri

Copy link
Copy Markdown
Member

Is UintType generic parameter name okay?

I generally use U for that sort of thing

@dishmaker dishmaker changed the title pkcs1: split RsaPublicKey into RsaPublicKeyRef and RsaPublicKeyOwned pkcs1: split der objects into *Ref and *Owned Aug 29, 2026
Comment thread Cargo.toml Outdated
@dishmaker

Copy link
Copy Markdown
Contributor Author

I had to add UintLike trait in der

@tarcieri

Copy link
Copy Markdown
Member

I'd prefer not to add additional traits in this PR, particularly ones unrelated to pkcs1 like IntLike.

Any reason it can't just be AsRef<[u8]>? I mean, it looks like we'd need to add impls, but that seems more straightforward than trying to shoehorn multiple new traits into this PR.

If we really need to add UintLike I'd prefer it be its own PR.

@tarcieri

Copy link
Copy Markdown
Member

I guess the main problem is there's a divergence between Uint(Ref)::to_bytes and its underlying encoding due to the leading zero stripping

@dishmaker

dishmaker commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

I think AsRef<[u8]> for Uint would be unintuitive, because of leading zeros/ones.

But I can add AsRef<[u8]> if you'd like.

@tarcieri

tarcieri commented Aug 29, 2026

Copy link
Copy Markdown
Member

No, that doesn't seem like a good solution either.

One thing that's annoying is UintRef didn't get the same treatment as e.g. OctetStringRef in that it still has a lifetime, which makes writing other bounds annoying (e.g AsRef<UintRef> would be nice here).

So I guess we can do UintLike for now, with a TODO to eventually get rid of it and replace it with AsRef<UintRef>. I'd probably prefer it actually exposed the full UintRef rather than just its bytes, and be added in its own separate PR first.

@dishmaker

dishmaker commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

Edit: I misunderstood you wanted

fn as_uint_ref<'a>(&'a self) -> &UintRef<'a>;

Should I:

  • remove the .len() and .is_empty() from UintRef,
  • or leave it in both UintRef and UintLike trait?

@tarcieri

Copy link
Copy Markdown
Member

I think UintLike should just be a helper to retrieve a UintRef which can be replaced by AsRef<UintRef> in the future when we can make a breaking change from &UintRef<'a> to &'a UintRef.

I don't think there should be a need to add/remove any other methods.

This is needed for `pkcs1` generic `*Ref` and `*Owned` split
patch rsa crate with RustCrypto/RSA commit rev

pkcs1: pub use RsaPublicKey

use RsaPublicKey #[cfg(doc)]

pkcs1: replace UintType with U

pkcs1: split RsaPrivateKey info RsaPrivateKeyRef and Owned

bump RSA patch git commit rev
@dishmaker
dishmaker force-pushed the dishmaker/pkcs1_rsapublickey_ref_owned branch from adf5efa to 9279a2e Compare August 29, 2026 17:56
@dishmaker
dishmaker marked this pull request as ready for review August 30, 2026 14:05
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