fn sign_rsa(
    alg: &'static dyn signature::RsaEncoding,
    key: Key<'_>,
    signing_input: &str,
) -> Result<String, Error> {
    let key_pair = match key {
        Key::Pkcs8(bytes) => {
            signature::RsaKeyPair::from_pkcs8(bytes).map_err(Error::InvalidRsaKeyRejected)?
        }
    };

    let key_pair = std::sync::Arc::new(key_pair);
    let mut signature = vec![0; key_pair.public_modulus_len()];
    let rng = ring::rand::SystemRandom::new();
    key_pair
        .sign(alg, &rng, signing_input.as_bytes(), &mut signature)
        .map_err(Error::InvalidRsaKey)?;

    Ok(base64::encode_config(&signature, base64::URL_SAFE_NO_PAD))
}
/// The actual RSA signing + encoding
/// Taken from Ring doc <https://briansmith.org/rustdoc/ring/signature/index.html>
The actual RSA signing + encoding
Taken from Ring doc
The actual RSA signing + encoding Taken from Ring doc
fn sign_rsa(
    alg: &'static dyn signature::RsaEncoding,
    key: Key<'_>,
    signing_input: &str,
) -> Result<String, Error> {
    let key_pair = match key {
        Key::Pkcs8(bytes) => {
            signature::RsaKeyPair::from_pkcs8(bytes).map_err(Error::InvalidRsaKeyRejected)?
        }
    };
    let key_pair = std::sync::Arc::new(key_pair);
    let mut signature = vec![0; key_pair.public_modulus_len()];
    let rng = ring::rand::SystemRandom::new();
    key_pair
        .sign(alg, &rng, signing_input.as_bytes(), &mut signature)
        .map_err(Error::InvalidRsaKey)?;
    Ok(base64::encode_config(&signature, base64::URL_SAFE_NO_PAD))
}
fn sign_rsa ( alg : & ' static dyn signature :: RsaEncoding , key : Key < ' _ > , signing_input : & str , ) -> Result < String , Error > { let key_pair = match key { Key :: Pkcs8 ( bytes ) => { signature :: RsaKeyPair :: from_pkcs8 ( bytes ) . map_err ( Error :: InvalidRsaKeyRejected ) ? } } ; let key_pair = std :: sync :: Arc :: new ( key_pair ) ; let mut signature = vec ! [ 0 key_pair public_modulus_len ( ) ] ; let rng = ring :: rand :: SystemRandom :: new ( ) ; key_pair . sign ( alg , & rng , signing_input . as_bytes ( ) , & mut signature ) . map_err ( Error :: InvalidRsaKey ) ? ; Ok ( base64 :: encode_config ( & signature , base64 :: URL_SAFE_NO_PAD ) ) }
The actual RSA signing + encoding
Taken from Ring doc <https://briansmith.org/rustdoc/ring/signature/index.html>
The actual RSA signing + encoding Taken from Ring doc <https : // briansmith . org / rustdoc / ring / signature / index . html >
alg
&'static dyn signature::RsaEncoding
key
Key<'_>
signing_input
&str