From a6177d3af54437375c752b8046230b7fb98c8563 Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 5 Nov 2009 07:52:35 +0000 Subject: 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. --- doc/examples/fpe.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 doc/examples/fpe.cpp (limited to 'doc') 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 +#include + +using namespace Botan; + +#include + +int main() + { + LibraryInitializer init; + + BigInt n = 100000000; + BigInt x = 49604394; + + SymmetricKey key("AAAAAAAAAAAAAAAA"); + MemoryVector tweak(4); + + BigInt c = fpe_encrypt(n, x, key, tweak); + BigInt p = fpe_decrypt(n, c, key, tweak); + + std::cout << c << ' ' << p << ' ' << x << '\n'; + } -- cgit v1.2.3