Crate blowfish_mbed_c

Source
Expand description

Lean and safe interface for Blowfish cipher from the mbedtls implementation.

This crate provides a rusty wrapper around the blowfish_mbed_sys bindings to the Blowfish cipher implementation taken from an older branch of the mbedtls library. So far, only ECB and CBC block cipher modes of operation have been wrapped and tested.

§Example

use blowfish_mbed_c::*;

let key = BlowfishKey::new(b"secret").unwrap();
let context = BlowfishContext::with_key(&key).unwrap();

// Notice that its length is a multiple of eight...
const CLEARTEXT: [u8; 16] = *b"Hi there, world!";

let mut ciphertext = [0u8; 16];
context.encrypt_ecb_slice(&CLEARTEXT, &mut ciphertext).unwrap();

let mut cleartext = [0u8; 16];
context.decrypt_ecb_slice(&ciphertext, &mut cleartext).unwrap();

assert_eq!(CLEARTEXT, cleartext);

Structs§

BlowfishContext
Blowfish cipher context for decrypting and/or encrypting data.
BlowfishKey
Type-safe variable-size Blowfish cipher key.

Enums§

BlowfishError
Error type for all BlowfishContext operations.

Constants§

BLOCK_SIZE
Number of bytes in a Blowfish cipher block.
KEY_BYTES_MAX
Highest number of bytes in a valid Blowfish key.
KEY_BYTES_MIN
Lowest number of bytes in a valid Blowfish key.