belt-ctr

Crates.iobelt-ctr
lib.rsbelt-ctr
version0.1.0
sourcesrc
created_at2023-03-03 06:08:02.430137
updated_at2023-04-02 06:35:55.862048
descriptionCTR block mode of operation specified by the BelT standard
homepage
repositoryhttps://github.com/RustCrypto/block-modes
max_upload_size
id799482
size22,945
block-ciphers (github:rustcrypto:block-ciphers)

documentation

https://docs.rs/belt-ctr

README

RustCrypto: belt-ctr

crate Docs Apache2/MIT licensed Rust Version Project Chat Build Status

Generic implementation of the belt-ctr block mode of operation.

Mode functionality is accessed using traits from the [cipher] crate.

⚠️ Security Warning: Hazmat!

This crate does not ensure ciphertexts are authentic! Thus ciphertext integrity is not verified, which can lead to serious vulnerabilities! AEADs provide simple authenticated encryption, which is much less error-prone than manual integrity verification.

Example

use hex_literal::hex;
use belt_ctr::{BeltCtr, cipher::{KeyIvInit, StreamCipher, StreamCipherSeek}};

let key = &[0x42; 32];
let iv = &[0x24; 16];
let plaintext: &[u8; 34] = b"hello world! this is my plaintext.";
let ciphertext: &[u8; 34] = &hex!(
    "38DF06243BD85DA1CAE597CE680D3AFE"
    "0EBB372A4F6A858DB2DBE20A63567EED"
    "7D1B"
);

let mut cipher: BeltCtr = BeltCtr::new_from_slices(key, iv).unwrap();

// encrypt in-place
let mut buf = plaintext.clone();
cipher.apply_keystream(&mut buf);
assert_eq!(buf[..], ciphertext[..]);

cipher.seek(0);
cipher.apply_keystream(&mut buf);
assert_eq!(buf[..], plaintext[..]);

Minimum Supported Rust Version

Rust 1.57 or higher.

Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump.

SemVer Policy

  • All on-by-default features of this library are covered by SemVer
  • MSRV is considered exempt from SemVer as noted above

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 53

cargo fmt