Struct LeeKoq

Source
pub struct LeeKoq;

Implementations§

Source§

impl LeeKoq

Source

pub const LUT: u32 = 979_137_582u32

Source

pub fn encrypt(block: u32, key: u64) -> u32

Encrypts a 32-bit block of plaintext using the KeeLoq algorithm.

§Arguments
  • block - 32-bit plaintext block
  • key - 64-bit key
  • return - 32-bit cipher-text block
§Example
use leekoq::LeeKoq;
 
let plain: u32 = 0x12345678;
let key: u64 = 0xCAFED00D;
assert_eq!(LeeKoq::encrypt(plain, key), 0xD0FB287C);
Examples found in repository?
examples/encrypt.rs (line 22)
14fn main() {
15    let args: Vec<String> = env::args().collect();
16    if args.len() != 3 {
17        println!("Usage: cargo run --example encrypt -- <plain> <key>");
18    }
19    else {
20        let plain: u32 = parse(&args[1]) as u32;
21        let key: u64 = parse(&args[2]);
22        println!("cipher: {:08X}", LeeKoq::encrypt(plain, key));
23    }
24}
Source

pub fn decrypt(block: u32, key: u64) -> u32

Decrypts a 32-bit block of ciphertext using the KeeLoq algorithm.

§Arguments
  • block - 32-bit plaintext block
  • key - 64-bit key
  • return - 32-bit cipher-text block
§Example
use leekoq::LeeKoq;
 
let cipher: u32 = 0xD0FB287C;
let key: u64 = 0xCAFED00D;
assert_eq!(LeeKoq::decrypt(cipher, key), 0x12345678);
Examples found in repository?
examples/decrypt.rs (line 22)
14fn main() {
15    let args: Vec<String> = env::args().collect();
16    if args.len() != 3 {
17        println!("Usage: cargo run --example decrypt -- <cipher> <key>");
18    }
19    else {
20        let cipher: u32 = parse(&args[1]) as u32;
21        let key: u64 = parse(&args[2]);
22        println!("cipher: {:08X}", LeeKoq::decrypt(cipher, key));
23    }
24}

Auto Trait Implementations§

§

impl Freeze for LeeKoq

§

impl RefUnwindSafe for LeeKoq

§

impl Send for LeeKoq

§

impl Sync for LeeKoq

§

impl Unpin for LeeKoq

§

impl UnwindSafe for LeeKoq

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.