Tpt commented on code in PR #707: URL: https://github.com/apache/arrow-rs-object-store/pull/707#discussion_r3426628820
########## src/client/crypto.rs: ########## @@ -0,0 +1,410 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use crate::Result; + +/// Algorithm for computing digests +#[derive(Debug, Ord, PartialOrd, Eq, PartialEq)] +#[non_exhaustive] +pub enum DigestAlgorithm { + /// SHA-256 + Sha256, +} + +/// Algorithm for signing payloads +#[derive(Debug, Ord, PartialOrd, Eq, PartialEq)] +#[non_exhaustive] +pub enum SigningAlgorithm { + /// RSASSA-PKCS1-v1_5 using SHA-256 + RS256, +} + +/// Provides cryptographic primitives +pub trait CryptoProvider: std::fmt::Debug + Send + Sync { + /// Compute a digest + fn digest(&self, algorithm: DigestAlgorithm) -> Result<Box<dyn DigestContext>>; Review Comment: Seems like all the caller already have something that could be seen as a sequence of byte slices so maybe a signature like could work: ```rust fn digest(&self, algorithm: DigestAlgorithm, content: impl IntoIterator<Item=impl AsRef<[u8]>>) -> Result<Vec<u8>>; ``` This would drop the need for a dyn-safe trait and hopefully might help slightly performances. However, this looks like a follow-up and not something for this MR. -- 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]
