aboutsummaryrefslogtreecommitdiffstats
path: root/include/base64.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-05-18 18:33:19 +0000
committerlloyd <[email protected]>2006-05-18 18:33:19 +0000
commita2c99d3270eb73ef2db5704fc54356c6b75096f8 (patch)
treead3d6c4fcc8dd0f403f8105598943616246fe172 /include/base64.h
Initial checkin1.5.6
Diffstat (limited to 'include/base64.h')
-rw-r--r--include/base64.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/include/base64.h b/include/base64.h
new file mode 100644
index 000000000..98b195e58
--- /dev/null
+++ b/include/base64.h
@@ -0,0 +1,58 @@
+/*************************************************
+* Base64 Encoder/Decoder Header File *
+* (C) 1999-2006 The Botan Project *
+*************************************************/
+
+#ifndef BOTAN_BASE64_H__
+#define BOTAN_BASE64_H__
+
+#include <botan/filter.h>
+
+namespace Botan {
+
+/*************************************************
+* Base64 Encoder *
+*************************************************/
+class Base64_Encoder : public Filter
+ {
+ public:
+ static void encode(const byte[3], byte[4]);
+
+ void write(const byte[], u32bit);
+ void end_msg();
+ Base64_Encoder(bool = false, u32bit = 72);
+ 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;
+ SecureVector<byte> in, out;
+ u32bit position, counter;
+ };
+
+/*************************************************
+* Base64 Decoder *
+*************************************************/
+class Base64_Decoder : public Filter
+ {
+ public:
+ static void decode(const byte[4], byte[3]);
+ static bool is_valid(byte);
+
+ void write(const byte[], u32bit);
+ void end_msg();
+ Base64_Decoder(Decoder_Checking = NONE);
+ private:
+ void decode_and_send(const byte[], u32bit);
+ void handle_bad_char(byte);
+ static const byte BASE64_TO_BIN[256];
+
+ const Decoder_Checking checking;
+ SecureVector<byte> in, out;
+ u32bit position;
+ };
+
+}
+
+#endif