Crate gaia_crypt

Crate gaia_crypt 

Source
Expand description

A hybrid encryption library that provides RSA + AES-GCM encryption and decryption functionality.

This library implements a hybrid encryption scheme where:

  • Data is encrypted with AES-256-GCM (for performance and to handle large data)
  • The AES key is encrypted with RSA (for secure key exchange)

§Examples

// Generate a new RSA key pair
let (private_key, public_key) = generate_rsa_keypair().unwrap();
let private_key_pem = private_key.to_pkcs1_pem().unwrap();
let public_key_pem = public_key.to_public_key_pem().unwrap();

// Encrypt data
let data = b"Hello, world!";
let encrypted = encrypt(&public_key_pem, data).unwrap();

// Decrypt data
let decrypted = decrypt(&private_key_pem, &encrypted).unwrap();
assert_eq!(data, &decrypted[..]);

Functions§

decrypt
Decrypts data that was encrypted with the hybrid RSA + AES-GCM approach.
encrypt
Encrypts data using a hybrid RSA + AES-GCM approach.
generate_rsa_keypair
Generates a new RSA key pair for use with the encryption/decryption functions.
raw_decrypt
Decrypts data that was encrypted with the hybrid RSA + AES-GCM approach using a pre-parsed private key.
raw_encrypt
Encrypts data using a hybrid RSA + AES-GCM approach with a pre-parsed RSA public key.