summaryrefslogtreecommitdiff
path: root/basecode.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2015-11-05 01:59:46 -0500
committerJeffrey Walton <noloader@gmail.com>2015-11-05 01:59:46 -0500
commit48809d4e85c125814425c621d8d0d89f95405924 (patch)
tree1010fd16c4b1199f3d27dd726dda241a2bd29f83 /basecode.h
parent025337a94aceb75d188149db70c2094673772816 (diff)
downloadcryptopp-git-48809d4e85c125814425c621d8d0d89f95405924.tar.gz
CRYPTOPP 5.6.3 RC6 checkin
Diffstat (limited to 'basecode.h')
-rw-r--r--basecode.h180
1 files changed, 94 insertions, 86 deletions
diff --git a/basecode.h b/basecode.h
index ee736dcf..ca2323d1 100644
--- a/basecode.h
+++ b/basecode.h
@@ -1,86 +1,94 @@
-#ifndef CRYPTOPP_BASECODE_H
-#define CRYPTOPP_BASECODE_H
-
-#include "filters.h"
-#include "algparam.h"
-#include "argnames.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-//! base n encoder, where n is a power of 2
-class CRYPTOPP_DLL BaseN_Encoder : public Unflushable<Filter>
-{
-public:
- BaseN_Encoder(BufferedTransformation *attachment=NULL)
- : m_alphabet(NULL) {Detach(attachment);}
-
- BaseN_Encoder(const byte *alphabet, int log2base, BufferedTransformation *attachment=NULL, int padding=-1)
- {
- Detach(attachment);
- IsolatedInitialize(MakeParameters(Name::EncodingLookupArray(), alphabet)
- (Name::Log2Base(), log2base)
- (Name::Pad(), padding != -1)
- (Name::PaddingByte(), byte(padding)));
- }
-
- void IsolatedInitialize(const NameValuePairs &parameters);
- size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking);
-
-private:
- const byte *m_alphabet;
- int m_padding, m_bitsPerChar, m_outputBlockSize;
- int m_bytePos, m_bitPos;
- SecByteBlock m_outBuf;
-};
-
-//! base n decoder, where n is a power of 2
-class CRYPTOPP_DLL BaseN_Decoder : public Unflushable<Filter>
-{
-public:
- BaseN_Decoder(BufferedTransformation *attachment=NULL)
- : m_lookup(NULL) {Detach(attachment);}
-
- BaseN_Decoder(const int *lookup, int log2base, BufferedTransformation *attachment=NULL)
- {
- Detach(attachment);
- IsolatedInitialize(MakeParameters(Name::DecodingLookupArray(), lookup)(Name::Log2Base(), log2base));
- }
-
- void IsolatedInitialize(const NameValuePairs &parameters);
- size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking);
-
- static void CRYPTOPP_API InitializeDecodingLookupArray(int *lookup, const byte *alphabet, unsigned int base, bool caseInsensitive);
-
-private:
- const int *m_lookup;
- int /*m_padding,*/ m_bitsPerChar, m_outputBlockSize;
- int m_bytePos, m_bitPos;
- SecByteBlock m_outBuf;
-};
-
-//! filter that breaks input stream into groups of fixed size
-class CRYPTOPP_DLL Grouper : public Bufferless<Filter>
-{
-public:
- Grouper(BufferedTransformation *attachment=NULL)
- {Detach(attachment);}
-
- Grouper(int groupSize, const std::string &separator, const std::string &terminator, BufferedTransformation *attachment=NULL)
- {
- Detach(attachment);
- IsolatedInitialize(MakeParameters(Name::GroupSize(), groupSize)
- (Name::Separator(), ConstByteArrayParameter(separator))
- (Name::Terminator(), ConstByteArrayParameter(terminator)));
- }
-
- void IsolatedInitialize(const NameValuePairs &parameters);
- size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking);
-
-private:
- SecByteBlock m_separator, m_terminator;
- size_t m_groupSize, m_counter;
-};
-
-NAMESPACE_END
-
-#endif
+// basecode.h - written and placed in the public domain by Wei Dai
+
+//! \file
+//! \brief Base class files for working with encoders and decoders.
+
+#ifndef CRYPTOPP_BASECODE_H
+#define CRYPTOPP_BASECODE_H
+
+#include "cryptlib.h"
+#include "filters.h"
+#include "algparam.h"
+#include "argnames.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+//! \class BaseN_Encoder
+//! \details base n encoder, where n is a power of 2
+class CRYPTOPP_DLL BaseN_Encoder : public Unflushable<Filter>
+{
+public:
+ BaseN_Encoder(BufferedTransformation *attachment=NULL)
+ {Detach(attachment);}
+
+ BaseN_Encoder(const byte *alphabet, int log2base, BufferedTransformation *attachment=NULL, int padding=-1)
+ {
+ Detach(attachment);
+ IsolatedInitialize(MakeParameters(Name::EncodingLookupArray(), alphabet)
+ (Name::Log2Base(), log2base)
+ (Name::Pad(), padding != -1)
+ (Name::PaddingByte(), byte(padding)));
+ }
+
+ void IsolatedInitialize(const NameValuePairs &parameters);
+ size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking);
+
+private:
+ const byte *m_alphabet;
+ int m_padding, m_bitsPerChar, m_outputBlockSize;
+ int m_bytePos, m_bitPos;
+ SecByteBlock m_outBuf;
+};
+
+//! \class BaseN_Decoder
+//! \details base n encoder, where n is a power of 2
+class CRYPTOPP_DLL BaseN_Decoder : public Unflushable<Filter>
+{
+public:
+ BaseN_Decoder(BufferedTransformation *attachment=NULL)
+ {Detach(attachment);}
+
+ BaseN_Decoder(const int *lookup, int log2base, BufferedTransformation *attachment=NULL)
+ {
+ Detach(attachment);
+ IsolatedInitialize(MakeParameters(Name::DecodingLookupArray(), lookup)(Name::Log2Base(), log2base));
+ }
+
+ void IsolatedInitialize(const NameValuePairs &parameters);
+ size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking);
+
+ static void CRYPTOPP_API InitializeDecodingLookupArray(int *lookup, const byte *alphabet, unsigned int base, bool caseInsensitive);
+
+private:
+ const int *m_lookup;
+ int m_padding, m_bitsPerChar, m_outputBlockSize;
+ int m_bytePos, m_bitPos;
+ SecByteBlock m_outBuf;
+};
+
+//! filter that breaks input stream into groups of fixed size
+class CRYPTOPP_DLL Grouper : public Bufferless<Filter>
+{
+public:
+ Grouper(BufferedTransformation *attachment=NULL)
+ {Detach(attachment);}
+
+ Grouper(int groupSize, const std::string &separator, const std::string &terminator, BufferedTransformation *attachment=NULL)
+ {
+ Detach(attachment);
+ IsolatedInitialize(MakeParameters(Name::GroupSize(), groupSize)
+ (Name::Separator(), ConstByteArrayParameter(separator))
+ (Name::Terminator(), ConstByteArrayParameter(terminator)));
+ }
+
+ void IsolatedInitialize(const NameValuePairs &parameters);
+ size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking);
+
+private:
+ SecByteBlock m_separator, m_terminator;
+ size_t m_groupSize, m_counter;
+};
+
+NAMESPACE_END
+
+#endif