Botan 3.7.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 195 of file fpe_fe1.cpp.

195 {
196 FPE_FE1 fpe(n, 3, true, "HMAC(SHA-256)");
197 fpe.set_key(key);
198 return fpe.decrypt(X, tweak.data(), tweak.size());
199}
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 189 of file fpe_fe1.cpp.

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

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