Botan 2.19.5 Crypto and TLS for C&

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

  n | the modulus
  X | the ciphertext as a BigInt
  key | is the key used for encryption
  tweak | the 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 207 of file fpe_fe1.cpp.

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

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

## ◆ 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

  n | the modulus
  X | the plaintext as a BigInt
  key | a random key
  tweak | will 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 198 of file fpe_fe1.cpp.

201 {
202 FPE_FE1 fpe(n, 3, true, "HMAC(SHA-256)");
203 fpe.set_key(key);
204 return fpe.encrypt(X, tweak.data(), tweak.size());
205 }

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