#cipher #block-mode #crypto #block-cipher

no-std belt-ecb

Generic implementation of the belt-ecb block mode of operation (STB 34.101.31-2020)

2 releases

0.0.1 Nov 3, 2024
0.0.0 Mar 3, 2023

#8 in #block-mode

Download history 51/week @ 2024-07-28 1/week @ 2024-08-04 4/week @ 2024-09-22 1/week @ 2024-09-29 161/week @ 2024-11-03

161 downloads per month

MIT/Apache

3KB

This crate is deprecated.

For implementation of the belt-ecb mode you can use the cts crate with block cipher implementation from the belt-block crate:

use cts::{Decrypt, Encrypt, KeyInit};
use hex_literal::hex;

type BeltEcb = cts::EcbCs2<belt_block::BeltBlock>;

// Test vector from STB 34.101.31-2020, table A.9
let key = hex!(
    "E9DEE72C 8F0C0FA6 2DDB49F4 6F739647"
    "06075316 ED247A37 39CBA383 03A98BF6"
);
let pt = hex!(
    "B194BAC8 0A08F53B 366D008E 584A5DE4"
    "8504FA9D 1BB6C7AC 252E72C2 02FDCE0D"
    "5BE3D612 17B96181 FE6786AD 716B890B"
);
let ct = hex!(
    "69CCA1C9 3557C9E3 D66BC3E0 FA88FA6E"
    "5F23102E F1097107 75017F73 806DA9DC"
    "46FB2ED2 CE771F26 DCB5E5D1 569F9AB0"
);

let mut buf = [0u8; 48];

BeltEcb::new(&key.into()).encrypt_b2b(&pt, &mut buf).unwrap();
assert_eq!(buf, ct);

BeltEcb::new(&key.into()).decrypt(&mut buf).unwrap();
assert_eq!(buf, pt);

No runtime deps