83ab09ae1df1393ab8139b8764bd59aac703a635
[project/uclient.git] / uclient-utils.h
1 #ifndef __UCLIENT_UTILS_H
2 #define __UCLIENT_UTILS_H
3
4 #include <stdbool.h>
5
6 struct http_digest_data {
7 const char *uri;
8 const char *method;
9
10 const char *auth_hash; /* H(A1) */
11 const char *qop;
12 const char *nc;
13 const char *nonce;
14 const char *cnonce;
15 };
16
17 static inline int base64_len(int len)
18 {
19 return ((len + 2) / 3) * 4;
20 }
21
22 void base64_encode(const void *inbuf, unsigned int len, void *out);
23 void bin_to_hex(char *dest, const void *buf, int len);
24
25 int uclient_urldecode(const char *in, char *out, bool decode_plus);
26
27 void http_digest_calculate_auth_hash(char *dest, const char *user, const char *realm, const char *password);
28 void http_digest_calculate_response(char *dest, const struct http_digest_data *data);
29
30 #endif