-
Notifications
You must be signed in to change notification settings - Fork 103
ref(auth): add support for prehashed signature creation #5012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
/// Used to tell which algorithm was used for signature creation. | ||
#[derive(Default, Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] | ||
pub enum SignatureAlgorithm { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't think of a better name (SignatureType
is used). Feel free to suggest a better name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think SignatureAlgorithm
works fine.
} | ||
SignatureAlgorithm::Prehashed => { | ||
let digest = create_digest(&header, data); | ||
self.inner.sign_digest(digest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess nothing can go wrong, but this method panics silently (like sign
before).
This PR introduces support for pre-hashed signatures.
Currently we create signatures by cloning the passed data, which in some cases is the entire request body.
With pre-hashed signatures we can create the hash that is used in the signature process ourselves by incrementally digesting it.
Unfortunately, signatures creates by the two mentioned mechanisms are not compatible with each other.
Support for the new type is created by extending the signature header with informations about how the signature was created. To remain backwards compatible, it defaults to the old way of verifying signatures in case this information is missing.
To allow for a smooth rollout, only the verification is introduced in this PR and changing the creation will be done in a separate PR once this is sufficiently rolled out.
ref INGEST-430