Struct SigningKey

Source
pub struct SigningKey<D>
where D: Digest,
{ /* private fields */ }
Available on crate feature rsa only.
Expand description

Signing key for RSASSA-PKCS1-v1_5 signatures as described in RFC8017 § 8.2.

Implementations§

Source§

impl<D> SigningKey<D>
where D: Digest + AssociatedOid,

Source

pub fn new(key: RsaPrivateKey) -> SigningKey<D>

Create a new signing key with a prefix for the digest D.

Examples found in repository?
tests/dyn-rsa-key.rs (line 31)
30fn rsa_signer() -> rsa::pkcs1v15::SigningKey<Sha256> {
31    rsa::pkcs1v15::SigningKey::<Sha256>::new(rsa_private())
32}
More examples
Hide additional examples
examples/acme-new-account.rs (line 50)
36fn main() {
37    // This key is from RFC 7515, Appendix A.2. Provide your own key instead!
38    // The key here is stored as a PKCS#8 PEM file, but you can leverage
39    // RustCrypto to load a variety of other formats.
40    let key = rsa::RsaPrivateKey::from_pkcs8_pem(include_str!(concat!(
41        env!("CARGO_MANIFEST_DIR"),
42        "/examples/rfc7515a2.pem"
43    )))
44    .unwrap();
45
46    // We will sign the JWT with the RS256 algorithm: RSA with SHA-256.
47    // RsaPkcs1v15 is really an alias to the digital signature algorithm
48    // implementation in the `rsa` crate, but provided in JAWS to make
49    // it clear which types are compatible with JWTs.
50    let alg = rsa::pkcs1v15::SigningKey::<Sha256>::new(key);
51
52    let payload = json!({
53      "termsOfServiceAgreed": true,
54      "contact": [
55        "mailto:cert-admin@example.org",
56        "mailto:admin@example.org"
57      ]
58    });
59
60    let header = json!({
61        "nonce": "6S8IqOGY7eL2lsGoTZYifg",
62        "url": "https://example.com/acme/new-account"
63    });
64
65    // Create a token with the default headers, and no custom headers.
66    let mut token = Token::new(payload, header, Compact);
67    // Request that the token header include a JWK field.
68    token.header_mut().key().derived();
69
70    // Sign the token with the algorithm and key we specified above.
71    let signed = token.sign::<_, rsa::pkcs1v15::Signature>(&alg).unwrap();
72
73    // Print the token in the ACME example format.
74    println!("{}", signed.formatted());
75}
examples/rfc7515a2.rs (line 47)
36fn main() -> Result<(), Box<dyn std::error::Error>> {
37    // This key is from RFC 7515, Appendix A.2. Provide your own key instead!
38    // The key here is stored as a PKCS#8 PEM file, but you can leverage
39    // RustCrypto to load a variety of other formats.
40    let key = rsa::RsaPrivateKey::from_pkcs8_pem(include_str!(concat!(
41        env!("CARGO_MANIFEST_DIR"),
42        "/examples/rfc7515a2.pem"
43    )))
44    .unwrap();
45
46    // We will sign the JWT with the RS256 algorithm: RSA with SHA-256.
47    let alg = rsa::pkcs1v15::SigningKey::<Sha256>::new(key);
48
49    // Claims can combine registered and custom fields. The claims object
50    // can be any type which implements [serde::Serialize].
51    let claims: Claims<serde_json::Value, (), String, (), ()> = Claims {
52        registered: RegisteredClaims {
53            subject: "1234567890".to_string().into(),
54            ..Default::default()
55        },
56        claims: json!({
57            "name": "John Doe",
58            "admin": true,
59        }),
60    };
61
62    // Create a token with the default headers, and no custom headers.
63    // The unit type can be used here because it implements [serde::Serialize],
64    // but a custom type could be passed if we wanted to have custom header
65    // fields.
66    let mut token = Token::compact((), claims);
67
68    // We can modify the headers freely before signing the JWT. In this case,
69    // we provide the `typ` header, which is optional in the JWT spec.
70    *token.header_mut().r#type() = Some("JWT".to_string());
71
72    // We can also ask that some fields be derived from the signing key, for example,
73    // this will derive the JWK field in the header from the signing key.
74    token.header_mut().key().derived();
75
76    println!("=== Initial JWT ===");
77    // Initially the JWT has no defined signature:
78    println!("{}", token.formatted());
79
80    // Sign the token with the algorithm, and print the result.
81    let signed = token.sign::<_, rsa::pkcs1v15::Signature>(&alg).unwrap();
82
83    println!("=== Signed JWT ===");
84
85    println!("JWT:");
86    println!("{}", signed.formatted());
87    println!("Token: {}", signed.rendered().unwrap());
88
89    // We can't modify the token after signing it (that would change the signature)
90    // but we can access fields and read from them:
91    println!(
92        "Type: {:?}, Algorithm: {:?}",
93        signed.header().r#type(),
94        signed.header().algorithm(),
95    );
96
97    // We can also verify tokens.
98    let token: Token<Claims<serde_json::Value>, Unverified<()>, Compact> =
99        signed.rendered().unwrap().parse().unwrap();
100
101    println!("=== Parsed JWT ===");
102
103    // Unverified tokens can be printed for debugging, but there is deliberately
104    // no access to the payload, only to the header fields.
105    println!("JWT:");
106    println!("{}", token.formatted());
107
108    // We can use the JWK to verify that the token is signed with the correct key.
109    let hdr = token.header();
110    let jwk = hdr.key().unwrap();
111    let key = rsa::RsaPublicKey::from_jwk(jwk).unwrap();
112
113    assert_eq!(&key, alg.verifying_key().as_ref());
114    println!("=== Verification === ");
115    let alg: rsa::pkcs1v15::VerifyingKey<Sha256> = alg.verifying_key();
116
117    // We can't access the claims until we verify the token.
118    let verified = token
119        .verify::<_, jaws::algorithms::SignatureBytes>(&alg)
120        .unwrap();
121
122    println!("=== Verified JWT ===");
123    println!("JWT:");
124    println!("{}", verified.formatted());
125    println!(
126        "Payload: \n{}",
127        serde_json::to_string_pretty(&verified.payload()).unwrap()
128    );
129
130    Ok(())
131}
examples/dyn-key.rs (line 34)
18fn main() -> Result<(), Box<dyn std::error::Error>> {
19    // This key is from RFC 7515, Appendix A.2. Provide your own key instead!
20    // The key here is stored as a PKCS#8 PEM file, but you can leverage
21    // RustCrypto to load a variety of other formats.
22    let signing_key = rsa::RsaPrivateKey::from_pkcs8_pem(include_str!(concat!(
23        env!("CARGO_MANIFEST_DIR"),
24        "/examples/rfc7515a2.pem"
25    )))
26    .unwrap();
27    let verify_key: rsa::pkcs1v15::VerifyingKey<Sha256> =
28        rsa::pkcs1v15::VerifyingKey::new(signing_key.to_public_key());
29
30    // We will sign the JWT with a type-erased algorithm, and use a type-erased
31    // verifier to verify it. This allows you to use a set of verifiers which
32    // are not known at compile time.
33    let dyn_signing_key: Box<dyn TokenSigner<SignatureBytes>> = Box::new(
34        rsa::pkcs1v15::SigningKey::<Sha256>::new(signing_key.clone()),
35    );
36    let dyn_verify_key: Box<dyn TokenVerifier<SignatureBytes>> = Box::new(verify_key.clone());
37
38    // Claims can combine registered and custom fields. The claims object
39    // can be any type which implements [serde::Serialize].
40    let claims: Claims<serde_json::Value, (), String, (), ()> = Claims {
41        registered: RegisteredClaims {
42            subject: "1234567890".to_string().into(),
43            ..Default::default()
44        },
45        claims: json!({
46            "name": "John Doe",
47            "admin": true,
48        }),
49    };
50
51    // Create a token with the default headers, and no custom headers.
52    // The unit type can be used here because it implements [serde::Serialize],
53    // but a custom type could be passed if we wanted to have custom header
54    // fields.
55    let mut token = Token::compact((), claims);
56    // We can modify the headers freely before signing the JWT. In this case,
57    // we provide the `typ` header, which is optional in the JWT spec.
58    *token.header_mut().r#type() = Some("JWT".to_string());
59
60    // We can also ask that some fields be derived from the signing key, for example,
61    // this will derive the JWK field in the header from the signing key.
62    token.header_mut().key().derived();
63
64    println!("=== Initial JWT ===");
65
66    // Initially the JWT has no defined signature:
67    println!("{}", token.formatted());
68
69    // Sign the token with the algorithm, and print the result.
70    let signed = token
71        .sign::<_, SignatureBytes>(dyn_signing_key.as_ref())
72        .unwrap();
73
74    let rendered = signed.rendered().unwrap();
75
76    // We can also verify tokens.
77    let token: Token<Claims<serde_json::Value>, Unverified<()>, Compact> =
78        rendered.parse().unwrap();
79
80    println!("=== Parsed JWT ===");
81
82    // Unverified tokens can be printed for debugging, but there is deliberately
83    // no access to the payload, only to the header fields.
84    println!("JWT:");
85    println!("{}", token.formatted());
86
87    // We can use the JWK to verify that the token is signed with the correct key.
88    let hdr = token.header();
89    let jwk = hdr.key().unwrap();
90    let key: rsa::pkcs1v15::VerifyingKey<Sha256> =
91        rsa::pkcs1v15::VerifyingKey::new(rsa::RsaPublicKey::from_jwk(jwk).unwrap());
92
93    println!("=== Verification === ");
94    // Check it against the verified key
95    token
96        .clone()
97        .verify::<_, rsa::pkcs1v15::Signature>(&verify_key)
98        .unwrap();
99    println!(
100        "Verified with verify key (typed): {}",
101        type_name_of_val(&verify_key)
102    );
103
104    // Check it against the verified key
105    let verified = token
106        .clone()
107        .verify::<_, SignatureBytes>(dyn_verify_key.as_ref())
108        .unwrap();
109    println!(
110        "Verified with dyn verify key: {}",
111        type_name_of_val(&dyn_verify_key)
112    );
113
114    // Check it against its own JWT
115    token
116        .clone()
117        .verify::<_, rsa::pkcs1v15::Signature>(&key)
118        .unwrap();
119    println!("Verified with JWK");
120
121    println!("=== Verified JWT ===");
122    println!("JWT:");
123    println!("{}", verified.formatted());
124    println!(
125        "Payload: \n{}",
126        serde_json::to_string_pretty(&verified.payload()).unwrap()
127    );
128
129    Ok(())
130}
Source

pub fn random<R>(rng: &mut R, bit_size: usize) -> Result<SigningKey<D>, Error>
where R: CryptoRngCore + ?Sized,

Generate a new signing key with a prefix for the digest D.

Source

pub fn new_with_prefix(key: RsaPrivateKey) -> SigningKey<D>

👎Deprecated since 0.9.0: use SigningKey::new instead

Create a new signing key with a prefix for the digest D.

Source

pub fn random_with_prefix<R>( rng: &mut R, bit_size: usize, ) -> Result<SigningKey<D>, Error>
where R: CryptoRngCore + ?Sized,

👎Deprecated since 0.9.0: use SigningKey::random instead

Generate a new signing key with a prefix for the digest D.

Source§

impl<D> SigningKey<D>
where D: Digest,

Source

pub fn new_unprefixed(key: RsaPrivateKey) -> SigningKey<D>

Create a new signing key from the give RSA private key with an empty prefix.

§Note: unprefixed signatures are uncommon

In most cases you’ll want to use SigningKey::new.

Source

pub fn random_unprefixed<R>( rng: &mut R, bit_size: usize, ) -> Result<SigningKey<D>, Error>
where R: CryptoRngCore + ?Sized,

Generate a new signing key with an empty prefix.

Trait Implementations§

Source§

impl<D> AsRef<RsaPrivateKey> for SigningKey<D>
where D: Digest,

Source§

fn as_ref(&self) -> &RsaPrivateKey

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<D> AssociatedAlgorithmIdentifier for SigningKey<D>
where D: Digest,

Source§

const ALGORITHM_IDENTIFIER: AlgorithmIdentifier<AnyRef<'static>> = pkcs1::ALGORITHM_ID

AlgorithmIdentifier for this structure.
Source§

type Params = AnyRef<'static>

Algorithm parameters.
Source§

impl<D> Clone for SigningKey<D>
where D: Clone + Digest,

Source§

fn clone(&self) -> SigningKey<D>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D> Debug for SigningKey<D>
where D: Debug + Digest,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<D> DigestSigner<D, Signature> for SigningKey<D>
where D: Digest,

Source§

fn try_sign_digest(&self, digest: D) -> Result<Signature, Error>

Attempt to sign the given prehashed message Digest, returning a digital signature on success, or an error if something went wrong.
Source§

fn sign_digest(&self, digest: D) -> S

Sign the given prehashed message Digest, returning a signature. Read more
Source§

impl<D> EncodePrivateKey for SigningKey<D>
where D: Digest,

Source§

fn to_pkcs8_der(&self) -> Result<SecretDocument, Error>

Serialize a SecretDocument containing a PKCS#8-encoded private key.
Source§

fn to_pkcs8_pem( &self, line_ending: LineEnding, ) -> Result<Zeroizing<String>, Error>

Serialize this private key as PEM-encoded PKCS#8 with the given LineEnding.
Source§

fn write_pkcs8_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>

Write ASN.1 DER-encoded PKCS#8 private key to the given path
Source§

fn write_pkcs8_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding, ) -> Result<(), Error>

Write ASN.1 DER-encoded PKCS#8 private key to the given path
Source§

impl<D> From<RsaPrivateKey> for SigningKey<D>
where D: Digest,

Source§

fn from(key: RsaPrivateKey) -> SigningKey<D>

Converts to this type from the input type.
Source§

impl<D> JWKeyType for SigningKey<D>
where D: Digest,

Source§

const KEY_TYPE: &'static str = "RSA"

The string used to identify the JWK type in the kty field.
Source§

impl JsonWebAlgorithm for SigningKey<Sha256>

Source§

const IDENTIFIER: AlgorithmIdentifier = crate::algorithms::AlgorithmIdentifier::RS256

The identifier for this algorithm when used in a JWT registered header. Read more
Source§

impl JsonWebAlgorithm for SigningKey<Sha512>

Source§

const IDENTIFIER: AlgorithmIdentifier = crate::algorithms::AlgorithmIdentifier::RS512

The identifier for this algorithm when used in a JWT registered header. Read more
Source§

impl JsonWebAlgorithm for SigningKey<Sha384>

Source§

const IDENTIFIER: AlgorithmIdentifier = crate::algorithms::AlgorithmIdentifier::RS384

The identifier for this algorithm when used in a JWT registered header. Read more
Source§

impl JsonWebAlgorithmDigest for SigningKey<Sha256>

Source§

type Digest = CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>

The digest algorithm used by this signature.
Source§

impl JsonWebAlgorithmDigest for SigningKey<Sha512>

Source§

type Digest = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, OidSha512>>

The digest algorithm used by this signature.
Source§

impl JsonWebAlgorithmDigest for SigningKey<Sha384>

Source§

type Digest = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>, B0>, B0>, OidSha384>>

The digest algorithm used by this signature.
Source§

impl<D> Keypair for SigningKey<D>
where D: Digest,

Source§

type VerifyingKey = VerifyingKey<D>

Verifying key type for this keypair.
Source§

fn verifying_key(&self) -> <SigningKey<D> as Keypair>::VerifyingKey

Get the verifying key which can verify signatures produced by the signing key portion of this keypair.
Source§

impl<D> PrehashSigner<Signature> for SigningKey<D>
where D: Digest,

Source§

fn sign_prehash(&self, prehash: &[u8]) -> Result<Signature, Error>

Attempt to sign the given message digest, returning a digital signature on success, or an error if something went wrong. Read more
Source§

impl<D> RandomizedDigestSigner<D, Signature> for SigningKey<D>
where D: Digest,

Source§

fn try_sign_digest_with_rng( &self, rng: &mut impl CryptoRngCore, digest: D, ) -> Result<Signature, Error>

Attempt to sign the given prehashed message Digest, returning a digital signature on success, or an error if something went wrong.
Source§

fn sign_digest_with_rng(&self, rng: &mut impl CryptoRngCore, digest: D) -> S

Sign the given prehashed message Digest, returning a signature. Read more
Source§

impl<D> RandomizedSigner<Signature> for SigningKey<D>
where D: Digest,

Source§

fn try_sign_with_rng( &self, rng: &mut impl CryptoRngCore, msg: &[u8], ) -> Result<Signature, Error>

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign_with_rng(&self, rng: &mut impl CryptoRngCore, msg: &[u8]) -> S

Sign the given message and return a digital signature
Source§

impl<D> SerializeJWK for SigningKey<D>
where D: Digest,

Source§

fn parameters(&self) -> Vec<(String, Value)>

Return a list of parameters to be serialized in the JWK.
Source§

impl<D> SignatureAlgorithmIdentifier for SigningKey<D>

Source§

const SIGNATURE_ALGORITHM_IDENTIFIER: AlgorithmIdentifier<AnyRef<'static>>

AlgorithmIdentifier for the corresponding singature system.
Source§

type Params = AnyRef<'static>

Algorithm parameters.
Source§

impl<D> Signer<Signature> for SigningKey<D>
where D: Digest,

Source§

fn try_sign(&self, msg: &[u8]) -> Result<Signature, Error>

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign(&self, msg: &[u8]) -> S

Sign the given message and return a digital signature
Source§

impl<D> TryFrom<PrivateKeyInfo<'_>> for SigningKey<D>
where D: Digest + AssociatedOid,

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( private_key_info: PrivateKeyInfo<'_>, ) -> Result<SigningKey<D>, Error>

Performs the conversion.
Source§

impl<D> ZeroizeOnDrop for SigningKey<D>
where D: Digest,

Auto Trait Implementations§

§

impl<D> Freeze for SigningKey<D>

§

impl<D> RefUnwindSafe for SigningKey<D>
where D: RefUnwindSafe,

§

impl<D> Send for SigningKey<D>
where D: Send,

§

impl<D> Sync for SigningKey<D>
where D: Sync,

§

impl<D> Unpin for SigningKey<D>
where D: Unpin,

§

impl<D> UnwindSafe for SigningKey<D>
where D: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DecodeEcPrivateKey for T
where T: for<'a> TryFrom<PrivateKeyInfo<'a>, Error = Error>,

Source§

fn from_sec1_der(private_key: &[u8]) -> Result<T, Error>

Deserialize SEC1 private key from ASN.1 DER-encoded data (binary format).
Source§

fn from_sec1_pem(s: &str) -> Result<Self, Error>

Deserialize SEC1-encoded private key from PEM. Read more
Source§

fn read_sec1_der_file(path: impl AsRef<Path>) -> Result<Self, Error>

Load SEC1 private key from an ASN.1 DER-encoded file on the local filesystem (binary format).
Source§

fn read_sec1_pem_file(path: impl AsRef<Path>) -> Result<Self, Error>

Load SEC1 private key from a PEM-encoded file on the local filesystem.
Source§

impl<T> DecodePrivateKey for T
where T: for<'a> TryFrom<PrivateKeyInfo<'a>, Error = Error>,

Source§

fn from_pkcs8_der(bytes: &[u8]) -> Result<T, Error>

Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary format).
Source§

fn from_pkcs8_pem(s: &str) -> Result<Self, Error>

Deserialize PKCS#8-encoded private key from PEM. Read more
Source§

fn read_pkcs8_der_file(path: impl AsRef<Path>) -> Result<Self, Error>

Load PKCS#8 private key from an ASN.1 DER-encoded file on the local filesystem (binary format).
Source§

fn read_pkcs8_pem_file(path: impl AsRef<Path>) -> Result<Self, Error>

Load PKCS#8 private key from a PEM-encoded file on the local filesystem.
Source§

impl<T> DecodeRsaPrivateKey for T
where T: for<'a> TryFrom<PrivateKeyInfo<'a>, Error = Error>,

Source§

fn from_pkcs1_der(private_key: &[u8]) -> Result<T, Error>

Deserialize PKCS#1 private key from ASN.1 DER-encoded data (binary format).
Source§

fn from_pkcs1_pem(s: &str) -> Result<Self, Error>

Deserialize PKCS#1-encoded private key from PEM. Read more
Source§

fn read_pkcs1_der_file(path: impl AsRef<Path>) -> Result<Self, Error>

Load PKCS#1 private key from an ASN.1 DER-encoded file on the local filesystem (binary format).
Source§

fn read_pkcs1_pem_file(path: impl AsRef<Path>) -> Result<Self, Error>

Load PKCS#1 private key from a PEM-encoded file on the local filesystem.
Source§

impl<T> DynAssociatedAlgorithmIdentifier for T

Source§

fn algorithm_identifier(&self) -> Result<AlgorithmIdentifier<Any>, Error>

AlgorithmIdentifier for this structure.
Source§

impl<T> DynJsonWebAlgorithm for T

Source§

fn identifier(&self) -> AlgorithmIdentifier

The identifier for this algorithm when used in a JWT registered header.
Source§

impl<T> DynJwkKeyType for T
where T: JWKeyType,

Source§

fn key_type(&self) -> &'static str

The string used to identify the JWK type in the kty field.
Source§

impl<T> DynSignatureAlgorithmIdentifier for T

Source§

fn signature_algorithm_identifier( &self, ) -> Result<AlgorithmIdentifier<Any>, Error>

AlgorithmIdentifier for the corresponding singature system.
Source§

impl<T> EncodeEcPrivateKey for T

Source§

fn to_sec1_der(&self) -> Result<SecretDocument, Error>

Serialize a SecretDocument containing a SEC1-encoded private key.
Source§

fn to_sec1_pem( &self, line_ending: LineEnding, ) -> Result<Zeroizing<String>, Error>

Serialize this private key as PEM-encoded SEC1 with the given LineEnding. Read more
Source§

fn write_sec1_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>

Write ASN.1 DER-encoded SEC1 private key to the given path.
Source§

fn write_sec1_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding, ) -> Result<(), Error>

Write ASN.1 DER-encoded SEC1 private key to the given path.
Source§

impl<T> EncodeRsaPrivateKey for T

Source§

fn to_pkcs1_der(&self) -> Result<SecretDocument, Error>

Serialize a SecretDocument containing a PKCS#1-encoded private key.
Source§

fn to_pkcs1_pem( &self, line_ending: LineEnding, ) -> Result<Zeroizing<String>, Error>

Serialize this private key as PEM-encoded PKCS#1 with the given LineEnding.
Source§

fn write_pkcs1_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>

Write ASN.1 DER-encoded PKCS#1 private key to the given path.
Source§

fn write_pkcs1_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding, ) -> Result<(), Error>

Write ASN.1 DER-encoded PKCS#1 private key to the given path.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<S, T> SignerMut<S> for T
where T: Signer<S>,

Source§

fn try_sign(&mut self, msg: &[u8]) -> Result<S, Error>

Attempt to sign the given message, updating the state, and returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign(&mut self, msg: &[u8]) -> S

Sign the given message, update the state, and return a digital signature.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<K, S> TokenSigner<S> for K

Source§

fn try_sign_token(&self, header: &str, payload: &str) -> Result<S, Error>

Sign the contents of the JWT, when provided with the base64url-encoded header and payload. The header and payload are already serialized to JSON and then base64url-encoded, so this function should not perform any additional encoding. Read more
Source§

fn sign_token(&self, header: &str, payload: &str) -> S

Sign the contents of the JWT, when provided with the base64url-encoded header and payload. See TokenSigner::try_sign_token for more details. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,