Mon, 12 Aug 2013 15:34:40 +0200
base64 encoded passwords in config.xml
dav/config.c | file | annotate | diff | comparison | revisions | |
dav/utils.c | file | annotate | diff | comparison | revisions | |
dav/utils.h | file | annotate | diff | comparison | revisions |
--- a/dav/config.c Mon Aug 12 14:55:31 2013 +0200 +++ b/dav/config.c Mon Aug 12 15:34:40 2013 +0200 @@ -90,8 +90,7 @@ } else if(xstreq(node->name, "user")) { repo->user = strdup(value); } else if(xstreq(node->name, "password")) { - // TODO: use base64 - repo->password = strdup(value); + repo->password = util_base64decode(value); } else if(xstreq(node->name, "default-key")) { repo->default_key = strdup(value); } else if(xstreq(node->name, "encrypt")) {
--- a/dav/utils.c Mon Aug 12 14:55:31 2013 +0200 +++ b/dav/utils.c Mon Aug 12 15:34:40 2013 +0200 @@ -34,6 +34,12 @@ #include <libxml/tree.h> #include <curl/curl.h> +#include <openssl/sha.h> +#include <openssl/hmac.h> +#include <openssl/evp.h> +#include <openssl/bio.h> +#include <openssl/buffer.h> + #include "utils.h" @@ -150,3 +156,19 @@ return NULL; } + + +char* util_base64decode(char* in) { + size_t len = strlen(in); + char *out = calloc(1, len); + + BIO* b = BIO_new_mem_buf(in, len); + BIO *d = BIO_new(BIO_f_base64()); + BIO_set_flags(d, BIO_FLAGS_BASE64_NO_NL); + b = BIO_push(d, b); + + BIO_read(b, out, len); + BIO_free_all(b); + + return out; +}