aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-01-31 22:31:41 +0000
committerlloyd <[email protected]>2014-01-31 22:31:41 +0000
commit49b744e70a8daeddde6c9e7ab81da4e4c523ffe2 (patch)
tree7f34fecd9291457f9411d1a683d63ac277b62c66 /src/lib
parente11024f26113189f45ca1759f6a045ca6989849e (diff)
Round up Transformation_Filters internal buffer size to the next multiple of 1024
if the underlying transform uses a small update granularity.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/filters/transform_filter.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/lib/filters/transform_filter.cpp b/src/lib/filters/transform_filter.cpp
index 5465b9d9b..b5eeff4a8 100644
--- a/src/lib/filters/transform_filter.cpp
+++ b/src/lib/filters/transform_filter.cpp
@@ -1,16 +1,31 @@
/*
* Filter interface for Transformations
-* (C) 2013 Jack Lloyd
+* (C) 2013,2014 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#include <botan/transform_filter.h>
+#include <botan/internal/rounding.h>
namespace Botan {
+namespace {
+
+size_t choose_update_size(size_t update_granularity)
+ {
+ const size_t target_size = 1024;
+
+ if(update_granularity >= target_size)
+ return update_granularity;
+
+ return round_up(target_size, update_granularity);
+ }
+
+}
+
Transformation_Filter::Transformation_Filter(Transformation* transform) :
- Buffered_Filter(transform->update_granularity(),
+ Buffered_Filter(choose_update_size(transform->update_granularity()),
transform->minimum_final_size()),
m_nonce(transform->default_nonce_length() == 0),
m_transform(transform),