Struct extended_tea::XTEA [−][src]
pub struct XTEA { /* fields omitted */ }
Expand description
Struct containing the XTEA
info.
See Wikipedia for more information
Implementations
Creates a new XTEA cipher using the given key, with a custom number of rounds.
HIGHLY Recommended to use the fn new(key: [u32; 4]) -> Self
instead unless you know what you’re doing.
Panics
If num_rounds is NOT divisible by 2.
Enciphers the two given u32
’s into the output array.
Highly recommended to NOT use this, and instead use either the slice or stream implementation.
See https://en.wikipedia.org/wiki/XTEA#Implementations for implementation details
Deciphers the two given u32
’s into the output array.
Highly recommended to NOT use this, and instead use either the slice or stream implementation.
See https://en.wikipedia.org/wiki/XTEA#Implementations for implementation details
Enciphers the given &[u8]
into the output &mut [u8]
.
Uses the given ByteOrder passed as a template for properly parsing the slices.
If you’re unsure which ByteOrder to use, use BigEndian
(BE).
Panics
If the length of the input is not equal to the length of the output
If the length of the input or output is not divisible by 8
Examples
use extended_tea::XTEA;
use byteorder::BE;
let input: Box<[u8]> = vec![10u8; 16].into_boxed_slice();
let xtea = XTEA::new(&[0x1380C5B5, 0x28037DF9, 0x26E314A2, 0xC57684E4]);
let encrypted = {
let mut output = vec![0u8; input.len()].into_boxed_slice();
xtea.encipher_u8slice::<BE>(&input, &mut output);
output
};
Deciphers the given &[u8]
into the output &mut [u8]
.
Uses the given ByteOrder passed as a template for properly parsing the slices.
If you’re unsure which ByteOrder to use, use BigEndian
(BE).
Panics
If the length of the input is not equal to the length of the output.
If the length of the input or output is not divisible by 8.
Examples
use extended_tea::XTEA;
use byteorder::BE;
let input: Box<[u8]> = vec![10u8; 16].into_boxed_slice();
let xtea = XTEA::new(&[0x1380C5B5, 0x28037DF9, 0x26E314A2, 0xC57684E4]);
let encrypted = {
let mut output = vec![0u8; input.len()].into_boxed_slice();
xtea.encipher_u8slice::<BE>(&input, &mut output);
output
};
let decrypted = {
let mut output = vec![0u8; input.len()].into_boxed_slice();
xtea.decipher_u8slice::<BE>(&encrypted, &mut output);
output
};
assert_eq!(input, decrypted);
Enciphers the given input stream into the given output stream.
Uses the given ByteOrder passed as a template for properly parsing the streams.
If you’re unsure which ByteOrder to use, use BigEndian
(BE).
Returns
Ok(()) if there were no errors in parsing.
Err(_) if there was an error parsing the input stream that did NOT occour on an even read. In other words, the stream’s input needs to have a length that is divisible by 8.
NOTE: Unlike std::io::{Read, Write} in the case of an Err(_), the output stream IS modified
Deciphers the given input stream into the given output stream.
Uses the given ByteOrder passed as a template for properly parsing the streams.
If you’re unsure which ByteOrder to use, use BigEndian
(BE).
Returns
Ok(()) if there were no errors in parsing.
Err(_) if there was an error parsing the input stream that did NOT occour on an even read. In other words, the stream’s input needs to have a length that is divisible by 8.
NOTE: Unlike std::io::{Read, Write} in the case of an Err(_), the output stream IS modified