alamb commented on code in PR #766:
URL: 
https://github.com/apache/arrow-rs-object-store/pull/766#discussion_r3547146891


##########
src/client/crypto.rs:
##########
@@ -35,42 +35,16 @@ pub enum SigningAlgorithm {
 
 /// Provides cryptographic primitives
 pub trait CryptoProvider: std::fmt::Debug + Send + Sync {
-    /// Compute a digest
-    fn digest(&self, algorithm: DigestAlgorithm) -> Result<Box<dyn 
DigestContext>>;
+    /// Compute the digest of `data`
+    fn digest(&self, algorithm: DigestAlgorithm, data: &[&[u8]]) -> 
Result<Vec<u8>>;
 
-    /// Compute an HMAC with the provided `secret`
-    fn hmac(&self, algorithm: DigestAlgorithm, secret: &[u8]) -> 
Result<Box<dyn HmacContext>>;
+    /// Compute the HMAC of `data` with the provided `secret`
+    fn hmac(&self, algorithm: DigestAlgorithm, secret: &[u8], data: &[u8]) -> 
Result<Vec<u8>>;
 
     /// Sign a payload with the provided PEM-encoded secret
     fn sign(&self, algorithm: SigningAlgorithm, pem: &[u8]) -> Result<Box<dyn 
Signer>>;
 }
 
-/// Incrementally compute a digest, see [`CryptoProvider::digest`]
-pub trait DigestContext: Send {
-    /// Updates the digest with all the data in data.
-    ///
-    /// It is implementation-defined behaviour to call this after calling 
[`Self::finish`]
-    fn update(&mut self, data: &[u8]);
-
-    /// Finalizes the digest calculation and returns the digest value.
-    ///
-    /// It is implementation-defined behaviour to call this after calling 
[`Self::finish`]
-    fn finish(&mut self) -> Result<&[u8]>;

Review Comment:
   > . I just found quite sad to have a complicated API with a lot of dynamic 
traits where a smaller API could work. Feel free to close this MR.
   
   Yeah, this is a new API that we added to support pluggable crypto providers. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to