1 .TH "oauth.h" 3 "Thu Apr 17 2014" "Version 1.0.3" "OAuth library functions" \" -*- nroff -*-
7 OAuth\&.net implementation in POSIX-C\&.
16 .RI "enum \fBOAuthMethod\fP { \fBOA_HMAC\fP =0, \fBOA_RSA\fP, \fBOA_PLAINTEXT\fP }"
18 .RI "\fIsignature method to used for signing the request\&. \fP"
24 .RI "char * \fBoauth_encode_base64\fP (int size, const unsigned char *src)"
26 .RI "\fIBase64 encode and return size data in 'src'\&. \fP"
28 .RI "int \fBoauth_decode_base64\fP (unsigned char *dest, const char *src)"
30 .RI "\fIDecode the base64 encoded string 'src' into the memory pointed to by 'dest'\&. \fP"
32 .RI "char * \fBoauth_url_escape\fP (const char *string)"
34 .RI "\fIEscape 'string' according to RFC3986 and http://oauth.net/core/1.0/#encoding_parameters\&. \fP"
36 .RI "char * \fBoauth_url_unescape\fP (const char *string, size_t *olen)"
38 .RI "\fIParse RFC3986 encoded 'string' back to unescaped version\&. \fP"
40 .RI "char * \fBoauth_sign_hmac_sha1\fP (const char *m, const char *k)"
42 .RI "\fIreturns base64 encoded HMAC-SHA1 signature for given message and key\&. \fP"
44 .RI "char * \fBoauth_sign_hmac_sha1_raw\fP (const char *m, const size_t ml, const char *k, const size_t kl)"
46 .RI "\fIsame as \fBoauth_sign_hmac_sha1\fP but allows one to specify length of message and key (in case they contain null chars)\&. \fP"
48 .RI "char * \fBoauth_sign_plaintext\fP (const char *m, const char *k)"
50 .RI "\fIreturns plaintext signature for the given key\&. \fP"
52 .RI "char * \fBoauth_sign_rsa_sha1\fP (const char *m, const char *k)"
54 .RI "\fIreturns RSA-SHA1 signature for given data\&. \fP"
56 .RI "int \fBoauth_verify_rsa_sha1\fP (const char *m, const char *c, const char *s)"
58 .RI "\fIverify RSA-SHA1 signature\&. \fP"
60 .RI "char * \fBoauth_catenc\fP (int len,\&.\&.\&.)"
62 .RI "\fIurl-escape strings and concatenate with '&' separator\&. \fP"
64 .RI "int \fBoauth_split_url_parameters\fP (const char *url, char ***argv)"
66 .RI "\fIsplits the given url into a parameter array\&. \fP"
68 .RI "int \fBoauth_split_post_paramters\fP (const char *url, char ***argv, short qesc)"
70 .RI "\fIsplits the given url into a parameter array\&. \fP"
72 .RI "char * \fBoauth_serialize_url\fP (int argc, int start, char **argv)"
74 .RI "\fIbuild a url query string from an array\&. \fP"
76 .RI "char * \fBoauth_serialize_url_sep\fP (int argc, int start, char **argv, char *sep, int mod)"
78 .RI "\fIencode query parameters from an array\&. \fP"
80 .RI "char * \fBoauth_serialize_url_parameters\fP (int argc, char **argv)"
82 .RI "\fIbuild a query parameter string from an array\&. \fP"
84 .RI "char * \fBoauth_gen_nonce\fP ()"
86 .RI "\fIgenerate a random string between 15 and 32 chars length and return a pointer to it\&. \fP"
88 .RI "int \fBoauth_cmpstringp\fP (const void *p1, const void *p2)"
90 .RI "\fIstring compare function for oauth parameters\&. \fP"
92 .RI "int \fBoauth_param_exists\fP (char **argv, int argc, char *key)"
94 .RI "\fIsearch array for parameter key\&. \fP"
96 .RI "void \fBoauth_add_param_to_array\fP (int *argcp, char ***argvp, const char *addparam)"
98 .RI "\fIadd query parameter to array \fP"
100 .RI "void \fBoauth_free_array\fP (int *argcp, char ***argvp)"
102 .RI "\fIfree array args \fP"
104 .RI "int \fBoauth_time_independent_equals_n\fP (const char *a, const char *b, size_t len_a, size_t len_b)"
106 .RI "\fIcompare two strings in constant-time (as to not let an attacker guess how many leading chars are correct: http://rdist.root.org/2010/01/07/timing-independent-array-comparison/ ) \fP"
108 .RI "int \fBoauth_time_indepenent_equals_n\fP (const char *a, const char *b, size_t len_a, size_t len_b) attribute_deprecated"
111 .RI "int \fBoauth_time_independent_equals\fP (const char *a, const char *b)"
113 .RI "\fIcompare two strings in constant-time\&. \fP"
115 .RI "int \fBoauth_time_indepenent_equals\fP (const char *a, const char *b) attribute_deprecated"
118 .RI "char * \fBoauth_sign_url2\fP (const char *url, char **postargs, \fBOAuthMethod\fP method, const char *http_method, const char *c_key, const char *c_secret, const char *t_key, const char *t_secret)"
120 .RI "\fIcalculate OAuth-signature for a given HTTP request URL, parameters and oauth-tokens\&. \fP"
122 .RI "char * \fBoauth_sign_url\fP (const char *url, char **postargs, \fBOAuthMethod\fP method, const char *c_key, const char *c_secret, const char *t_key, const char *t_secret) attribute_deprecated"
125 .RI "void \fBoauth_sign_array2_process\fP (int *argcp, char ***argvp, char **postargs, \fBOAuthMethod\fP method, const char *http_method, const char *c_key, const char *c_secret, const char *t_key, const char *t_secret)"
127 .RI "\fIthe back-end behind by /ref oauth_sign_array2\&. \fP"
129 .RI "char * \fBoauth_sign_array2\fP (int *argcp, char ***argvp, char **postargs, \fBOAuthMethod\fP method, const char *http_method, const char *c_key, const char *c_secret, const char *t_key, const char *t_secret)"
131 .RI "\fIsame as /ref oauth_sign_url with the url already split into parameter array \fP"
133 .RI "char * \fBoauth_sign_array\fP (int *argcp, char ***argvp, char **postargs, \fBOAuthMethod\fP method, const char *c_key, const char *c_secret, const char *t_key, const char *t_secret) attribute_deprecated"
136 .RI "char * \fBoauth_body_hash_file\fP (char *filename)"
138 .RI "\fIcalculate body hash (sha1sum) of given file and return a oauth_body_hash=xxxx parameter to be added to the request\&. \fP"
140 .RI "char * \fBoauth_body_hash_data\fP (size_t length, const char *data)"
142 .RI "\fIcalculate body hash (sha1sum) of given data and return a oauth_body_hash=xxxx parameter to be added to the request\&. \fP"
144 .RI "char * \fBoauth_body_hash_encode\fP (size_t len, unsigned char *digest)"
146 .RI "\fIbase64 encode digest, free it and return a URL parameter with the oauth_body_hash\&. \fP"
148 .RI "char * \fBoauth_sign_xmpp\fP (const char *xml, \fBOAuthMethod\fP method, const char *c_secret, const char *t_secret)"
150 .RI "\fIxep-0235 - TODO \fP"
152 .RI "char * \fBoauth_http_get\fP (const char *u, const char *q) attribute_deprecated"
154 .RI "\fIdo a HTTP GET request, wait for it to finish and return the content of the reply\&. \fP"
156 .RI "char * \fBoauth_http_get2\fP (const char *u, const char *q, const char *customheader) attribute_deprecated"
158 .RI "\fIdo a HTTP GET request, wait for it to finish and return the content of the reply\&. \fP"
160 .RI "char * \fBoauth_http_post\fP (const char *u, const char *p) attribute_deprecated"
162 .RI "\fIdo a HTTP POST request, wait for it to finish and return the content of the reply\&. \fP"
164 .RI "char * \fBoauth_http_post2\fP (const char *u, const char *p, const char *customheader) attribute_deprecated"
166 .RI "\fIdo a HTTP POST request, wait for it to finish and return the content of the reply\&. \fP"
168 .RI "char * \fBoauth_post_file\fP (const char *u, const char *fn, const size_t len, const char *customheader) attribute_deprecated"
170 .RI "\fIhttp post raw data from file\&. \fP"
172 .RI "char * \fBoauth_post_data\fP (const char *u, const char *data, size_t len, const char *customheader) attribute_deprecated"
174 .RI "\fIhttp post raw data the returned string needs to be freed by the caller (requires libcurl) \fP"
176 .RI "char * \fBoauth_post_data_with_callback\fP (const char *u, const char *data, size_t len, const char *customheader, void(*callback)(void *, int, size_t, size_t), void *callback_data) attribute_deprecated"
178 .RI "\fIhttp post raw data, with callback\&. \fP"
180 .RI "char * \fBoauth_send_data\fP (const char *u, const char *data, size_t len, const char *customheader, const char *httpMethod) attribute_deprecated"
182 .RI "\fIhttp send raw data\&. \fP"
184 .RI "char * \fBoauth_send_data_with_callback\fP (const char *u, const char *data, size_t len, const char *customheader, void(*callback)(void *, int, size_t, size_t), void *callback_data, const char *httpMethod) attribute_deprecated"
186 .RI "\fIhttp post raw data, with callback\&. \fP"
188 .SH "Detailed Description"
190 OAuth\&.net implementation in POSIX-C\&.
194 Robin Gareus robin@gareus.org
197 Copyright 2007-2014 Robin Gareus robin@gareus.org
199 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
201 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software\&.
203 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\&. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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 IN THE SOFTWARE\&.
205 Definition in file \fBoauth\&.h\fP\&.
206 .SH "Enumeration Type Documentation"
208 .SS "enum \fBOAuthMethod\fP"
211 signature method to used for signing the request\&.
217 use HMAC-SHA1 request signing method
222 \fB\fIOA_PLAINTEXT \fP\fP
223 use plain text signature (for testing only)
225 Definition at line 66 of file oauth\&.h\&.
226 .SH "Function Documentation"
228 .SS "void oauth_add_param_to_array (int * argcp, char *** argvp, const char * addparam)"
231 add query parameter to array \fBParameters:\fP
233 \fIargcp\fP pointer to array length int
235 \fIargvp\fP pointer to array values
237 \fIaddparam\fP parameter to add (eg\&. 'foo=bar')
241 .SS "char* oauth_body_hash_data (size_t length, const char * data)"
244 calculate body hash (sha1sum) of given data and return a oauth_body_hash=xxxx parameter to be added to the request\&. The returned string needs to be freed by the calling function\&. The returned string is not yet url-escaped and suitable to be passed as argument to \fBoauth_catenc\fP\&.
246 see http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html
250 \fIlength\fP length of the data parameter in bytes
252 \fIdata\fP to calculate the hash for
257 URL oauth_body_hash parameter string
264 \fBtests/oauthbodyhash\&.c\fP\&.
265 .SS "char* oauth_body_hash_encode (size_t len, unsigned char * digest)"
268 base64 encode digest, free it and return a URL parameter with the oauth_body_hash\&. The returned hash needs to be freed by the calling function\&. The returned string is not yet url-escaped and thus suitable to be passed to \fBoauth_catenc\fP\&.
272 \fIlen\fP length of the digest to encode
274 \fIdigest\fP hash value to encode
279 URL oauth_body_hash parameter string
283 .SS "char* oauth_body_hash_file (char * filename)"
286 calculate body hash (sha1sum) of given file and return a oauth_body_hash=xxxx parameter to be added to the request\&. The returned string needs to be freed by the calling function\&.
288 see http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html
292 \fIfilename\fP the filename to calculate the hash for
297 URL oauth_body_hash parameter string
304 \fBtests/oauthbodyhash\&.c\fP\&.
305 .SS "char* oauth_catenc (int len, \&.\&.\&.)"
308 url-escape strings and concatenate with '&' separator\&. The number of strings to be concatenated must be given as first argument\&. all arguments thereafter must be of type (char *)
312 \fIlen\fP the number of arguments to follow this parameter
317 pointer to memory holding the concatenated strings - needs to be xfree(d) by the caller\&. or NULL in case we ran out of memory\&.
321 .SS "int oauth_cmpstringp (const void * p1, const void * p2)"
324 string compare function for oauth parameters\&. used with qsort\&. needed to normalize request parameters\&. see http://oauth.net/core/1.0/#anchor14
328 \fBtests/oauthexample\&.c\fP, \fBtests/oauthtest\&.c\fP, and \fBtests/oauthtest2\&.c\fP\&.
329 .SS "int oauth_decode_base64 (unsigned char * dest, const char * src)"
332 Decode the base64 encoded string 'src' into the memory pointed to by 'dest'\&. \fBParameters:\fP
334 \fIdest\fP Pointer to memory for holding the decoded string\&. Must be large enough to receive the decoded string\&.
336 \fIsrc\fP A base64 encoded string\&.
341 the length of the decoded string if decode succeeded otherwise 0\&.
345 .SS "char* oauth_encode_base64 (int size, const unsigned char * src)"
348 Base64 encode and return size data in 'src'\&. The caller must free the returned string\&.
352 \fIsize\fP The size of the data in src
354 \fIsrc\fP The data to be base64 encode
359 encoded string otherwise NULL
363 .SS "void oauth_free_array (int * argcp, char *** argvp)"
366 free array args \fBParameters:\fP
368 \fIargcp\fP pointer to array length int
370 \fIargvp\fP pointer to array values to be xfree()d
377 \fBtests/oauthtest2\&.c\fP\&.
378 .SS "char* oauth_gen_nonce ()"
381 generate a random string between 15 and 32 chars length and return a pointer to it\&. The value needs to be freed by the caller
385 zero terminated random string\&.
389 .SS "char* oauth_http_get (const char * u, const char * q)"
392 do a HTTP GET request, wait for it to finish and return the content of the reply\&. (requires libcurl or a command-line HTTP client)
394 If compiled \fBwithout\fP libcurl this function calls a command-line executable defined in the environment variable OAUTH_HTTP_GET_CMD - it defaults to \fCcurl \-sA 'liboauth-agent/0\&.1' '%u'\fP where %u is replaced with the URL and query parameters\&.
396 bash & wget example: \fCexport OAUTH_HTTP_CMD='wget \-q \-U 'liboauth-agent/0\&.1' '%u' '\fP
398 WARNING: this is a tentative function\&. it's convenient and handy for testing or developing OAuth code\&. But don't rely on this function to become a stable part of this API\&. It does not do much error checking or handling for one thing\&.\&.
400 NOTE: \fIu\fP and \fIq\fP are just concatenated with a '?' in between, unless \fIq\fP is NULL\&. in which case only \fIu\fP will be used\&.
404 \fIu\fP base url to get
406 \fIq\fP query string to send along with the HTTP request or NULL\&.
411 In case of an error NULL is returned; otherwise a pointer to the replied content from HTTP server\&. latter needs to be freed by caller\&.
416 use libcurl - http://curl.haxx.se/libcurl/c/
423 \fBtests/oauthexample\&.c\fP, and \fBtests/oauthtest\&.c\fP\&.
424 .SS "char* oauth_http_get2 (const char * u, const char * q, const char * customheader)"
427 do a HTTP GET request, wait for it to finish and return the content of the reply\&. (requires libcurl)
429 This is equivalent to /ref oauth_http_get but allows one to specifiy a custom HTTP header andhas no support for commandline-curl\&.
431 If liboauth is compiled \fBwithout\fP libcurl this function always returns NULL\&.
435 \fIu\fP base url to get
437 \fIq\fP query string to send along with the HTTP request or NULL\&.
439 \fIcustomheader\fP specify custom HTTP header (or NULL for none) Multiple header elements can be passed separating them with '\\r\\n'
444 In case of an error NULL is returned; otherwise a pointer to the replied content from HTTP server\&. latter needs to be freed by caller\&.
449 use libcurl - http://curl.haxx.se/libcurl/c/
456 \fBtests/oauthtest2\&.c\fP\&.
457 .SS "char* oauth_http_post (const char * u, const char * p)"
460 do a HTTP POST request, wait for it to finish and return the content of the reply\&. (requires libcurl or a command-line HTTP client)
462 If compiled \fBwithout\fP libcurl this function calls a command-line executable defined in the environment variable OAUTH_HTTP_CMD - it defaults to \fCcurl \-sA 'liboauth-agent/0\&.1' \-d '%p' '%u'\fP where %p is replaced with the postargs and %u is replaced with the URL\&.
464 bash & wget example: \fCexport OAUTH_HTTP_CMD='wget \-q \-U 'liboauth-agent/0\&.1' –post-data='%p' '%u' '\fP
466 NOTE: This function uses the curl's default HTTP-POST Content-Type: application/x-www-form-urlencoded which is the only option allowed by oauth core 1\&.0 spec\&. Experimental code can use the Environment variable to transmit custom HTTP headers or parameters\&.
468 WARNING: this is a tentative function\&. it's convenient and handy for testing or developing OAuth code\&. But don't rely on this function to become a stable part of this API\&. It does not do much error checking for one thing\&.\&.
474 \fIp\fP postargs to send along with the HTTP request\&.
479 replied content from HTTP server\&. needs to be freed by caller\&.
484 use libcurl - http://curl.haxx.se/libcurl/c/
491 \fBtests/oauthexample\&.c\fP, and \fBtests/oauthtest\&.c\fP\&.
492 .SS "char* oauth_http_post2 (const char * u, const char * p, const char * customheader)"
495 do a HTTP POST request, wait for it to finish and return the content of the reply\&. (requires libcurl)
497 It's equivalent to /ref oauth_http_post, but offers the possibility to specify a custom HTTP header and has no support for commandline-curl\&.
499 If liboauth is compiled \fBwithout\fP libcurl this function always returns NULL\&.
505 \fIp\fP postargs to send along with the HTTP request\&.
507 \fIcustomheader\fP specify custom HTTP header (or NULL for none) Multiple header elements can be passed separating them with '\\r\\n'
512 replied content from HTTP server\&. needs to be freed by caller\&.
517 use libcurl - http://curl.haxx.se/libcurl/c/
521 .SS "int oauth_param_exists (char ** argv, int argc, char * key)"
524 search array for parameter key\&. \fBParameters:\fP
526 \fIargv\fP length of array to search
528 \fIargc\fP parameter array to search
530 \fIkey\fP key of parameter to check\&.
535 FALSE (0) if array does not contain a parameter with given key, TRUE (1) otherwise\&.
539 .SS "char* oauth_post_data (const char * u, const char * data, size_t len, const char * customheader)"
542 http post raw data the returned string needs to be freed by the caller (requires libcurl) see dislaimer: /ref oauth_http_post
546 \fIu\fP url to retrieve
548 \fIdata\fP data to post
550 \fIlen\fP length of the data in bytes\&.
552 \fIcustomheader\fP specify custom HTTP header (or NULL for default) Multiple header elements can be passed separating them with '\\r\\n'
557 returned HTTP reply or NULL on error
562 use libcurl - http://curl.haxx.se/libcurl/c/
569 \fBtests/oauthbodyhash\&.c\fP\&.
570 .SS "char* oauth_post_data_with_callback (const char * u, const char * data, size_t len, const char * customheader, void(*)(void *, int, size_t, size_t) callback, void * callback_data)"
573 http post raw data, with callback\&. the returned string needs to be freed by the caller (requires libcurl)
575 Invokes the callback - in no particular order - when HTTP-request status updates occur\&. The callback is called with: void * callback_data: supplied on function call\&. int type: 0=data received, 1=data sent\&. size_t size: amount of data received or amount of data sent so far size_t totalsize: original amount of data to send, or amount of data received
579 \fIu\fP url to retrieve
581 \fIdata\fP data to post along
583 \fIlen\fP length of the file in bytes\&. set to '0' for autodetection
585 \fIcustomheader\fP specify custom HTTP header (or NULL for default) Multiple header elements can be passed separating them with '\\r\\n'
587 \fIcallback\fP specify the callback function
589 \fIcallback_data\fP specify data to pass to the callback function
594 returned HTTP reply or NULL on error
599 use libcurl - http://curl.haxx.se/libcurl/c/
603 .SS "char* oauth_post_file (const char * u, const char * fn, const size_t len, const char * customheader)"
606 http post raw data from file\&. the returned string needs to be freed by the caller (requires libcurl)
608 see dislaimer: /ref oauth_http_post
612 \fIu\fP url to retrieve
614 \fIfn\fP filename of the file to post along
616 \fIlen\fP length of the file in bytes\&. set to '0' for autodetection
618 \fIcustomheader\fP specify custom HTTP header (or NULL for default)\&. Multiple header elements can be passed separating them with '\\r\\n'
623 returned HTTP reply or NULL on error
628 use libcurl - http://curl.haxx.se/libcurl/c/
632 .SS "char* oauth_send_data (const char * u, const char * data, size_t len, const char * customheader, const char * httpMethod)"
635 http send raw data\&. similar to /ref oauth_http_post but provides for specifying the HTTP request method\&.
637 the returned string needs to be freed by the caller (requires libcurl)
639 see dislaimer: /ref oauth_http_post
643 \fIu\fP url to retrieve
645 \fIdata\fP data to post
647 \fIlen\fP length of the data in bytes\&.
649 \fIcustomheader\fP specify custom HTTP header (or NULL for default) Multiple header elements can be passed separating them with '\\r\\n'
651 \fIhttpMethod\fP specify http verb ('GET'/'POST'/'PUT'/'DELETE') to be used\&. if httpMethod is NULL, a POST is executed\&.
656 returned HTTP reply or NULL on error
661 use libcurl - http://curl.haxx.se/libcurl/c/
665 .SS "char* oauth_send_data_with_callback (const char * u, const char * data, size_t len, const char * customheader, void(*)(void *, int, size_t, size_t) callback, void * callback_data, const char * httpMethod)"
668 http post raw data, with callback\&. the returned string needs to be freed by the caller (requires libcurl)
670 Invokes the callback - in no particular order - when HTTP-request status updates occur\&. The callback is called with: void * callback_data: supplied on function call\&. int type: 0=data received, 1=data sent\&. size_t size: amount of data received or amount of data sent so far size_t totalsize: original amount of data to send, or amount of data received
674 \fIu\fP url to retrieve
676 \fIdata\fP data to post along
678 \fIlen\fP length of the file in bytes\&. set to '0' for autodetection
680 \fIcustomheader\fP specify custom HTTP header (or NULL for default) Multiple header elements can be passed separating them with '\\r\\n'
682 \fIcallback\fP specify the callback function
684 \fIcallback_data\fP specify data to pass to the callback function
686 \fIhttpMethod\fP specify http verb ('GET'/'POST'/'PUT'/'DELETE') to be used\&.
691 returned HTTP reply or NULL on error
696 use libcurl - http://curl.haxx.se/libcurl/c/
700 .SS "char* oauth_serialize_url (int argc, int start, char ** argv)"
703 build a url query string from an array\&. \fBParameters:\fP
705 \fIargc\fP the total number of elements in the array
707 \fIstart\fP element in the array at which to start concatenating\&.
709 \fIargv\fP parameter-array to concatenate\&.
714 url string needs to be freed by the caller\&.
718 .SS "char* oauth_serialize_url_parameters (int argc, char ** argv)"
721 build a query parameter string from an array\&. This function is a shortcut for \fBoauth_serialize_url\fP (argc, 1, argv)\&. It strips the leading host/path, which is usually the first element when using oauth_split_url_parameters on an URL\&.
725 \fIargc\fP the total number of elements in the array
727 \fIargv\fP parameter-array to concatenate\&.
732 url string needs to be freed by the caller\&.
736 .SS "char* oauth_serialize_url_sep (int argc, int start, char ** argv, char * sep, int mod)"
739 encode query parameters from an array\&. \fBParameters:\fP
741 \fIargc\fP the total number of elements in the array
743 \fIstart\fP element in the array at which to start concatenating\&.
745 \fIargv\fP parameter-array to concatenate\&.
747 \fIsep\fP separator for parameters (usually '&')
749 \fImod\fP - bitwise modifiers: 1: skip all values that start with 'oauth_' 2: skip all values that don't start with 'oauth_' 4: double quotation marks are added around values (use with sep ', ' for HTTP Authorization header)\&.
754 url string needs to be freed by the caller\&.
761 \fBtests/oauthtest2\&.c\fP\&.
762 .SS "char* oauth_sign_array (int * argcp, char *** argvp, char ** postargs, \fBOAuthMethod\fP method, const char * c_key, const char * c_secret, const char * t_key, const char * t_secret)"
765 Use \fBoauth_sign_array2()\fP instead\&.
769 .SS "char* oauth_sign_array2 (int * argcp, char *** argvp, char ** postargs, \fBOAuthMethod\fP method, const char * http_method, const char * c_key, const char * c_secret, const char * t_key, const char * t_secret)"
772 same as /ref oauth_sign_url with the url already split into parameter array \fBParameters:\fP
774 \fIargcp\fP pointer to array length int
776 \fIargvp\fP pointer to array values (argv[0]='http://example\&.org:80/' argv[1]='first=QueryParamater' \&.\&. the array is modified: fi\&. oauth_ parameters are added) These arrays can be generated with /ref oauth_split_url_parameters or /ref oauth_split_post_paramters\&.
778 \fIpostargs\fP This parameter points to an area where the return value is stored\&. If 'postargs' is NULL, no value is stored\&.
780 \fImethod\fP specify the signature method to use\&. It is of type \fBOAuthMethod\fP and most likely \fBOA_HMAC\fP\&.
782 \fIhttp_method\fP The HTTP request method to use (ie 'GET', 'PUT',\&.\&.) If NULL is given as 'http_method' this defaults to 'GET' when 'postargs' is also NULL and when postargs is not NULL 'POST' is used\&.
784 \fIc_key\fP consumer key
786 \fIc_secret\fP consumer secret
788 \fIt_key\fP token key
790 \fIt_secret\fP token secret
795 the signed url or NULL if an error occurred\&.
799 .SS "void oauth_sign_array2_process (int * argcp, char *** argvp, char ** postargs, \fBOAuthMethod\fP method, const char * http_method, const char * c_key, const char * c_secret, const char * t_key, const char * t_secret)"
802 the back-end behind by /ref oauth_sign_array2\&. however it does not serialize the signed URL again\&. The user needs to call /ref oauth_serialize_url (oA) and /ref oauth_free_array to do so\&.
804 This allows one to split parts of the URL to be used for OAuth HTTP Authorization header: see http://oauth.net/core/1.0a/#consumer_req_param the oauthtest2 example code does so\&.
808 \fIargcp\fP pointer to array length int
810 \fIargvp\fP pointer to array values (argv[0]='http://example\&.org:80/' argv[1]='first=QueryParamater' \&.\&. the array is modified: fi\&. oauth_ parameters are added) These arrays can be generated with /ref oauth_split_url_parameters or /ref oauth_split_post_paramters\&.
812 \fIpostargs\fP This parameter points to an area where the return value is stored\&. If 'postargs' is NULL, no value is stored\&.
814 \fImethod\fP specify the signature method to use\&. It is of type \fBOAuthMethod\fP and most likely \fBOA_HMAC\fP\&.
816 \fIhttp_method\fP The HTTP request method to use (ie 'GET', 'PUT',\&.\&.) If NULL is given as 'http_method' this defaults to 'GET' when 'postargs' is also NULL and when postargs is not NULL 'POST' is used\&.
818 \fIc_key\fP consumer key
820 \fIc_secret\fP consumer secret
822 \fIt_key\fP token key
824 \fIt_secret\fP token secret
836 \fBtests/oauthtest2\&.c\fP\&.
837 .SS "char* oauth_sign_hmac_sha1 (const char * m, const char * k)"
840 returns base64 encoded HMAC-SHA1 signature for given message and key\&. both data and key need to be urlencoded\&.
842 the returned string needs to be freed by the caller
846 \fIm\fP message to be signed
848 \fIk\fP key used for signing
860 \fBtests/selftest_wiki\&.c\fP\&.
861 .SS "char* oauth_sign_hmac_sha1_raw (const char * m, const size_t ml, const char * k, const size_t kl)"
864 same as \fBoauth_sign_hmac_sha1\fP but allows one to specify length of message and key (in case they contain null chars)\&. \fBParameters:\fP
866 \fIm\fP message to be signed
868 \fIml\fP length of message
870 \fIk\fP key used for signing
872 \fIkl\fP length of key
881 .SS "char* oauth_sign_plaintext (const char * m, const char * k)"
884 returns plaintext signature for the given key\&. the returned string needs to be freed by the caller
888 \fIm\fP message to be signed
890 \fIk\fP key used for signing
899 .SS "char* oauth_sign_rsa_sha1 (const char * m, const char * k)"
902 returns RSA-SHA1 signature for given data\&. the returned signature needs to be freed by the caller\&.
906 \fIm\fP message to be signed
908 \fIk\fP private-key PKCS and Base64-encoded
913 base64 encoded signature string\&.
920 \fBtests/selftest_wiki\&.c\fP\&.
921 .SS "char* oauth_sign_url (const char * url, char ** postargs, \fBOAuthMethod\fP method, const char * c_key, const char * c_secret, const char * t_key, const char * t_secret)"
924 Use \fBoauth_sign_url2()\fP instead\&.
928 .SS "char* oauth_sign_url2 (const char * url, char ** postargs, \fBOAuthMethod\fP method, const char * http_method, const char * c_key, const char * c_secret, const char * t_key, const char * t_secret)"
931 calculate OAuth-signature for a given HTTP request URL, parameters and oauth-tokens\&. if 'postargs' is NULL a 'GET' request is signed and the signed URL is returned\&. Else this fn will modify 'postargs' to point to memory that contains the signed POST-variables and returns the base URL\&.
933 both, the return value and (if given) 'postargs' need to be freed by the caller\&.
937 \fIurl\fP The request URL to be signed\&. append all GET or POST query-parameters separated by either '?' or '&' to this parameter\&.
939 \fIpostargs\fP This parameter points to an area where the return value is stored\&. If 'postargs' is NULL, no value is stored\&.
941 \fImethod\fP specify the signature method to use\&. It is of type \fBOAuthMethod\fP and most likely \fBOA_HMAC\fP\&.
943 \fIhttp_method\fP The HTTP request method to use (ie 'GET', 'PUT',\&.\&.) If NULL is given as 'http_method' this defaults to 'GET' when 'postargs' is also NULL and when postargs is not NULL 'POST' is used\&.
945 \fIc_key\fP consumer key
947 \fIc_secret\fP consumer secret
949 \fIt_key\fP token key
951 \fIt_secret\fP token secret
956 the signed url or NULL if an error occurred\&.
963 \fBtests/oauthbodyhash\&.c\fP, \fBtests/oauthexample\&.c\fP, and \fBtests/oauthtest\&.c\fP\&.
964 .SS "char* oauth_sign_xmpp (const char * xml, \fBOAuthMethod\fP method, const char * c_secret, const char * t_secret)"
968 .SS "int oauth_split_post_paramters (const char * url, char *** argv, short qesc)"
971 splits the given url into a parameter array\&. (see \fBoauth_serialize_url\fP and \fBoauth_serialize_url_parameters\fP for the reverse)
975 \fIurl\fP the url or query-string to parse\&.
977 \fIargv\fP pointer to a (char *) array where the results are stored\&. The array is re-allocated to match the number of parameters and each parameter-string is allocated with strdup\&. - The memory needs to be freed by the caller\&.
979 \fIqesc\fP use query parameter escape (vs post-param-escape) - if set to 1 all '+' are treated as spaces ' '
984 number of parameter(s) in array\&.
988 .SS "int oauth_split_url_parameters (const char * url, char *** argv)"
991 splits the given url into a parameter array\&. (see \fBoauth_serialize_url\fP and \fBoauth_serialize_url_parameters\fP for the reverse) (see \fBoauth_split_post_paramters\fP for a more generic version)
995 \fIurl\fP the url or query-string to parse; may be NULL
997 \fIargv\fP pointer to a (char *) array where the results are stored\&. The array is re-allocated to match the number of parameters and each parameter-string is allocated with strdup\&. - The memory needs to be freed by the caller\&.
1002 number of parameter(s) in array\&.
1009 \fBtests/oauthexample\&.c\fP, \fBtests/oauthtest\&.c\fP, and \fBtests/oauthtest2\&.c\fP\&.
1010 .SS "int oauth_time_independent_equals (const char * a, const char * b)"
1013 compare two strings in constant-time\&. wrapper to \fBoauth_time_independent_equals_n\fP which calls strlen() for each argument\&.
1017 \fIa\fP string to compare
1019 \fIb\fP string to compare
1022 returns 0 (false) if strings are not equal, and 1 (true) if strings are equal\&.
1023 .SS "int oauth_time_independent_equals_n (const char * a, const char * b, size_t len_a, size_t len_b)"
1026 compare two strings in constant-time (as to not let an attacker guess how many leading chars are correct: http://rdist.root.org/2010/01/07/timing-independent-array-comparison/ ) \fBParameters:\fP
1028 \fIa\fP string to compare
1030 \fIb\fP string to compare
1032 \fIlen_a\fP length of string a
1034 \fIlen_b\fP length of string b
1037 returns 0 (false) if strings are not equal, and 1 (true) if strings are equal\&.
1038 .SS "int oauth_time_indepenent_equals (const char * a, const char * b)"
1041 Use \fBoauth_time_independent_equals()\fP instead\&.
1045 .SS "int oauth_time_indepenent_equals_n (const char * a, const char * b, size_t len_a, size_t len_b)"
1048 Use \fBoauth_time_independent_equals_n()\fP instead\&.
1052 .SS "char* oauth_url_escape (const char * string)"
1055 Escape 'string' according to RFC3986 and http://oauth.net/core/1.0/#encoding_parameters\&. \fBParameters:\fP
1057 \fIstring\fP The data to be encoded
1062 encoded string otherwise NULL The caller must free the returned string\&.
1066 .SS "char* oauth_url_unescape (const char * string, size_t * olen)"
1069 Parse RFC3986 encoded 'string' back to unescaped version\&. \fBParameters:\fP
1071 \fIstring\fP The data to be unescaped
1073 \fIolen\fP unless NULL the length of the returned string is stored there\&.
1078 decoded string or NULL The caller must free the returned string\&.
1082 .SS "int oauth_verify_rsa_sha1 (const char * m, const char * c, const char * s)"
1085 verify RSA-SHA1 signature\&. returns the output of EVP_VerifyFinal() for a given message, cert/pubkey and signature\&.
1089 \fIm\fP message to be verified
1091 \fIc\fP public-key or x509 certificate
1093 \fIs\fP base64 encoded signature
1098 1 for a correct signature, 0 for failure and \-1 if some other error occurred
1105 \fBtests/selftest_wiki\&.c\fP\&.
1108 Generated automatically by Doxygen for OAuth library functions from the source code\&.