oauth.h | oauth.h | |||
---|---|---|---|---|
/** | /** | |||
* @brief OAuth.net implementation in POSIX-C. | * @brief OAuth.net implementation in POSIX-C. | |||
* @file oauth.h | * @file oauth.h | |||
* @author Robin Gareus <robin@gareus.org> | * @author Robin Gareus <robin@gareus.org> | |||
* | * | |||
* Copyright 2007-2012 Robin Gareus <robin@gareus.org> | * Copyright 2007-2014 Robin Gareus <robin@gareus.org> | |||
* | * | |||
* Permission is hereby granted, free of charge, to any person obtaining a copy | * Permission is hereby granted, free of charge, to any person obtaining a copy | |||
* of this software and associated documentation files (the "Software"), to deal | * of this software and associated documentation files (the "Software"), to deal | |||
* in the Software without restriction, including without limitation the ri ghts | * in the Software without restriction, including without limitation the ri ghts | |||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sel l | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sel l | |||
* copies of the Software, and to permit persons to whom the Software is | * copies of the Software, and to permit persons to whom the Software is | |||
* furnished to do so, subject to the following conditions: | * furnished to do so, subject to the following conditions: | |||
* | * | |||
* The above copyright notice and this permission notice shall be included in | * The above copyright notice and this permission notice shall be included in | |||
* all copies or substantial portions of the Software. | * all copies or substantial portions of the Software. | |||
skipping to change at line 32 | skipping to change at line 32 | |||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS I N | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS I N | |||
* THE SOFTWARE. | * THE SOFTWARE. | |||
* | * | |||
*/ | */ | |||
#ifndef _OAUTH_H | #ifndef _OAUTH_H | |||
#define _OAUTH_H 1 | #define _OAUTH_H 1 | |||
#ifndef DOXYGEN_IGNORE | #ifndef DOXYGEN_IGNORE | |||
// liboauth version | // liboauth version | |||
#define LIBOAUTH_VERSION "1.0.1" | #define LIBOAUTH_VERSION "1.0.2" | |||
#define LIBOAUTH_VERSION_MAJOR 1 | #define LIBOAUTH_VERSION_MAJOR 1 | |||
#define LIBOAUTH_VERSION_MINOR 0 | #define LIBOAUTH_VERSION_MINOR 0 | |||
#define LIBOAUTH_VERSION_MICRO 1 | #define LIBOAUTH_VERSION_MICRO 2 | |||
//interface revision number | //interface revision number | |||
//http://www.gnu.org/software/libtool/manual/html_node/Updating-version-inf o.html | //http://www.gnu.org/software/libtool/manual/html_node/Updating-version-inf o.html | |||
#define LIBOAUTH_CUR 8 | #define LIBOAUTH_CUR 8 | |||
#define LIBOAUTH_REV 5 | #define LIBOAUTH_REV 6 | |||
#define LIBOAUTH_AGE 8 | #define LIBOAUTH_AGE 8 | |||
#ifdef __GNUC__ | #ifdef __GNUC__ | |||
# define OA_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) | # define OA_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) | |||
#else | #else | |||
# define OA_GCC_VERSION_AT_LEAST(x,y) 0 | # define OA_GCC_VERSION_AT_LEAST(x,y) 0 | |||
#endif | #endif | |||
#ifndef attribute_deprecated | #ifndef attribute_deprecated | |||
#if OA_GCC_VERSION_AT_LEAST(3,1) | #if OA_GCC_VERSION_AT_LEAST(3,1) | |||
skipping to change at line 128 | skipping to change at line 128 | |||
* | * | |||
* the returned string needs to be freed by the caller | * the returned string needs to be freed by the caller | |||
* | * | |||
* @param m message to be signed | * @param m message to be signed | |||
* @param k key used for signing | * @param k key used for signing | |||
* @return signature string. | * @return signature string. | |||
*/ | */ | |||
char *oauth_sign_hmac_sha1 (const char *m, const char *k); | char *oauth_sign_hmac_sha1 (const char *m, const char *k); | |||
/** | /** | |||
* same as \ref oauth_sign_hmac_sha1 but allows | * same as \ref oauth_sign_hmac_sha1 but allows one | |||
* to specify length of message and key (in case they contain null chars). | * to specify length of message and key (in case they contain null chars). | |||
* | * | |||
* @param m message to be signed | * @param m message to be signed | |||
* @param ml length of message | * @param ml length of message | |||
* @param k key used for signing | * @param k key used for signing | |||
* @param kl length of key | * @param kl length of key | |||
* @return signature string. | * @return signature string. | |||
*/ | */ | |||
char *oauth_sign_hmac_sha1_raw (const char *m, const size_t ml, const char *k, const size_t kl); | char *oauth_sign_hmac_sha1_raw (const char *m, const size_t ml, const char *k, const size_t kl); | |||
skipping to change at line 182 | skipping to change at line 182 | |||
/** | /** | |||
* url-escape strings and concatenate with '&' separator. | * url-escape strings and concatenate with '&' separator. | |||
* The number of strings to be concatenated must be | * The number of strings to be concatenated must be | |||
* given as first argument. | * given as first argument. | |||
* all arguments thereafter must be of type (char *) | * all arguments thereafter must be of type (char *) | |||
* | * | |||
* @param len the number of arguments to follow this parameter | * @param len the number of arguments to follow this parameter | |||
* | * | |||
* @return pointer to memory holding the concatenated | * @return pointer to memory holding the concatenated | |||
* strings - needs to be free(d) by the caller. or NULL | * strings - needs to be xfree(d) by the caller. or NULL | |||
* in case we ran out of memory. | * in case we ran out of memory. | |||
*/ | */ | |||
char *oauth_catenc(int len, ...); | char *oauth_catenc(int len, ...); | |||
/** | /** | |||
* splits the given url into a parameter array. | * splits the given url into a parameter array. | |||
* (see \ref oauth_serialize_url and \ref oauth_serialize_url_parameters fo r the reverse) | * (see \ref oauth_serialize_url and \ref oauth_serialize_url_parameters fo r the reverse) | |||
* (see \ref oauth_split_post_paramters for a more generic version) | * (see \ref oauth_split_post_paramters for a more generic version) | |||
* | * | |||
* @param url the url or query-string to parse; may be NULL | * @param url the url or query-string to parse; may be NULL | |||
skipping to change at line 297 | skipping to change at line 297 | |||
* @param argcp pointer to array length int | * @param argcp pointer to array length int | |||
* @param argvp pointer to array values | * @param argvp pointer to array values | |||
* @param addparam parameter to add (eg. "foo=bar") | * @param addparam parameter to add (eg. "foo=bar") | |||
*/ | */ | |||
void oauth_add_param_to_array(int *argcp, char ***argvp, const char *addpar am); | void oauth_add_param_to_array(int *argcp, char ***argvp, const char *addpar am); | |||
/** | /** | |||
* free array args | * free array args | |||
* | * | |||
* @param argcp pointer to array length int | * @param argcp pointer to array length int | |||
* @param argvp pointer to array values to be free()d | * @param argvp pointer to array values to be xfree()d | |||
*/ | */ | |||
void oauth_free_array(int *argcp, char ***argvp); | void oauth_free_array(int *argcp, char ***argvp); | |||
/** | /** | |||
* compare two strings in constant-time (as to not let an | * compare two strings in constant-time (as to not let an | |||
* attacker guess how many leading chars are correct: | * attacker guess how many leading chars are correct: | |||
* http://rdist.root.org/2010/01/07/timing-independent-array-comparison/ ) | * http://rdist.root.org/2010/01/07/timing-independent-array-comparison/ ) | |||
* | * | |||
* @param a string to compare | * @param a string to compare | |||
* @param b string to compare | * @param b string to compare | |||
skipping to change at line 395 | skipping to change at line 395 | |||
const char *t_key, //< token key - posted plain text in URL | const char *t_key, //< token key - posted plain text in URL | |||
const char *t_secret //< token secret - used as 2st part of secret-key | const char *t_secret //< token secret - used as 2st part of secret-key | |||
) attribute_deprecated; | ) attribute_deprecated; | |||
/** | /** | |||
* the back-end behind by /ref oauth_sign_array2. | * the back-end behind by /ref oauth_sign_array2. | |||
* however it does not serialize the signed URL again. | * however it does not serialize the signed URL again. | |||
* The user needs to call /ref oauth_serialize_url (oA) | * The user needs to call /ref oauth_serialize_url (oA) | |||
* and /ref oauth_free_array to do so. | * and /ref oauth_free_array to do so. | |||
* | * | |||
* This allows to split parts of the URL to be used for | * This allows one to split parts of the URL to be used for | |||
* OAuth HTTP Authorization header: | * OAuth HTTP Authorization header: | |||
* see http://oauth.net/core/1.0a/#consumer_req_param | * see http://oauth.net/core/1.0a/#consumer_req_param | |||
* the oauthtest2 example code does so. | * the oauthtest2 example code does so. | |||
* | * | |||
* | * | |||
* @param argcp pointer to array length int | * @param argcp pointer to array length int | |||
* @param argvp pointer to array values | * @param argvp pointer to array values | |||
* (argv[0]="http://example.org:80/" argv[1]="first=QueryParamater" .. | * (argv[0]="http://example.org:80/" argv[1]="first=QueryParamater" .. | |||
* the array is modified: fi. oauth_ parameters are added) | * the array is modified: fi. oauth_ parameters are added) | |||
* These arrays can be generated with /ref oauth_split_url_parameters | * These arrays can be generated with /ref oauth_split_url_parameters | |||
skipping to change at line 576 | skipping to change at line 576 | |||
* @deprecated use libcurl - http://curl.haxx.se/libcurl/c/ | * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/ | |||
*/ | */ | |||
char *oauth_http_get (const char *u, const char *q) attribute_deprecated; | char *oauth_http_get (const char *u, const char *q) attribute_deprecated; | |||
/** | /** | |||
* do a HTTP GET request, wait for it to finish | * do a HTTP GET request, wait for it to finish | |||
* and return the content of the reply. | * and return the content of the reply. | |||
* | * | |||
* (requires libcurl) | * (requires libcurl) | |||
* | * | |||
* This is equivalent to /ref oauth_http_get but allows to | * This is equivalent to /ref oauth_http_get but allows one | |||
* specifiy a custom HTTP header and has | * to specifiy a custom HTTP header andhas no support for commandline-curl. | |||
* has no support for commandline-curl. | ||||
* | * | |||
* If liboauth is compiled <b>without</b> libcurl this function | * If liboauth is compiled <b>without</b> libcurl this function | |||
* always returns NULL. | * always returns NULL. | |||
* | * | |||
* @param u base url to get | * @param u base url to get | |||
* @param q query string to send along with the HTTP request or NULL. | * @param q query string to send along with the HTTP request or NULL. | |||
* @param customheader specify custom HTTP header (or NULL for none) | * @param customheader specify custom HTTP header (or NULL for none) | |||
* Multiple header elements can be passed separating them with "\r\n" | * Multiple header elements can be passed separating them with "\r\n" | |||
* @return In case of an error NULL is returned; otherwise a pointer to th e | * @return In case of an error NULL is returned; otherwise a pointer to th e | |||
* replied content from HTTP server. latter needs to be freed by caller. | * replied content from HTTP server. latter needs to be freed by caller. | |||
End of changes. 9 change blocks. | ||||
11 lines changed or deleted | 10 lines changed or added | |||