diff options
author | lloyd <[email protected]> | 2010-10-12 16:43:24 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-10-12 16:43:24 +0000 |
commit | e7e3af16a3540e1d7a84e085aa1ea7c55f627930 (patch) | |
tree | ce25c4e74b2696c017c78c8a9afe297d0f1fcb27 /src/kdf | |
parent | e3e02712563e03fbfd6b474cfaa7c0dfdf08f267 (diff) |
Add a simple update_be to BufferedComputation that takes an integer
and writes the bytes to the stream in big-endian order. Use it in
KDF2, MGF1, and FPE.
Diffstat (limited to 'src/kdf')
-rw-r--r-- | src/kdf/kdf2/kdf2.cpp | 5 | ||||
-rw-r--r-- | src/kdf/mgf1/mgf1.cpp | 4 |
2 files changed, 3 insertions, 6 deletions
diff --git a/src/kdf/kdf2/kdf2.cpp b/src/kdf/kdf2/kdf2.cpp index b10077e35..51b9e41ea 100644 --- a/src/kdf/kdf2/kdf2.cpp +++ b/src/kdf/kdf2/kdf2.cpp @@ -6,7 +6,6 @@ */ #include <botan/kdf2.h> -#include <botan/get_byte.h> namespace Botan { @@ -23,9 +22,9 @@ SecureVector<byte> KDF2::derive(size_t out_len, while(out_len && counter) { hash->update(secret, secret_len); - for(size_t i = 0; i != 4; ++i) - hash->update(get_byte(i, counter)); + hash->update_be(counter); hash->update(P, P_len); + SecureVector<byte> hash_result = hash->final(); size_t added = std::min(hash_result.size(), out_len); diff --git a/src/kdf/mgf1/mgf1.cpp b/src/kdf/mgf1/mgf1.cpp index 6dc028bad..7d949c2b8 100644 --- a/src/kdf/mgf1/mgf1.cpp +++ b/src/kdf/mgf1/mgf1.cpp @@ -6,7 +6,6 @@ */ #include <botan/mgf1.h> -#include <botan/get_byte.h> #include <botan/exceptn.h> #include <botan/internal/xor_buf.h> #include <algorithm> @@ -25,8 +24,7 @@ void MGF1::mask(const byte in[], size_t in_len, byte out[], while(out_len) { hash->update(in, in_len); - for(size_t i = 0; i != 4; ++i) - hash->update(get_byte(i, counter)); + hash->update_be(counter); SecureVector<byte> buffer = hash->final(); size_t xored = std::min<size_t>(buffer.size(), out_len); |