Botan  2.6.0
Crypto and TLS for C++11
Functions
Botan::FPE Namespace Reference

Functions

BigInt fe1_decrypt (const BigInt &n, const BigInt &X, const SymmetricKey &key, const std::vector< uint8_t > &tweak)
 
BigInt fe1_encrypt (const BigInt &n, const BigInt &X, const SymmetricKey &key, const std::vector< uint8_t > &tweak)
 

Function Documentation

◆ fe1_decrypt()

BigInt Botan::FPE::fe1_decrypt ( const BigInt n,
const BigInt X,
const SymmetricKey key,
const std::vector< uint8_t > &  tweak 
)

Decrypt X from and onto the group Z_n using key and tweak

Parameters
nthe modulus
Xthe ciphertext as a BigInt
keyis the key used for encryption
tweakthe same tweak used for encryption
Warning
This function is hardcoded to use only 3 rounds which may be insecure for some values of n. Prefer FPE_FE1 class

Definition at line 205 of file fpe_fe1.cpp.

References Botan::FPE_FE1::decrypt(), Botan::SymmetricAlgorithm::set_key(), and X.

208  {
209  FPE_FE1 fpe(n, 3, true, "HMAC(SHA-256)");
210  fpe.set_key(key);
211  return fpe.decrypt(X, tweak.data(), tweak.size());
212  }
fe X
Definition: ge.cpp:27

◆ fe1_encrypt()

BigInt Botan::FPE::fe1_encrypt ( const BigInt n,
const BigInt X,
const SymmetricKey key,
const std::vector< uint8_t > &  tweak 
)

Format Preserving Encryption using the scheme FE1 from the paper "Format-Preserving Encryption" by Bellare, Rogaway, et al (https://eprint.iacr.org/2009/251)

Encrypt X from and onto the group Z_n using key and tweak

Parameters
nthe modulus
Xthe plaintext as a BigInt
keya random key
tweakwill modify the ciphertext (think of as an IV)
Warning
This function is hardcoded to use only 3 rounds which may be insecure for some values of n. Prefer FPE_FE1 class

Definition at line 196 of file fpe_fe1.cpp.

References Botan::FPE_FE1::encrypt(), Botan::SymmetricAlgorithm::set_key(), and X.

199  {
200  FPE_FE1 fpe(n, 3, true, "HMAC(SHA-256)");
201  fpe.set_key(key);
202  return fpe.encrypt(X, tweak.data(), tweak.size());
203  }
fe X
Definition: ge.cpp:27