Go to the documentation of this file.
8 #include <openssl/hmac.h>
9 #include <openssl/bio.h>
10 #include <openssl/sha.h>
11 #include <openssl/evp.h>
12 #include <openssl/buffer.h>
19 #define xroad_base64_encode(_data, _len) \
21 BIO* base64 = BIO_new(BIO_f_base64()); \
22 BIO* b_mem = BIO_new(BIO_s_mem()); \
23 BIO* all = BIO_push(base64, b_mem); \
24 BIO_set_flags(all, BIO_FLAGS_BASE64_NO_NL); \
25 BIO_write(all, (_data), (_len)); \
26 (void)BIO_flush(all); \
28 BIO_get_mem_ptr(all, &bptr); \
29 xroad_str_t ret = xroad_str_dupa(xroad_str_len(bptr->data, bptr->length)); \
34 #define xroad_base64_decode(_str) \
36 char* ret = alloca(_str.len); \
37 BIO* str64 = BIO_new_mem_buf(_str.data, _str.len); \
38 BIO* base64 = BIO_new(BIO_f_base64()); \
39 BIO* all = BIO_push(base64, str64); \
40 BIO_set_flags(all, BIO_FLAGS_BASE64_NO_NL); \
41 size_t len = BIO_read(all, ret, _str.len); \
42 BIO_free_all(base64); \
43 xroad_str_len(ret, len); \