2 releases
0.1.1 | Sep 28, 2024 |
---|---|
0.1.0 | Sep 28, 2024 |
#742 in Cryptography
301 downloads per month
71KB
1K
SLoC
plain-aes
An implementation of Rijndael's cipher, commonly known as Advanced Encryption Standard.
Features
- Based on FIPS 197 Final.
- Thoroughly tested and documented.
- Implements AES-128/192 encryption and decryption.
- Implements the following modes of operation:
- Electronic CodeBook.
- Cipher Block Chaining.
- Ability to implement your own mode of operation, using the block operations exposed by the crate's internal module.
- Out of the box support for
&[str]
and&[u8]
encryption/decryption. - Ability to encrypt/decrypt any custom data structure that implements the Encryptable trait.
Usage
To use the crate, either add plain-aes
to your Cargo.toml
's dependecies, or run cargo add plain-aes
.
Here's a quick example on how to encrypt a text message in AES128-ECB:
use plain_aes::{encrypt, ModeOfOperation, CipherVersion};
let message = "This is a super secret message";
let key = "This lib is cool"; // This lib is cool
let encrypted_message = encrypt(message, CipherVersion::Aes128(key.as_bytes(), ModeOfOperation::ECB)).unwrap();
let expected_enrypted: &[u8] = &[
0x11, 0x2B, 0xBD, 0x0D, 0x4C, 0x0C, 0xC5, 0x02, 0xB4, 0xC1, 0x38, 0xFD, 0x9A, 0x56,
0xC1, 0xA8, 0x78, 0x61, 0xD9, 0xF5, 0x6B, 0x48, 0xCC, 0xC5, 0x48, 0x14, 0xF2, 0x8C,
0x1A, 0x25, 0x11, 0xA3,
];
assert!(expected_enrypted.iter().eq(encrypted_message.iter()))
Refer to the docs, or the tests folder for in-depth examples and documentation.
Test coverage
- This crate is tested using tarpaulin.
- Currently boasts a 100% line coverage.
- See the project's codecov page for more information.
License
This project is licensed under both the MIT and Apache 2.0 License. See LICENSE-APACHE and LICENSE-MIT for details.
Disclaimer
This crate is intended for educational and experimental purposes only and should not be used in production environments. For security-critical applications, it is strongly recommended to use established and well-tested cryptographic libraries that have undergone rigorous security audits. The author shall not be liable for any damages, including but not limited to direct, indirect, incidental, special, exemplary, or consequential damages, arising out of or in connection with the use or inability to use this crate.