diff options
Diffstat (limited to 'src/lib/codec/base64/base64.cpp')
-rw-r--r-- | src/lib/codec/base64/base64.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/lib/codec/base64/base64.cpp b/src/lib/codec/base64/base64.cpp index bd4d36cfa..c854e52b0 100644 --- a/src/lib/codec/base64/base64.cpp +++ b/src/lib/codec/base64/base64.cpp @@ -14,7 +14,7 @@ namespace Botan { namespace { -static const byte BIN_TO_BASE64[64] = { +static const uint8_t BIN_TO_BASE64[64] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', @@ -22,7 +22,7 @@ static const byte BIN_TO_BASE64[64] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; -void do_base64_encode(char out[4], const byte in[3]) +void do_base64_encode(char out[4], const uint8_t in[3]) { out[0] = BIN_TO_BASE64[((in[0] & 0xFC) >> 2)]; out[1] = BIN_TO_BASE64[((in[0] & 0x03) << 4) | (in[1] >> 4)]; @@ -33,7 +33,7 @@ void do_base64_encode(char out[4], const byte in[3]) } size_t base64_encode(char out[], - const byte in[], + const uint8_t in[], size_t input_length, size_t& input_consumed, bool final_inputs) @@ -54,7 +54,7 @@ size_t base64_encode(char out[], if(final_inputs && input_remaining) { - byte remainder[3] = { 0 }; + uint8_t remainder[3] = { 0 }; for(size_t i = 0; i != input_remaining; ++i) remainder[i] = in[input_consumed + i]; @@ -75,7 +75,7 @@ size_t base64_encode(char out[], return output_produced; } -std::string base64_encode(const byte input[], +std::string base64_encode(const uint8_t input[], size_t input_length) { const size_t output_length = (round_up(input_length, 3) / 3) * 4; @@ -97,7 +97,7 @@ std::string base64_encode(const byte input[], return output; } -size_t base64_decode(byte output[], +size_t base64_decode(uint8_t output[], const char input[], size_t input_length, size_t& input_consumed, @@ -108,7 +108,7 @@ size_t base64_decode(byte output[], * Base64 Decoder Lookup Table * Warning: assumes ASCII encodings */ - static const byte BASE64_TO_BIN[256] = { + static const uint8_t BASE64_TO_BIN[256] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x80, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, @@ -136,8 +136,8 @@ size_t base64_decode(byte output[], 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - byte* out_ptr = output; - byte decode_buf[4]; + uint8_t* out_ptr = output; + uint8_t decode_buf[4]; size_t decode_buf_pos = 0; size_t final_truncate = 0; @@ -145,7 +145,7 @@ size_t base64_decode(byte output[], for(size_t i = 0; i != input_length; ++i) { - const byte bin = BASE64_TO_BIN[static_cast<byte>(input[i])]; + const uint8_t bin = BASE64_TO_BIN[static_cast<uint8_t>(input[i])]; if(bin <= 0x3F) { @@ -194,7 +194,7 @@ size_t base64_decode(byte output[], } while(input_consumed < input_length && - BASE64_TO_BIN[static_cast<byte>(input[input_consumed])] == 0x80) + BASE64_TO_BIN[static_cast<uint8_t>(input[input_consumed])] == 0x80) { ++input_consumed; } @@ -204,7 +204,7 @@ size_t base64_decode(byte output[], return written; } -size_t base64_decode(byte output[], +size_t base64_decode(uint8_t output[], const char input[], size_t input_length, bool ignore_ws) @@ -219,19 +219,19 @@ size_t base64_decode(byte output[], return written; } -size_t base64_decode(byte output[], +size_t base64_decode(uint8_t output[], const std::string& input, bool ignore_ws) { return base64_decode(output, input.data(), input.length(), ignore_ws); } -secure_vector<byte> base64_decode(const char input[], +secure_vector<uint8_t> base64_decode(const char input[], size_t input_length, bool ignore_ws) { const size_t output_length = (round_up(input_length, 4) * 3) / 4; - secure_vector<byte> bin(output_length); + secure_vector<uint8_t> bin(output_length); size_t written = base64_decode(bin.data(), input, @@ -242,7 +242,7 @@ secure_vector<byte> base64_decode(const char input[], return bin; } -secure_vector<byte> base64_decode(const std::string& input, +secure_vector<uint8_t> base64_decode(const std::string& input, bool ignore_ws) { return base64_decode(input.data(), input.size(), ignore_ws); |