diff options
author | lloyd <[email protected]> | 2014-01-18 23:00:53 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-01-18 23:00:53 +0000 |
commit | d5354c1c3ee0067dd35ca253d4b8914f870cea75 (patch) | |
tree | 09dce01e5489528a2fe1874547ae97effccdd746 /src/lib/constructs | |
parent | 700ae0440c1fac65a218fc2ae5883bdc63683f08 (diff) |
More unique_ptr, and pull <memory> all the way up to types.h
Diffstat (limited to 'src/lib/constructs')
-rw-r--r-- | src/lib/constructs/fpe_fe1/fpe_fe1.cpp | 12 | ||||
-rw-r--r-- | src/lib/constructs/fpe_fe1/fpe_fe1.h | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/constructs/fpe_fe1/fpe_fe1.cpp b/src/lib/constructs/fpe_fe1/fpe_fe1.cpp index b22d3a8df..da0ef1081 100644 --- a/src/lib/constructs/fpe_fe1/fpe_fe1.cpp +++ b/src/lib/constructs/fpe_fe1/fpe_fe1.cpp @@ -1,8 +1,5 @@ /* -* Format Preserving Encryption using the scheme FE1 from the paper -* "Format-Preserving Encryption" by Bellare, Rogaway, et al -* (http://eprint.iacr.org/2009/251) -* +* Format Preserving Encryption (FE1 scheme) * (C) 2009 Jack Lloyd * * Distributed under the terms of the Botan license @@ -13,6 +10,7 @@ #include <botan/hmac.h> #include <botan/sha2_32.h> #include <stdexcept> +#include <memory> namespace Botan { @@ -86,12 +84,10 @@ class FPE_Encryptor const BigInt& n, const std::vector<byte>& tweak); - ~FPE_Encryptor() { delete mac; } - BigInt operator()(size_t i, const BigInt& R); private: - MessageAuthenticationCode* mac; + std::unique_ptr<MessageAuthenticationCode> mac; std::vector<byte> mac_n_t; }; @@ -99,7 +95,7 @@ FPE_Encryptor::FPE_Encryptor(const SymmetricKey& key, const BigInt& n, const std::vector<byte>& tweak) { - mac = new HMAC(new SHA_256); + mac.reset(new HMAC(new SHA_256)); mac->set_key(key); std::vector<byte> n_bin = BigInt::encode(n); diff --git a/src/lib/constructs/fpe_fe1/fpe_fe1.h b/src/lib/constructs/fpe_fe1/fpe_fe1.h index 66e7f1cfa..555f97d3f 100644 --- a/src/lib/constructs/fpe_fe1/fpe_fe1.h +++ b/src/lib/constructs/fpe_fe1/fpe_fe1.h @@ -16,6 +16,10 @@ namespace Botan { namespace FPE { /** +* Format Preserving Encryption using the scheme FE1 from the paper +* "Format-Preserving Encryption" by Bellare, Rogaway, et al +* (http://eprint.iacr.org/2009/251) +* * Encrypt X from and onto the group Z_n using key and tweak * @param n the modulus * @param X the plaintext as a BigInt |