7 releases
Uses new Rust 2024
| new 0.2.4 | Dec 1, 2025 |
|---|---|
| 0.2.3 | Apr 21, 2025 |
| 0.2.2 | Jul 28, 2023 |
| 0.2.1 | Mar 17, 2023 |
| 0.1.1 | Jun 21, 2022 |
#1942 in Cryptography
150KB
584 lines
ISAP
Pure Rust implementation of the lightweight Authenticated Encryption and Associated Data (AEAD) scheme ISAP. This crate implements version 2 of ISAP. By default, implementations with the Keccak (feature keccak) and Ascon (feature ascon) permutations are provided. For the documentation of all other features, please see the aead crate.
Security Notes
This crate has received no security audit. Use at your own risk.
License
This crate is licensed under the MIT license.
lib.rs:
Usage
Simple usage (allocating, no associated data):
use isap_aead::IsapAscon128; // Or `IsapAscon128A`, `IsapKeccak128`, `IsapKeccak128A`
use isap_aead::aead::{Aead, KeyInit};
let key = b"very secret key.";
let cipher = IsapAscon128::new(key.into());
let nonce = b"unique nonce 012"; // 128-bits; unique per message
let ciphertext = cipher.encrypt(nonce.into(), b"plaintext message".as_ref())
.expect("encryption failure!"); // NOTE: handle this error to avoid panics!
let plaintext = cipher.decrypt(nonce.into(), ciphertext.as_ref())
.expect("decryption failure!"); // NOTE: handle this error to avoid panics!
assert_eq!(&plaintext, b"plaintext message");
In-place Usage (eliminates alloc requirement)
Similar to other crates implementing aead interfaces, this crate also offers an optional
alloc feature which can be disabled in e.g. microcontroller environments that don't have a
heap. See aead::AeadInPlace for more details.
use isap_aead::IsapAscon128; // Or `IsapAscon128A`, `IsapKeccak128`, `IsapKeccak128A`
use isap_aead::aead::{AeadInPlace, KeyInit};
use isap_aead::aead::heapless::Vec;
let key = b"very secret key.";
let cipher = IsapAscon128::new(key.into());
let nonce = b"unique nonce 012"; // 128-bits; unique per message
let mut buffer: Vec<u8, 128> = Vec::new(); // Buffer needs 16-bytes overhead for authentication tag
buffer.extend_from_slice(b"plaintext message");
// Encrypt `buffer` in-place, replacing the plaintext contents with ciphertext
cipher.encrypt_in_place(nonce.into(), b"", &mut buffer).expect("encryption failure!");
// `buffer` now contains the message ciphertext
assert_ne!(&buffer, b"plaintext message");
// Decrypt `buffer` in-place, replacing its ciphertext context with the original plaintext
cipher.decrypt_in_place(nonce.into(), b"", &mut buffer).expect("decryption failure!");
assert_eq!(&buffer, b"plaintext message");
Similarly, enabling the arrayvec feature of this crate will provide an impl of
aead::Buffer for arrayvec::ArrayVec.
Dependencies
~0.7–1.4MB
~33K SLoC