aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-11-05 07:52:35 +0000
committerlloyd <[email protected]>2009-11-05 07:52:35 +0000
commita6177d3af54437375c752b8046230b7fb98c8563 (patch)
tree2e0199f9fb93725c1a2f0cfea03458c03bbbbba9 /doc/examples
parent56c3c044215f36fe00c9a8a2e06a84f969996cb7 (diff)
Add format preserving encryption, design is FE1/FD1 from the paper
Format-Preserving Encryption (http://eprint.iacr.org/2009/251). This doesn't implement the rank functions which are necessary for the actual format-preserving part, though that would be nice to add to the example.
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/fpe.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/examples/fpe.cpp b/doc/examples/fpe.cpp
new file mode 100644
index 000000000..9384a0d2d
--- /dev/null
+++ b/doc/examples/fpe.cpp
@@ -0,0 +1,22 @@
+#include <botan/fpe.h>
+#include <botan/init.h>
+
+using namespace Botan;
+
+#include <iostream>
+
+int main()
+ {
+ LibraryInitializer init;
+
+ BigInt n = 100000000;
+ BigInt x = 49604394;
+
+ SymmetricKey key("AAAAAAAAAAAAAAAA");
+ MemoryVector<byte> tweak(4);
+
+ BigInt c = fpe_encrypt(n, x, key, tweak);
+ BigInt p = fpe_decrypt(n, c, key, tweak);
+
+ std::cout << c << ' ' << p << ' ' << x << '\n';
+ }