Skip to content
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

Add support for CRC64-NVME checksum algorithm #1235

Merged
merged 5 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 130 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mountpoint-s3-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Other changes

* Add support for CRC64-NVME checksum algorithm. ([#1235](https://github.com/awslabs/mountpoint-s3/pull/1235))
* Add support for overriding the number of threads used by the Event Loop.
([#1240](https://github.com/awslabs/mountpoint-s3/pull/1240/))
* The ECS credentials provider now performs retries in the event of some failures. ([awslabs/aws-c-auth#259](https://github.com/awslabs/aws-c-auth/pull/259/))
Expand Down
2 changes: 1 addition & 1 deletion mountpoint-s3-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ rand_chacha = { version = "0.3.1", optional = true }
[dev-dependencies]
aws-config = "1.5.10"
aws-credential-types = "1.2.1"
aws-sdk-s3 = "1.65.0"
aws-sdk-s3 = "1.69.0"
aws-smithy-runtime-api = "1.7.3"
bytes = "1.9.0"
clap = { version = "4.5.23", features = ["derive"] }
Expand Down
27 changes: 27 additions & 0 deletions mountpoint-s3-client/src/checksums.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
//! Provides base64 encoding/decoding for various checksums.
pub use mountpoint_s3_crt::checksums::crc32::{self, Crc32};
pub use mountpoint_s3_crt::checksums::crc32c::{self, Crc32c};
pub use mountpoint_s3_crt::checksums::crc64nvme::{self, Crc64nvme};
pub use mountpoint_s3_crt::checksums::sha1::{self, Sha1};
pub use mountpoint_s3_crt::checksums::sha256::{self, Sha256};

use base64ct::Base64;
use base64ct::Encoding;
use thiserror::Error;

/// The base64 encoding for this CRC64-NVME checksum value.
pub fn crc64nvme_to_base64(checksum: &Crc64nvme) -> String {
Base64::encode_string(&checksum.value().to_be_bytes())
}
dannycjones marked this conversation as resolved.
Show resolved Hide resolved

/// Create a CRC64-NVME checksum from a base64 encoding.
pub fn crc64nvme_from_base64(base64_str: &str) -> Result<Crc64nvme, ParseError> {
let mut dec_buf = [0u8; std::mem::size_of::<u64>()];
let _ = Base64::decode(base64_str, &mut dec_buf)?;
Ok(Crc64nvme::new(u64::from_be_bytes(dec_buf)))
}

/// The base64 encoding for this CRC32C checksum value.
pub fn crc32c_to_base64(checksum: &Crc32c) -> String {
Base64::encode_string(&checksum.value().to_be_bytes())
Expand Down Expand Up @@ -55,6 +68,20 @@ mod tests {
use super::*;
use test_case::test_case;

#[test]
fn test_crc64nvme_to_base64() {
let crc = Crc64nvme::new(0xAE8B14860A799888);
let base64 = crc64nvme_to_base64(&crc);
assert_eq!(&base64, "rosUhgp5mIg=");
}

#[test]
fn test_crc64nvme_from_base64() {
let base64 = "rosUhgp5mIg=";
let crc = crc64nvme_from_base64(base64).expect("parsing should succeeed");
assert_eq!(crc.value(), 0xAE8B14860A799888);
}

#[test]
fn test_crc32c_to_base64() {
let crc = Crc32c::new(1234);
Expand Down
Loading
Loading