From c68fd3ad95bed0ee93b59f299adff6e94e2ffa88 Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 13 Oct 2008 03:39:38 +0000 Subject: Doxygen comments for base64 and hex from InSiTo --- src/codec/base64/base64.h | 57 +++++++++++++++++++++++++++++++++++++---------- src/codec/hex/hex.h | 47 +++++++++++++++++++++++++++++--------- 2 files changed, 81 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/codec/base64/base64.h b/src/codec/base64/base64.h index 0003875a6..7f5c7cfc7 100644 --- a/src/codec/base64/base64.h +++ b/src/codec/base64/base64.h @@ -11,17 +11,34 @@ namespace Botan { -/************************************************* -* Base64 Encoder * -*************************************************/ +/** +* This class represents a Base64 encoder. +*/ class BOTAN_DLL Base64_Encoder : public Filter { public: - static void encode(const byte[3], byte[4]); + static void encode(const byte in[3], byte out[4]); + + /** + * Input a part of a message to the encoder. + * @param input the message to input as a byte array + * @param length the length of the byte array input + */ + void write(const byte input[], u32bit length); - void write(const byte[], u32bit); + /** + * Inform the Encoder that the current message shall be closed. + */ void end_msg(); - Base64_Encoder(bool = false, u32bit = 72, bool = false); + + /** + * Create a base64 encoder. + * @param breaks whether to use line breaks in the Streamcipheroutput + * @param length the length of the lines of the output + * @param t_n whether to use a trailing newline + */ + Base64_Encoder(bool breaks = false, u32bit length = 72, + bool t_n = false); private: void encode_and_send(const byte[], u32bit); void do_output(const byte[], u32bit); @@ -33,18 +50,34 @@ class BOTAN_DLL Base64_Encoder : public Filter u32bit position, counter; }; -/************************************************* -* Base64 Decoder * -*************************************************/ +/** +* This object represents a Base64 decoder. +*/ class BOTAN_DLL Base64_Decoder : public Filter { public: - static void decode(const byte[4], byte[3]); + static void decode(const byte input[4], byte output[3]); + static bool is_valid(byte); - void write(const byte[], u32bit); + /** + * Input a part of a message to the decoder. + * @param input the message to input as a byte array + * @param length the length of the byte array input + */ + void write(const byte input[], u32bit length); + + /** + * Inform the Encoder that the current message shall be closed. + */ void end_msg(); - Base64_Decoder(Decoder_Checking = NONE); + + /** + * Create a base64 encoder. + * @param checking the type of checking that shall be performed by + * the decoder + */ + Base64_Decoder(Decoder_Checking checking = NONE); private: void decode_and_send(const byte[], u32bit); void handle_bad_char(byte); diff --git a/src/codec/hex/hex.h b/src/codec/hex/hex.h index 0ecddb588..2b4c15462 100644 --- a/src/codec/hex/hex.h +++ b/src/codec/hex/hex.h @@ -11,20 +11,40 @@ namespace Botan { -/************************************************* -* Hex Encoder * -*************************************************/ +/** +* This class represents a hex encoder. It encodes byte arrays to hex strings. +*/ class BOTAN_DLL Hex_Encoder : public Filter { public: + /** + * Whether to use uppercase or lowercase letters for the encoded string. + */ enum Case { Uppercase, Lowercase }; - static void encode(byte, byte[2], Case = Uppercase); - void write(const byte[], u32bit); + /** + Encode a single byte into two hex characters + */ + static void encode(byte in, byte out[2], Case the_case = Uppercase); + + void write(const byte in[], u32bit length); void end_msg(); - Hex_Encoder(Case); - Hex_Encoder(bool = false, u32bit = 72, Case = Uppercase); + /** + * Create a hex encoder. + * @param the_case the case to use in the encoded strings. + */ + Hex_Encoder(Case the_case); + + /** + * Create a hex encoder. + * @param newlines should newlines be used + * @param line_length if newlines are used, how long are lines + * @param the_case the case to use in the encoded strings + */ + Hex_Encoder(bool newlines = false, + u32bit line_length = 72, + Case the_case = Uppercase); private: void encode_and_send(const byte[], u32bit); static const byte BIN_TO_HEX_UPPER[16]; @@ -36,9 +56,9 @@ class BOTAN_DLL Hex_Encoder : public Filter u32bit position, counter; }; -/************************************************* -* Hex Decoder * -*************************************************/ +/** +* This class represents a hex decoder. It converts hex strings to byte arrays. +*/ class BOTAN_DLL Hex_Decoder : public Filter { public: @@ -48,7 +68,12 @@ class BOTAN_DLL Hex_Decoder : public Filter void write(const byte[], u32bit); void end_msg(); - Hex_Decoder(Decoder_Checking = NONE); + /** + * Construct a Hex Decoder using the specified + * character checking. + * @param checking the checking to use during decoding. + */ + Hex_Decoder(Decoder_Checking checking = NONE); private: void decode_and_send(const byte[], u32bit); void handle_bad_char(byte); -- cgit v1.2.3