Module fpe::ff3_1

source ·
Expand description

The FF3-1 algorithm

The FF3-1 algorithm supports key sizes of 128, 192, and 256 bits. The length of the tweak is specified by the algorithm as 56 bits.

This implementation contains a “context” structure, called FF3_1, that holds the encryption key, the default tweak, and some other parameters related to the algorithm. Once, this structure has been created, it can be used to encrypt and decrypt data

Example

let ff3_1 = fpe::ff3_1::FF3_1::new(
    &[
        0xad, 0x41, 0xec, 0x5d, 0x23, 0x56, 0xde, 0xae,
        0x53, 0xae, 0x76, 0xf5, 0x0b, 0x4b, 0xa6, 0xd2,
    ],    // the encryption key
    // the default tweak
    Some(&[0xcf, 0x29, 0xda, 0x1e, 0x18, 0xd9, 0x70]),
    10,   // radix specifies the number of characters in the alphabet
    None  // use (the first 10 characters of) the default alphabet
).unwrap();

let pt = "6520935496";
let ct = "4716569208";

let out = ff3_1.encrypt(pt, None).unwrap();
assert!(out == ct);

let out = ff3_1.decrypt(&ct, None).unwrap();
assert!(out == pt);

Structs

  • The FF3_1 context structure

Functions