aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-02-28 13:51:54 -0500
committerJack Lloyd <[email protected]>2018-02-28 15:03:50 -0500
commitd7ee63924da94fe7e46af7012cde971ef7588732 (patch)
tree4ac666072b75f9f46474e491142e4128c422a50b /src/cli
parent3870a2a59a9940635a133fbe60ab05c9815a4d1c (diff)
Optimize FE1 format preserving encryption
Expose the state as the FPE_FE1 class which allows most values to be precomputed. Approx 6-8 times faster.
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/speed.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp
index 1e8c3135f..b29c8b9e9 100644
--- a/src/cli/speed.cpp
+++ b/src/cli/speed.cpp
@@ -1290,17 +1290,20 @@ class Speed final : public Command
Botan::BigInt x = 1;
+ Botan::FPE_FE1 fpe_fe1(n, 3, "HMAC(SHA-256)");
+ fpe_fe1.set_key(key);
+
while(enc_timer.under(runtime))
{
enc_timer.start();
- x = Botan::FPE::fe1_encrypt(n, x, key, tweak);
+ x = fpe_fe1.encrypt(x, tweak.data(), tweak.size());
enc_timer.stop();
}
for(size_t i = 0; i != enc_timer.events(); ++i)
{
dec_timer.start();
- x = Botan::FPE::fe1_decrypt(n, x, key, tweak);
+ x = fpe_fe1.decrypt(x, tweak.data(), tweak.size());
dec_timer.stop();
}