Crates.io | rustfs-crypto |
lib.rs | rustfs-crypto |
version | 0.0.3 |
created_at | 2025-07-04 23:35:02.550745+00 |
updated_at | 2025-07-04 23:35:02.550745+00 |
description | Cryptography and security features for RustFS, providing encryption, hashing, and secure authentication mechanisms. |
homepage | https://rustfs.com |
repository | https://github.com/rustfs/rustfs |
max_upload_size | |
id | 1738632 |
size | 84,130 |
High-performance cryptographic module for RustFS distributed object storage
๐ Documentation
ยท ๐ Bug Reports
ยท ๐ฌ Discussions
The RustFS Crypto Module is a core cryptographic component of the RustFS distributed object storage system. This module provides secure, high-performance encryption and decryption capabilities, JWT token management, and cross-platform cryptographic operations designed specifically for enterprise-grade storage systems.
Note: This is a submodule of RustFS and is designed to work seamlessly within the RustFS ecosystem. For the complete RustFS experience, please visit the main RustFS repository.
Bytes
supportAdd this to your Cargo.toml
:
[dependencies]
rustfs-crypto = "0.1.0"
[dependencies]
rustfs-crypto = { version = "0.1.0", features = ["crypto", "fips"] }
Available features:
crypto
(default): Enable all cryptographic functionsfips
: Enable FIPS 140-2 compliance modedefault
: Includes both crypto
and fips
use rustfs_crypto::{encrypt_data, decrypt_data};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let password = b"my_secure_password";
let data = b"sensitive information";
// Encrypt data
let encrypted = encrypt_data(password, data)?;
println!("Encrypted {} bytes", encrypted.len());
// Decrypt data
let decrypted = decrypt_data(password, &encrypted)?;
assert_eq!(data, decrypted.as_slice());
println!("Successfully decrypted data");
Ok(())
}
use rustfs_crypto::{jwt_encode, jwt_decode};
use serde_json::json;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let secret = b"jwt_secret_key";
let claims = json!({
"sub": "user123",
"exp": 1234567890,
"iat": 1234567890
});
// Create JWT token
let token = jwt_encode(secret, &claims)?;
println!("Generated token: {}", token);
// Verify and decode token
let decoded = jwt_decode(&token, secret)?;
println!("Decoded claims: {:?}", decoded.claims);
Ok(())
}
use rustfs_crypto::{encrypt_data, decrypt_data, Error};
#[cfg(feature = "crypto")]
fn secure_storage_example() -> Result<(), Error> {
// Large data encryption
let large_data = vec![0u8; 1024 * 1024]; // 1MB
let password = b"complex_password_123!@#";
// Encrypt with automatic algorithm selection
let encrypted = encrypt_data(password, &large_data)?;
// Decrypt and verify
let decrypted = decrypt_data(password, &encrypted)?;
assert_eq!(large_data.len(), decrypted.len());
println!("Successfully processed {} bytes", large_data.len());
Ok(())
}
Algorithm | Key Derivation | Use Case | FIPS Compliant |
---|---|---|---|
AES-GCM | Argon2id | General purpose, hardware accelerated | โ |
ChaCha20Poly1305 | Argon2id | Software-only environments | โ |
AES-GCM | PBKDF2 | FIPS compliance required | โ |
The module automatically detects and optimizes for:
Run the test suite:
# Run all tests
cargo test
# Run tests with all features
cargo test --all-features
# Run benchmarks
cargo bench
# Test cross-platform compatibility
cargo test --target x86_64-unknown-linux-gnu
cargo test --target aarch64-unknown-linux-gnu
The crypto module is designed for high-performance scenarios:
This module is specifically designed to integrate with other RustFS components:
This module is part of the RustFS ecosystem:
For comprehensive documentation, visit:
We welcome contributions! Please see our Contributing Guide for details on:
# Clone the repository
git clone https://github.com/rustfs/rustfs.git
cd rustfs
# Navigate to crypto module
cd crates/crypto
# Install dependencies
cargo build
# Run tests
cargo test
# Format code
cargo fmt
# Run linter
cargo clippy
This module is maintained by the RustFS team and community contributors. Special thanks to all who have contributed to making RustFS cryptography secure and efficient.
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Copyright 2024 RustFS Team
Licensed 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.
RustFS is a trademark of RustFS, Inc.
All other trademarks are the property of their respective owners.
Made with โค๏ธ by the RustFS Team