pub struct CanonicalRequest(/* private fields */);Expand description
The canonical form of a request to be signed or verified.
Implementations§
Source§impl CanonicalRequest
impl CanonicalRequest
Sourcepub fn new(method: &Method, path: &str, query: Option<&str>) -> Self
pub fn new(method: &Method, path: &str, query: Option<&str>) -> Self
Builds the canonical form of a request.
path and query MUST be the raw request path and query string as transmitted/received
on the wire, which means that servers should pass the raw contents of these components, and
clients should ensure that the encoding used to compute the signature matches exactly the
encoding used by their HTTP client.
This is important to avoid any signature verification failures due to different encoding/decoding implementations between the client and server, and is based on the assumption that any intermediate proxies will never re-encode the URL, but always pass it through with the original encoding.
Sourcepub fn sign(&self, key: &SigningKey) -> String
pub fn sign(&self, key: &SigningKey) -> String
Signs this canonical form with Ed25519.
Returns the base64url-encoded signature, suitable as the value of the
PARAM_SIG query parameter.
Sourcepub fn verify(
&self,
key: &VerifyingKey,
signature_b64: &str,
) -> Result<(), Error>
pub fn verify( &self, key: &VerifyingKey, signature_b64: &str, ) -> Result<(), Error>
Verifies a base64url-encoded Ed25519 signature against this canonical form.
§Errors
Returns Error::InvalidKey if key is not a valid Ed25519 verifying key,
Error::InvalidSignatureEncoding if signature_b64 is not valid base64url
or not a 64-byte signature, and Error::VerificationFailed if the signature
does not match.
Trait Implementations§
Source§impl Clone for CanonicalRequest
impl Clone for CanonicalRequest
Source§fn clone(&self) -> CanonicalRequest
fn clone(&self) -> CanonicalRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CanonicalRequest
impl Debug for CanonicalRequest
Source§impl PartialEq for CanonicalRequest
impl PartialEq for CanonicalRequest
Source§fn eq(&self, other: &CanonicalRequest) -> bool
fn eq(&self, other: &CanonicalRequest) -> bool
self and other values to be equal, and is used by ==.