Crate crown

Crate crown 

Source
Expand description

ยงKittyTLS Cryptographic Library

A comprehensive cryptographic library designed to provide first-class documentation, easy-to-use APIs, and wide deployment compatibility across different environments.

ยง๐Ÿš€ Quick Start

For most use cases, we recommend using the high-level envelope module, which provides unified interfaces for common cryptographic operations:

use crown::envelope::*;
use crown::core::CoreWrite;

// Hash operations
let mut hasher = EvpHash::new_sha256()?;
hasher.write(b"hello world")?;
let digest = hasher.sum();

// AEAD encryption
let cipher = EvpAeadCipher::new_aes_gcm(&key)?;
cipher.seal_in_place_separate_tag(&mut data, &nonce, &[])?;

ยง๐Ÿ“š Library Structure

  • envelope - High-level unified interfaces (recommended for most users)
  • aead - Authenticated encryption with associated data implementations
  • block - Low-level block cipher implementations
  • stream - Stream cipher implementations
  • hash - Cryptographic hash functions (fixed and variable length)
  • mac - Message authentication codes
  • modes - Cipher modes of operation for block ciphers
  • padding - Padding schemes for block alignment
  • kdf - Key derivation functions
  • password_hash - Specialized password hashing functions

ยง๐Ÿ”’ Security Recommendations

Users should understand which algorithms are secure and which are not. For beginners, we recommend the following modern, secure algorithms:

  • Encryption: Always use ChaCha20-Poly1305 or AES-GCM for authenticated encryption
  • Hashing: Use SHA-256, SHA-3, or BLAKE2 for general purposes
  • Password Hashing: Use Argon2, scrypt, or bcrypt for password storage
Avoid legacy algorithms like MD5, SHA-1, DES, and RC4 which are cryptographically broken.

ยงDesign Goals

  • Ease of Use: Simple, intuitive APIs with comprehensive documentation
  • Performance: Optimized implementations with platform-specific acceleration
  • Security: Constant-time operations and secure defaults
  • Compatibility: Support for no_std environments and various platforms

ยงFeature flags

  • std (enabled by default) โ€” Enable std
  • alloc (enabled by default) โ€” Enable alloc
  • cuda โ€” Enable Cuda. (Experimental)
  • bindgen โ€” regenerate cuda sys.rs
  • asm โ€” Enable asm support. (Experimental)
  • unstable โ€” Enable experimental features

Re-exportsยง

pub use utils::rand;

Modulesยง

aead
Authenticated Encryption with Associated Data (AEAD)
block
Block Cipher Implementations
core
envelope
High-Level Cryptographic Interface
error
hash
Hash Function Implementations
kdf
Key Derivation Functions (KDF)
mac
Message Authentication Code (MAC)
modes
Cipher Modes of Operation
padding
Padding Schemes
password_hash
Password Hashing Functions
stream
Stream Cipher Implementations
utils