CryptGuard Programming Library
Introduction
CryptGuard is a comprehensive cryptographic library, offering robust encryption and decryption capabilities. It integrates traditional cryptography with post-quantum algorithms, ensuring resilience against quantum computing threats. Designed for developers, CryptGuard empowers applications to withstand future digital security challenges. Embrace CryptGuard as your trusted ally in safeguarding privacy in the digital realm.
Key Features and Capabilities
This library supports AES-256 and XChaCha20 encryption algorithms, providing a secure means to protect data. To cater to a variety of security requirements and operational contexts, CryptGuard integrates seamlessly with Kyber512, Kyber768, and Kyber1024 for encryption, ensuring compatibility with post-quantum cryptography standards.
For developers who require digital signing capabilities, CryptGuard incorporates Falcon and Dilithium algorithms, offering robust options for creating and verifying digital signatures. This feature is particularly crucial for applications that necessitate authenticity and integrity of data, ensuring that digital communications remain secure and verifiable.
An additional layer of security is provided through the appending of a HMAC (Hash-Based Message Authentication Code) to encrypted data. This critical feature enables the authentication of encrypted information, ensuring that any tampering with the data can be reliably detected. This HMAC attachment underscores CryptGuard's commitment to comprehensive data integrity and security, offering developers and end-users peace of mind regarding the authenticity and safety of their data.
Syntax Overhaul and Version Information
Upcoming Changes
Our library is undergoing a syntax overhaul to enhance detail and clarity, addressing feedback for a more intuitive user experience. The current syntax focuses on providing a comprehensive understanding of the cryptographic processes, albeit with a different complexity level.
Current Release
The present version, 1.1.4, emphasizes detailed cryptographic operations. This version is ideal for those who want a fast but not too complicated, elaborate approach to cryptography and don't want to use asynchronous code. Asynchronous capabilities will be reimplemented in a later update (but this time as a feature). For those who prefer an easier syntax, they should just use version 1.0.3 until a later update is released. This version's syntax is more user-friendly and does not require the definition of too many structs like in 1.1.1 or 1.1.0 but allows for precise control over the encryption and decryption algorithm as well as the Kyber key size. It allows the usage of Kyber1024, Kyber768, and Kyber512.
Future Release
A forthcoming update will introduce other bit sizes for Falcon and Dilithium. It will also introduce logging capabilities, not logging keys or original data, but rather information about which encryption algorithm (AES or XChaCha20) was used, whether it was a File or a Message, as well as the time it was used. Stay tuned for its release!
Important Considerations
Transition to the New Version
For those considering the transition to the updated version upon its release, familiarizing yourself with the current documentation and examples is recommended. This preparation will facilitate a smoother adaptation to the new syntax and features. The next upcoming versions will gradually change the syntax and often implement things you don't need to use in the next version anymore, but these structs and methods don't cease to exist; rather, they are now automatically implemented for easier usage. If you want to use them, don't hesitate to do so!
Usage Examples
Generating and Saving a Key Pair
This example illustrates generating a key pair and saving it to files, leveraging the KeyControKyber1024::keypair() method for key pair generation and the KeyControl::<KeyControKyber1024> instance for setting and saving the keys.
// Generate a keypair
let = keypair.unwrap;
let keycontrol = new;
// Save Public and Secret key while defining the folder (./key).
keycontrol.set_public_key.unwrap;
keycontrol.save.unwrap;
keycontrol.set_secret_key.unwrap;
keycontrol.save.unwrap;
Encryption of a File using AES
let message = "Hey, how are you doing?";
let passphrase = "Test Passphrase";
// Instantiate Kyber for encryption of a message with Kyber1024 and AES
// Fails when not using either of these properties since it would be the wrong type of algorithm, data, keysize or process!
let mut encryptor = new?;
// Encrypt message
let = encryptor.encrypt_msg?;
// Save the ciphertext for decryption in folder ./key
key_control.set_ciphertext.unwrap;
key_control.save.unwrap;
Decryption of a File using AES
let cipher = key_control.load;
let secret_key = key_control.load;
// Instantiate Kyber for decryption of a message with Kyber1024 and AES
// Fails when not using either of these properties since it would be the wrong type of algorithm, data, keysize or process!
let mut decryptor = new?;
// Decrypt message
let decrypt_message = decryptor.decrypt_msg?;
// Print the decrypted text
println!;
Encryption and decryption of a message written into a file with XChaCha20
let message = "Hey, how are you doing?";
let tmp_dir = new.map_err?;
let tmp_dir = new.prefix.tempdir.map_err?;
let enc_path = tmp_dir.path.clone.join;
let dec_path = tmp_dir.path.clone.join;
write?;
let passphrase = "Test Passphrase";
// Generate key pair
let = keypair.expect;
// Instantiate Kyber for encryption of a file with Kyber768 and XChaCha20
// Fails when not using either of these properties since it would be the wrong type of algorithm, data, keysize or process!
let mut encryptor = new?;
// Encrypt message
let = encryptor.encrypt_file?;
let nonce = encryptor.get_nonce;
remove_file;
// Instantiate Kyber for decryption of a file with Kyber768 and XChaCha20
// Fails when not using either of these properties since it would be the wrong type of algorithm, data, keysize or process!
let mut decryptor = new?;
// Decrypt message
let decrypt_message = decryptor.decrypt_file?;
Signing and Verifying with Falcon
use crate;
// Generate a keypair using Falcon
let falcon_keypair = keypair;
// Sign a message
let message = "This is a secret message";
let signature = sign_msg.expect;
// Verify the signature
let verified = verify_msg.expect;´
Signing and Verifying with Dilithium
use crate;
// Generate a keypair using Dilithium
let dilithium_keypair = keypair;
// Sign a message
let message = "Another secret message";
let signature = sign_msg.expect;
// Verify the signature
let verified = verify_msg.expect;´
Conclusion and Looking Forward
We appreciate your engagement with our cryptographic library. As we strive to improve and evolve, your feedback and contributions are invaluable. The anticipated update promises to make cryptography more accessible and straightforward for everyone.
Thank you for your support and for making security a priority in your projects.
License
CryptGuard is licensed under the MIT LICENSE. The full license text is available in the LICENSE file in the repository.