Botan 3.6.1
Crypto and TLS for C&
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 193 of file fpe_fe1.cpp.

193 {
194 FPE_FE1 fpe(n, 3, true, "HMAC(SHA-256)");
195 fpe.set_key(key);
196 return fpe.decrypt(X, tweak.data(), tweak.size());
197}
FE_25519 X
Definition ge.cpp:25

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
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 187 of file fpe_fe1.cpp.

187 {
188 FPE_FE1 fpe(n, 3, true, "HMAC(SHA-256)");
189 fpe.set_key(key);
190 return fpe.encrypt(X, tweak.data(), tweak.size());
191}

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