aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-10-13 13:15:20 +0000
committerlloyd <[email protected]>2010-10-13 13:15:20 +0000
commit9dc1fe2b5ca62adc2da69e1b55d9fa880833b2ca (patch)
tree912c7b12d2ae03b974c1641956b8786a2dd387c6
parent3f641af95c6ce8bebc7afa5d75ae41c6da0d7714 (diff)
Remove the upto argument to update_be
-rw-r--r--src/constructs/fpe/fpe.cpp8
-rw-r--r--src/utils/buf_comp/buf_comp.h13
2 files changed, 12 insertions, 9 deletions
diff --git a/src/constructs/fpe/fpe.cpp b/src/constructs/fpe/fpe.cpp
index d7101c544..3747171c2 100644
--- a/src/constructs/fpe/fpe.cpp
+++ b/src/constructs/fpe/fpe.cpp
@@ -105,10 +105,10 @@ FPE_Encryptor::FPE_Encryptor(const SymmetricKey& key,
if(n_bin.size() > MAX_N_BYTES)
throw std::runtime_error("N is too large for FPE encryption");
- mac->update_be(n_bin.size(), 4);
+ mac->update_be((u32bit)n_bin.size());
mac->update(&n_bin[0], n_bin.size());
- mac->update_be(tweak.size(), 4);
+ mac->update_be((u32bit)tweak.size());
mac->update(&tweak[0], tweak.size());
mac_n_t = mac->final();
@@ -119,9 +119,9 @@ BigInt FPE_Encryptor::operator()(u32bit round_no, const BigInt& R)
SecureVector<byte> r_bin = BigInt::encode(R);
mac->update(mac_n_t);
- mac->update_be(round_no, 4);
+ mac->update_be(round_no);
- mac->update_be(r_bin.size(), 4);
+ mac->update_be((u32bit)r_bin.size());
mac->update(&r_bin[0], r_bin.size());
SecureVector<byte> X = mac->final();
diff --git a/src/utils/buf_comp/buf_comp.h b/src/utils/buf_comp/buf_comp.h
index a64d807dd..0b0ef6e16 100644
--- a/src/utils/buf_comp/buf_comp.h
+++ b/src/utils/buf_comp/buf_comp.h
@@ -14,9 +14,8 @@
namespace Botan {
/**
-* This class represents any kind of computation which
-* uses an internal state,
-* such as hash functions.
+* This class represents any kind of computation which uses an internal
+* state, such as hash functions or MACs
*/
class BOTAN_DLL BufferedComputation
{
@@ -48,9 +47,13 @@ class BOTAN_DLL BufferedComputation
add_data(&in[0], in.size());
}
- template<typename T> void update_be(const T in, size_t upto = sizeof(T))
+ /**
+ * Add an integer in big-endian order
+ * @param in the value
+ */
+ template<typename T> void update_be(const T in)
{
- for(size_t i = 0; i != std::min(upto, sizeof(T)); ++i)
+ for(size_t i = 0; i != sizeof(T); ++i)
{
byte b = get_byte(i, in);
add_data(&b, 1);