RustCrypto/RSA

Support `From<_> for &RsaPublicKey` and `From<_> for &RsaPrivateKey` for relevant types

LWEdslev opened this issue · 1 comments

For example if I have a pss::VerifyingKey and a function fn foo(key: &RsaPublicKey) I currenctly have to do this:

let key: VerifyingKey<Sha256> = ....;
foo(&key.clone().into()); // if we don't clone here it is moved

whereas a pretty simple implementation could make it

let key: VerifyingKey<Sha256> = ....;
foo((&key).into());

the implementation could be something like:

impl<'a, D> From<&'a VerifyingKey<D>> for &'a RsaPublicKey
where
    D: Digest,
{
    fn from(key: &'a VerifyingKey<D>) -> Self {
        &key.inner
    }
}