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,
impl<D> SigningKey<D>where
D: Digest + AssociatedOid,
Sourcepub fn new(key: RsaPrivateKey) -> SigningKey<D>
pub fn new(key: RsaPrivateKey) -> SigningKey<D>
Create a new signing key with a prefix for the digest D.
Examples found in repository?
More 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}Sourcepub fn random<R>(rng: &mut R, bit_size: usize) -> Result<SigningKey<D>, Error>where
R: CryptoRngCore + ?Sized,
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.
Sourcepub fn new_with_prefix(key: RsaPrivateKey) -> SigningKey<D>
👎Deprecated since 0.9.0: use SigningKey::new instead
pub fn new_with_prefix(key: RsaPrivateKey) -> SigningKey<D>
Create a new signing key with a prefix for the digest D.
Sourcepub 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
pub fn random_with_prefix<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§impl<D> SigningKey<D>where
D: Digest,
impl<D> SigningKey<D>where
D: Digest,
Sourcepub fn new_unprefixed(key: RsaPrivateKey) -> SigningKey<D>
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.
Sourcepub fn random_unprefixed<R>(
rng: &mut R,
bit_size: usize,
) -> Result<SigningKey<D>, Error>where
R: CryptoRngCore + ?Sized,
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,
impl<D> AsRef<RsaPrivateKey> for SigningKey<D>where
D: Digest,
Source§fn as_ref(&self) -> &RsaPrivateKey
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,
impl<D> AssociatedAlgorithmIdentifier for SigningKey<D>where
D: Digest,
Source§const ALGORITHM_IDENTIFIER: AlgorithmIdentifier<AnyRef<'static>> = pkcs1::ALGORITHM_ID
const ALGORITHM_IDENTIFIER: AlgorithmIdentifier<AnyRef<'static>> = pkcs1::ALGORITHM_ID
AlgorithmIdentifier for this structure.Source§impl<D> Clone for SigningKey<D>
impl<D> Clone for SigningKey<D>
Source§fn clone(&self) -> SigningKey<D>
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)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<D> Debug for SigningKey<D>
impl<D> Debug for SigningKey<D>
Source§impl<D> DigestSigner<D, Signature> for SigningKey<D>where
D: Digest,
impl<D> DigestSigner<D, Signature> for SigningKey<D>where
D: Digest,
Source§fn try_sign_digest(&self, digest: D) -> Result<Signature, Error>
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
fn sign_digest(&self, digest: D) -> S
Source§impl<D> EncodePrivateKey for SigningKey<D>where
D: Digest,
impl<D> EncodePrivateKey for SigningKey<D>where
D: Digest,
Source§fn to_pkcs8_der(&self) -> Result<SecretDocument, Error>
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>
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>
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>
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,
impl<D> From<RsaPrivateKey> for SigningKey<D>where
D: Digest,
Source§fn from(key: RsaPrivateKey) -> SigningKey<D>
fn from(key: RsaPrivateKey) -> SigningKey<D>
Converts to this type from the input type.
Source§impl<D> JWKeyType for SigningKey<D>where
D: Digest,
impl<D> JWKeyType for SigningKey<D>where
D: Digest,
Source§impl JsonWebAlgorithm for SigningKey<Sha256>
impl JsonWebAlgorithm for SigningKey<Sha256>
Source§const IDENTIFIER: AlgorithmIdentifier = crate::algorithms::AlgorithmIdentifier::RS256
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>
impl JsonWebAlgorithm for SigningKey<Sha512>
Source§const IDENTIFIER: AlgorithmIdentifier = crate::algorithms::AlgorithmIdentifier::RS512
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>
impl JsonWebAlgorithm for SigningKey<Sha384>
Source§const IDENTIFIER: AlgorithmIdentifier = crate::algorithms::AlgorithmIdentifier::RS384
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>
impl JsonWebAlgorithmDigest for SigningKey<Sha256>
Source§impl JsonWebAlgorithmDigest for SigningKey<Sha512>
impl JsonWebAlgorithmDigest for SigningKey<Sha512>
Source§impl JsonWebAlgorithmDigest for SigningKey<Sha384>
impl JsonWebAlgorithmDigest for SigningKey<Sha384>
Source§impl<D> Keypair for SigningKey<D>where
D: Digest,
impl<D> Keypair for SigningKey<D>where
D: Digest,
Source§type VerifyingKey = VerifyingKey<D>
type VerifyingKey = VerifyingKey<D>
Verifying key type for this keypair.
Source§fn verifying_key(&self) -> <SigningKey<D> as Keypair>::VerifyingKey
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,
impl<D> PrehashSigner<Signature> for SigningKey<D>where
D: Digest,
Source§impl<D> RandomizedDigestSigner<D, Signature> for SigningKey<D>where
D: Digest,
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>
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
fn sign_digest_with_rng(&self, rng: &mut impl CryptoRngCore, digest: D) -> S
Sign the given prehashed message
Digest, returning a signature. Read moreSource§impl<D> RandomizedSigner<Signature> for SigningKey<D>where
D: Digest,
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>
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
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,
impl<D> SerializeJWK for SigningKey<D>where
D: Digest,
Source§impl<D> SignatureAlgorithmIdentifier for SigningKey<D>where
D: Digest + RsaSignatureAssociatedOid,
impl<D> SignatureAlgorithmIdentifier for SigningKey<D>where
D: Digest + RsaSignatureAssociatedOid,
Source§const SIGNATURE_ALGORITHM_IDENTIFIER: AlgorithmIdentifier<AnyRef<'static>>
const SIGNATURE_ALGORITHM_IDENTIFIER: AlgorithmIdentifier<AnyRef<'static>>
AlgorithmIdentifier for the corresponding singature system.Source§impl<D> TryFrom<PrivateKeyInfo<'_>> for SigningKey<D>where
D: Digest + AssociatedOid,
impl<D> TryFrom<PrivateKeyInfo<'_>> for SigningKey<D>where
D: Digest + AssociatedOid,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DecodeEcPrivateKey for T
impl<T> DecodeEcPrivateKey for T
Source§fn from_sec1_der(private_key: &[u8]) -> Result<T, Error>
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>
fn from_sec1_pem(s: &str) -> Result<Self, Error>
Deserialize SEC1-encoded private key from PEM. Read more
Source§impl<T> DecodePrivateKey for T
impl<T> DecodePrivateKey for T
Source§fn from_pkcs8_der(bytes: &[u8]) -> Result<T, Error>
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>
fn from_pkcs8_pem(s: &str) -> Result<Self, Error>
Deserialize PKCS#8-encoded private key from PEM. Read more
Source§impl<T> DecodeRsaPrivateKey for T
impl<T> DecodeRsaPrivateKey for T
Source§fn from_pkcs1_der(private_key: &[u8]) -> Result<T, Error>
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>
fn from_pkcs1_pem(s: &str) -> Result<Self, Error>
Deserialize PKCS#1-encoded private key from PEM. Read more
Source§impl<T> DynAssociatedAlgorithmIdentifier for Twhere
T: AssociatedAlgorithmIdentifier,
impl<T> DynAssociatedAlgorithmIdentifier for Twhere
T: AssociatedAlgorithmIdentifier,
Source§fn algorithm_identifier(&self) -> Result<AlgorithmIdentifier<Any>, Error>
fn algorithm_identifier(&self) -> Result<AlgorithmIdentifier<Any>, Error>
AlgorithmIdentifier for this structure.Source§impl<T> DynJsonWebAlgorithm for Twhere
T: JsonWebAlgorithm,
impl<T> DynJsonWebAlgorithm for Twhere
T: JsonWebAlgorithm,
Source§fn identifier(&self) -> AlgorithmIdentifier
fn identifier(&self) -> AlgorithmIdentifier
The identifier for this algorithm when used in a JWT registered header.
Source§impl<T> DynJwkKeyType for Twhere
T: JWKeyType,
impl<T> DynJwkKeyType for Twhere
T: JWKeyType,
Source§impl<T> DynSignatureAlgorithmIdentifier for Twhere
T: SignatureAlgorithmIdentifier,
impl<T> DynSignatureAlgorithmIdentifier for Twhere
T: SignatureAlgorithmIdentifier,
Source§fn signature_algorithm_identifier(
&self,
) -> Result<AlgorithmIdentifier<Any>, Error>
fn signature_algorithm_identifier( &self, ) -> Result<AlgorithmIdentifier<Any>, Error>
AlgorithmIdentifier for the corresponding singature system.Source§impl<T> EncodeEcPrivateKey for Twhere
T: EncodePrivateKey,
impl<T> EncodeEcPrivateKey for Twhere
T: EncodePrivateKey,
Source§fn to_sec1_der(&self) -> Result<SecretDocument, Error>
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>
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 moreSource§fn write_sec1_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
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>
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 Twhere
T: EncodePrivateKey,
impl<T> EncodeRsaPrivateKey for Twhere
T: EncodePrivateKey,
Source§fn to_pkcs1_der(&self) -> Result<SecretDocument, Error>
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>
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>
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>
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<S, T> SignerMut<S> for Twhere
T: Signer<S>,
impl<S, T> SignerMut<S> for Twhere
T: Signer<S>,
Source§impl<K, S> TokenSigner<S> for Kwhere
K: JsonWebAlgorithmDigest + SerializePublicJWK + DigestSigner<<K as JsonWebAlgorithmDigest>::Digest, S>,
S: SignatureEncoding,
impl<K, S> TokenSigner<S> for Kwhere
K: JsonWebAlgorithmDigest + SerializePublicJWK + DigestSigner<<K as JsonWebAlgorithmDigest>::Digest, S>,
S: SignatureEncoding,
Source§fn try_sign_token(&self, header: &str, payload: &str) -> Result<S, Error>
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
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