X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuclient.git;a=blobdiff_plain;f=uclient-utils.h;h=3c52eff2ed61e27886a74ad33e8115a36132f0e1;hp=a7eaf1cabac0a9ce2c5c2c6de2c9bc315accfef4;hb=2b80c2689068258eab5e94f92a6d1e7b7550094b;hpb=c280d54e1bc79de4424fabc3fad011cc15587b81 diff --git a/uclient-utils.h b/uclient-utils.h index a7eaf1c..3c52eff 100644 --- a/uclient-utils.h +++ b/uclient-utils.h @@ -1,16 +1,47 @@ +/* + * uclient - ustream based protocol client library + * + * Copyright (C) 2014 Felix Fietkau + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ #ifndef __UCLIENT_UTILS_H #define __UCLIENT_UTILS_H #include +struct http_digest_data { + const char *uri; + const char *method; + + const char *auth_hash; /* H(A1) */ + const char *qop; + const char *nc; + const char *nonce; + const char *cnonce; +}; + static inline int base64_len(int len) { return ((len + 2) / 3) * 4; } void base64_encode(const void *inbuf, unsigned int len, void *out); +void bin_to_hex(char *dest, const void *buf, int len); int uclient_urldecode(const char *in, char *out, bool decode_plus); +void http_digest_calculate_auth_hash(char *dest, const char *user, const char *realm, const char *password); +void http_digest_calculate_response(char *dest, const struct http_digest_data *data); #endif