aboutsummaryrefslogtreecommitdiffstats
path: root/src/codec/base64/base64.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-28 22:14:54 +0000
committerlloyd <[email protected]>2008-09-28 22:14:54 +0000
commit31204986023619c385d378e79a6511bb81ef7b78 (patch)
treece272a6585dc070f750f6875b0450d53145b935d /src/codec/base64/base64.h
parent42c0fe76ab6d9625d0e51c68b8dd187322c991bd (diff)
Move almost all of the ASN.1, BER, and DER codec related code into new
module asn1 Move hex and base64 codecs into new codecs directory. Also move zlib and bzip2 to codecs from compress.
Diffstat (limited to 'src/codec/base64/base64.h')
-rw-r--r--src/codec/base64/base64.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/codec/base64/base64.h b/src/codec/base64/base64.h
new file mode 100644
index 000000000..0003875a6
--- /dev/null
+++ b/src/codec/base64/base64.h
@@ -0,0 +1,60 @@
+/*************************************************
+* Base64 Encoder/Decoder Header File *
+* (C) 1999-2007 Jack Lloyd *
+*************************************************/
+
+#ifndef BOTAN_BASE64_H__
+#define BOTAN_BASE64_H__
+
+#include <botan/filter.h>
+#include <botan/enums.h>
+
+namespace Botan {
+
+/*************************************************
+* Base64 Encoder *
+*************************************************/
+class BOTAN_DLL 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, 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;
+ };
+
+/*************************************************
+* Base64 Decoder *
+*************************************************/
+class BOTAN_DLL 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