aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-04-20 19:10:32 +0000
committerlloyd <[email protected]>2011-04-20 19:10:32 +0000
commit162b5ca3c330af4b09823f286cd18cc21d3c2ac4 (patch)
tree2633a5d409dd94d278b9ea16d36e185f6c5b9088 /src
parent4e86628e4a7921ba7bdfa59faf72c1307552fc1e (diff)
It's likely that other FPE methods will be desirable once they are
standardized by NIST; the FPE currently included is just a random one that was relatively easy to implement. Move the header to fpe_fe1.h, and rename the function. Update the example and add some documentation for it.
Diffstat (limited to 'src')
-rw-r--r--src/constructs/fpe_fe1/fpe_fe1.cpp (renamed from src/constructs/fpe/fpe.cpp)10
-rw-r--r--src/constructs/fpe_fe1/fpe_fe1.h (renamed from src/constructs/fpe/fpe.h)14
-rw-r--r--src/constructs/fpe_fe1/info.txt (renamed from src/constructs/fpe/info.txt)2
3 files changed, 17 insertions, 9 deletions
diff --git a/src/constructs/fpe/fpe.cpp b/src/constructs/fpe_fe1/fpe_fe1.cpp
index 5491af133..91d328c17 100644
--- a/src/constructs/fpe/fpe.cpp
+++ b/src/constructs/fpe_fe1/fpe_fe1.cpp
@@ -8,7 +8,7 @@
* Distributed under the terms of the Botan license
*/
-#include <botan/fpe.h>
+#include <botan/fpe_fe1.h>
#include <botan/numthry.h>
#include <botan/hmac.h>
#include <botan/sha2_32.h>
@@ -16,6 +16,8 @@
namespace Botan {
+namespace FPE {
+
namespace {
// Normally FPE is for SSNs, CC#s, etc, nothing too big
@@ -133,7 +135,7 @@ BigInt FPE_Encryptor::operator()(size_t round_no, const BigInt& R)
/*
* Generic Z_n FPE encryption, FE1 scheme
*/
-BigInt fpe_encrypt(const BigInt& n, const BigInt& X0,
+BigInt fe1_encrypt(const BigInt& n, const BigInt& X0,
const SymmetricKey& key,
const MemoryRegion<byte>& tweak)
{
@@ -161,7 +163,7 @@ BigInt fpe_encrypt(const BigInt& n, const BigInt& X0,
/*
* Generic Z_n FPE decryption, FD1 scheme
*/
-BigInt fpe_decrypt(const BigInt& n, const BigInt& X0,
+BigInt fe1_decrypt(const BigInt& n, const BigInt& X0,
const SymmetricKey& key,
const MemoryRegion<byte>& tweak)
{
@@ -187,3 +189,5 @@ BigInt fpe_decrypt(const BigInt& n, const BigInt& X0,
}
}
+
+}
diff --git a/src/constructs/fpe/fpe.h b/src/constructs/fpe_fe1/fpe_fe1.h
index 7a4a7861a..da9a6bcb6 100644
--- a/src/constructs/fpe/fpe.h
+++ b/src/constructs/fpe_fe1/fpe_fe1.h
@@ -1,18 +1,20 @@
/*
-* Format Preserving Encryption
+* Format Preserving Encryption (FE1 scheme)
* (C) 2009 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
-#ifndef BOTAN_FORMAT_PRESERVING_ENCRYPTION_H__
-#define BOTAN_FORMAT_PRESERVING_ENCRYPTION_H__
+#ifndef BOTAN_FPE_FE1_H__
+#define BOTAN_FPE_FE1_H__
#include <botan/bigint.h>
#include <botan/symkey.h>
namespace Botan {
+namespace FPE {
+
/**
* Encrypt X from and onto the group Z_n using key and tweak
* @param n the modulus
@@ -20,7 +22,7 @@ namespace Botan {
* @param key a random key
* @param tweak will modify the ciphertext (think of as an IV)
*/
-BigInt BOTAN_DLL fpe_encrypt(const BigInt& n, const BigInt& X,
+BigInt BOTAN_DLL fe1_encrypt(const BigInt& n, const BigInt& X,
const SymmetricKey& key,
const MemoryRegion<byte>& tweak);
@@ -31,10 +33,12 @@ BigInt BOTAN_DLL fpe_encrypt(const BigInt& n, const BigInt& X,
* @param key is the key used for encryption
* @param tweak the same tweak used for encryption
*/
-BigInt BOTAN_DLL fpe_decrypt(const BigInt& n, const BigInt& X,
+BigInt BOTAN_DLL fe1_decrypt(const BigInt& n, const BigInt& X,
const SymmetricKey& key,
const MemoryRegion<byte>& tweak);
}
+}
+
#endif
diff --git a/src/constructs/fpe/info.txt b/src/constructs/fpe_fe1/info.txt
index 078eb2135..33b5a1c80 100644
--- a/src/constructs/fpe/info.txt
+++ b/src/constructs/fpe_fe1/info.txt
@@ -1,4 +1,4 @@
-define FORMAT_PRESERVING_ENCRYPTION
+define FPE_FE1
<requires>
hmac