#ice #algorithm #cryptography #block-cipher

ice-crypt

Rust implementation of the ICE encryption algorithm

1 stable release

Uses new Rust 2021

1.0.0 Sep 3, 2022

#636 in Cryptography

23 downloads per month

GPL-3.0-or-later

17KB
229 lines

ICE-Crypt

Ice-Crypt is a Rust implementation of the ICE (Information Concealment Engine) encryption algorithm.

ICE

[ICE] is a 64-bit private key block cipher, in the tradition of DES. However, unlike DES, it was designed to be secure against differential and linear cryptanalysis, and has no key complementation weaknesses or weak keys. In addition, its key size can be any multiple of 64 bits, whereas the DES key is limited to 56 bits.
-- Matthew Kwan, Author of the ICE encryption algorithm

Usage

Add this to your Cargo.toml:

[dependencies]
ice-crypt = "1.0.0"

To encrypt a simple message, you can use the following code:

src/main.rs:

use ice_crypt::IceKey;

fn main() {
    let key: Vec<u8> = vec![67, 83, 71, 79, 16, 54, 0, 0, 132, 13, 0, 0, 97, 3, 0, 0];

    let message: &str = "My secret message";

    // Create a new IceKey instance
    let mut icekey = IceKey::new(2);

    // Set Private Key
    icekey.set(key);

    let encrypted_message: Vec<u8> = icekey.encrypt_all(message.as_bytes().to_vec());

    let decrypted_message: Vec<u8> = icekey.decrypt_all(encrypted_message);

    // Convert to string and remove 0 padding
    let mut output = std::str::from_utf8(&decrypted_message).unwrap();
    output = output.trim_end_matches('\0');

    assert_eq!(message, output);
}

Documentation

TODO

Original

The ICE encryption algorithm was designed and written by Matthew Kwan, checkout his C/C++ implementations of the algorithm on his website.

License

Ice-Crypt is distributed under the terms of the GNU GENERAL PUBLIC LICENSE (Version 3).

See LICENSE for more details.

No runtime deps