RustFS Crypto Module
๐ Overview
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.
โจ Features
๐ Encryption & Decryption
- Multiple Algorithms: Support for AES-GCM, ChaCha20Poly1305, and PBKDF2
- Key Derivation: Argon2id and PBKDF2 for secure key generation
- Memory Safety: Built with Rust's memory safety guarantees
- Cross-Platform: Optimized for x86_64, aarch64, s390x, and other architectures
๐ซ JWT Management
- Token Generation: Secure JWT token creation with HS512 algorithm
- Token Validation: Robust JWT token verification and decoding
- Claims Management: Flexible claims handling with JSON support
๐ก๏ธ Security Features
- FIPS Compliance: Optional FIPS 140-2 compatible mode
- Hardware Acceleration: Automatic detection and utilization of CPU crypto extensions
- Secure Random: Cryptographically secure random number generation
- Side-Channel Protection: Resistant to timing attacks
๐ Performance
- Zero-Copy Operations: Efficient memory usage with
Bytes
support - Async/Await: Full async support for non-blocking operations
- Hardware Optimization: CPU-specific optimizations for better performance
๐ฆ Installation
Add this to your Cargo.toml
:
[]
= "0.1.0"
Feature Flags
[]
= { = "0.1.0", = ["crypto", "fips"] }
Available features:
crypto
(default): Enable all cryptographic functionsfips
: Enable FIPS 140-2 compliance modedefault
: Includes bothcrypto
andfips
๐ง Usage
Basic Encryption/Decryption
use ;
JWT Token Management
use ;
use json;
Advanced Usage with Custom Configuration
use ;
๐๏ธ Architecture
Supported Encryption Algorithms
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 | โ |
Cross-Platform Support
The module automatically detects and optimizes for:
- x86/x86_64: AES-NI and PCLMULQDQ instructions
- aarch64: ARM Crypto Extensions
- s390x: IBM Z Crypto Extensions
- Other architectures: Fallback to software implementations
๐งช Testing
Run the test suite:
# Run all tests
# Run tests with all features
# Run benchmarks
# Test cross-platform compatibility
๐ Performance
The crypto module is designed for high-performance scenarios:
- Encryption Speed: Up to 2GB/s on modern hardware
- Memory Usage: Minimal heap allocation with zero-copy operations
- CPU Utilization: Automatic hardware acceleration detection
- Scalability: Thread-safe operations for concurrent access
๐ค Integration with RustFS
This module is specifically designed to integrate with other RustFS components:
- Storage Layer: Provides encryption for object storage
- Authentication: JWT tokens for API authentication
- Configuration: Secure configuration data encryption
- Metadata: Encrypted metadata storage
๐ Requirements
- Rust: 1.70.0 or later
- Platforms: Linux, macOS, Windows
- Architectures: x86_64, aarch64, s390x, and more
๐ Security Considerations
- All cryptographic operations use industry-standard algorithms
- Key derivation follows best practices (Argon2id, PBKDF2)
- Memory is securely cleared after use
- Timing attack resistance is built-in
- Hardware security modules (HSM) support planned
๐ Known Issues
- Hardware acceleration detection may not work on all virtualized environments
- FIPS mode requires additional system-level configuration
- Some older CPU architectures may have reduced performance
๐ Related Projects
This module is part of the RustFS ecosystem:
- RustFS Main - Core distributed storage system
- RustFS ECStore - Erasure coding storage engine
- RustFS IAM - Identity and access management
- RustFS Policy - Policy engine
๐ Documentation
For comprehensive documentation, visit:
๐ Links
- Documentation - Complete RustFS manual
- Changelog - Release notes and updates
- GitHub Discussions - Community support
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details on:
- Code style and formatting requirements
- Testing procedures and coverage
- Security considerations for cryptographic code
- Pull request process and review guidelines
Development Setup
# Clone the repository
# Navigate to crypto module
# Install dependencies
# Run tests
# Format code
# Run linter
๐ฌ Getting Help
- Documentation: docs.rustfs.com
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Security: Report security issues to security@rustfs.com
๐ Contact
- Bugs: GitHub Issues
- Business: hello@rustfs.com
- Jobs: jobs@rustfs.com
- General Discussion: GitHub Discussions
๐ฅ Contributors
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.
๐ License
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.