diff options
-rw-r--r-- | include/base64.h | 3 | ||||
-rw-r--r-- | src/base64.cpp | 6 |
2 files changed, 5 insertions, 4 deletions
diff --git a/include/base64.h b/include/base64.h index bd3921ab8..ec144dc63 100644 --- a/include/base64.h +++ b/include/base64.h @@ -21,13 +21,14 @@ class Base64_Encoder : public Filter void write(const byte[], u32bit); void end_msg(); - Base64_Encoder(bool = false, u32bit = 72); + Base64_Encoder(bool = false, u32bit = 72, bool = false); private: void encode_and_send(const byte[], u32bit); void do_output(const byte[], u32bit); static const byte BIN_TO_BASE64[64]; const u32bit line_length; + const bool trailing_newline; SecureVector<byte> in, out; u32bit position, counter; }; diff --git a/src/base64.cpp b/src/base64.cpp index 6cfdc921e..787c7a292 100644 --- a/src/base64.cpp +++ b/src/base64.cpp @@ -12,8 +12,8 @@ namespace Botan { /************************************************* * Base64_Encoder Constructor * *************************************************/ -Base64_Encoder::Base64_Encoder(bool breaks, u32bit length) : - line_length(breaks ? length : 0) +Base64_Encoder::Base64_Encoder(bool breaks, u32bit length, bool t_n) : + line_length(breaks ? length : 0), trailing_newline(t_n) { in.create(48); out.create(4); @@ -118,7 +118,7 @@ void Base64_Encoder::end_msg() do_output(out, 4); } - if(counter && line_length) + if(trailing_newline || (counter && line_length)) send('\n'); counter = position = 0; |