RSA icon indicating copy to clipboard operation
RSA copied to clipboard

`RSAPrivateKey::from_components` builder state pattern over Vararg

Open pinkforest opened this issue 4 months ago • 1 comments

Would be feasible to add builder-state pattern over vararg for the from_components

It's kinda pain to remember n/e/d/primes placement and the type/lengths somewhat limit the footgun but regardless

Would be nicer to have

RSAPrivateKey::from_components()
 .n(..)
 .e(..)
 .d(..)
 .primes(..)

pinkforest avatar Aug 21 '25 04:08 pinkforest

It could be interesting, especially as there are different ways keys could be build from components (e.g. from just d and n assuming a default e of 65537, or from the primes alone assuming a default e).

Perhaps it could just be RsaPrivateKey::builder or RsaComponents rather than reusing the from_components name, which would let us preserve but deprecate the old API. I would like for the next release to be as drop-in as possible so people can easily upgrade to get the security benefits.

tarcieri avatar Aug 21 '25 16:08 tarcieri