Fix wrong length returned by base64_to_bin(), rewrite the function
- base64_to_bin() was handling the '=' padding char as data,
making the output longer when padding was used.
- If you had no padding, this was ok
- Or if you were knowing the length of the output to cut it at the right
length this was ok too
- The output buffer had to be a little longer too
- The function base64_init() has been removed and 'base64_map' is
initialized with a static table
- The function has been rewritten
- ignore spaces in the input (space, tab, newline), can be a multi-line input
- stop when a '\0', a '=' (padding) or srclen depending what is hit first
- return 0 when the output string is too short or invalid char are fount
in the output
- dest_size don't need to be bigger, the exact length is ok
- the output string is not ended with '\0', has it is supposed to be binary data
- The other usage of base64_to_bin() in the code have been fixed when needed
- Add plenty of test
==== Starting base64_test ... ====
OK test bin_to_base64
OK test bin_to_base64 content
OK test base64_to_bin
OK test base64_to_bin content
OK test base64 encode decode for multiple lengths
OK test base64 decode base64 with multiple spaces
OK test base64 buffer too small 1
OK test base64 buffer too small 2
OK test base64 padding YQ==
OK test base64 padding YQ=
OK test base64 padding YQ
OK test base64 padding YQ==
OK test base64 padding YQ=
OK test base64 padding YQ
OK test base64 truncated padding YQ== 3
OK test base64 truncated padding YQ== 2
OK test base64 invalid char 1
OK test base64 invalid char 2
OK test base64 invalid char 3
OK test base64 invalid char after the padding
OK Checking bin_to_base64 encoded length
OK Checking bin_to_base64 encoded data
OK Checking base64_to_bin decoded length
OK Checking base64_to_bin decoded data
OK Checking base64_to_bin decoded length - encoded
OK Checking base64_to_bin decoded data - encoded
OK Checking to_base64 encode length
OK Checking to_base64 encoded data
OK Checking from_base64 decoded data
OK Checking from_base64 decoded length
OK Checking from_base64 decoded data - encoded
OK Checking from_base64 decoded length - encoded