util/crypt: Add macro for max base64encode len

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.
pull/5627/head
Shivani Bhardwaj 5 years ago committed by Victor Julien
parent 057c4b34c8
commit 02942a123a

@ -29,6 +29,12 @@
#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,

Loading…
Cancel
Save