Maximum length of a base64 encoded string can be 33% over the actual
length of the input string. The formula to best cover all the edge cases
is mathematically
(4 * (input_length + 2) / 3) + 1
Add a macro to calculate this for a given input length.
#include "suricata-common.h"
+/* Ratio of output bytes to input bytes for Base64 Encoding is 4:3, hence the
+ * required output bytes are 4 * ceil(input_len / 3) and an additional byte
+ * for storing the NULL pointer.
+ * */
+#define BASE64_BUFFER_SIZE(x) ((4 * ((x) + 2) / 3) + 1)
+
typedef enum {
SC_SHA_1_OK,
SC_SHA_1_NOK,