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§
- Blowfish
Context - Blowfish cipher context for decrypting and/or encrypting data.
- Blowfish
Key - Type-safe variable-size Blowfish cipher key.
Enums§
- Blowfish
Error - 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.