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


##########
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:
   We could possibly have a smaller API change and just allow the traits to 
return a Vec<u8> directly 🤔  that would also avoid the need for a copy in some 
cases and might be a smaller API change?
   
   ```rust
   fn build(self) -> Result<Vec<u8>> { 
   ...
   }
   ```



-- 
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