From 49b744e70a8daeddde6c9e7ab81da4e4c523ffe2 Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 31 Jan 2014 22:31:41 +0000 Subject: Round up Transformation_Filters internal buffer size to the next multiple of 1024 if the underlying transform uses a small update granularity. --- src/lib/filters/transform_filter.cpp | 19 +++++++++++++++++-- 1 file 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 +#include 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), -- cgit v1.2.3