uploaded liboauth for tizen_3.0
[platform/upstream/liboauth.git] / doc / oauth.3
1 .TH "oauth.h" 3 "Thu Apr 17 2014" "Version 1.0.3" "OAuth library functions" \" -*- nroff -*-
2 .ad l
3 .nh
4 .SH NAME
5 oauth.h \- 
6 .PP
7 OAuth\&.net implementation in POSIX-C\&.  
8
9 .SH SYNOPSIS
10 .br
11 .PP
12 .SS "Enumerations"
13
14 .in +1c
15 .ti -1c
16 .RI "enum \fBOAuthMethod\fP { \fBOA_HMAC\fP =0, \fBOA_RSA\fP, \fBOA_PLAINTEXT\fP }"
17 .br
18 .RI "\fIsignature method to used for signing the request\&. \fP"
19 .in -1c
20 .SS "Functions"
21
22 .in +1c
23 .ti -1c
24 .RI "char * \fBoauth_encode_base64\fP (int size, const unsigned char *src)"
25 .br
26 .RI "\fIBase64 encode and return size data in 'src'\&. \fP"
27 .ti -1c
28 .RI "int \fBoauth_decode_base64\fP (unsigned char *dest, const char *src)"
29 .br
30 .RI "\fIDecode the base64 encoded string 'src' into the memory pointed to by 'dest'\&. \fP"
31 .ti -1c
32 .RI "char * \fBoauth_url_escape\fP (const char *string)"
33 .br
34 .RI "\fIEscape 'string' according to RFC3986 and http://oauth.net/core/1.0/#encoding_parameters\&. \fP"
35 .ti -1c
36 .RI "char * \fBoauth_url_unescape\fP (const char *string, size_t *olen)"
37 .br
38 .RI "\fIParse RFC3986 encoded 'string' back to unescaped version\&. \fP"
39 .ti -1c
40 .RI "char * \fBoauth_sign_hmac_sha1\fP (const char *m, const char *k)"
41 .br
42 .RI "\fIreturns base64 encoded HMAC-SHA1 signature for given message and key\&. \fP"
43 .ti -1c
44 .RI "char * \fBoauth_sign_hmac_sha1_raw\fP (const char *m, const size_t ml, const char *k, const size_t kl)"
45 .br
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"
47 .ti -1c
48 .RI "char * \fBoauth_sign_plaintext\fP (const char *m, const char *k)"
49 .br
50 .RI "\fIreturns plaintext signature for the given key\&. \fP"
51 .ti -1c
52 .RI "char * \fBoauth_sign_rsa_sha1\fP (const char *m, const char *k)"
53 .br
54 .RI "\fIreturns RSA-SHA1 signature for given data\&. \fP"
55 .ti -1c
56 .RI "int \fBoauth_verify_rsa_sha1\fP (const char *m, const char *c, const char *s)"
57 .br
58 .RI "\fIverify RSA-SHA1 signature\&. \fP"
59 .ti -1c
60 .RI "char * \fBoauth_catenc\fP (int len,\&.\&.\&.)"
61 .br
62 .RI "\fIurl-escape strings and concatenate with '&' separator\&. \fP"
63 .ti -1c
64 .RI "int \fBoauth_split_url_parameters\fP (const char *url, char ***argv)"
65 .br
66 .RI "\fIsplits the given url into a parameter array\&. \fP"
67 .ti -1c
68 .RI "int \fBoauth_split_post_paramters\fP (const char *url, char ***argv, short qesc)"
69 .br
70 .RI "\fIsplits the given url into a parameter array\&. \fP"
71 .ti -1c
72 .RI "char * \fBoauth_serialize_url\fP (int argc, int start, char **argv)"
73 .br
74 .RI "\fIbuild a url query string from an array\&. \fP"
75 .ti -1c
76 .RI "char * \fBoauth_serialize_url_sep\fP (int argc, int start, char **argv, char *sep, int mod)"
77 .br
78 .RI "\fIencode query parameters from an array\&. \fP"
79 .ti -1c
80 .RI "char * \fBoauth_serialize_url_parameters\fP (int argc, char **argv)"
81 .br
82 .RI "\fIbuild a query parameter string from an array\&. \fP"
83 .ti -1c
84 .RI "char * \fBoauth_gen_nonce\fP ()"
85 .br
86 .RI "\fIgenerate a random string between 15 and 32 chars length and return a pointer to it\&. \fP"
87 .ti -1c
88 .RI "int \fBoauth_cmpstringp\fP (const void *p1, const void *p2)"
89 .br
90 .RI "\fIstring compare function for oauth parameters\&. \fP"
91 .ti -1c
92 .RI "int \fBoauth_param_exists\fP (char **argv, int argc, char *key)"
93 .br
94 .RI "\fIsearch array for parameter key\&. \fP"
95 .ti -1c
96 .RI "void \fBoauth_add_param_to_array\fP (int *argcp, char ***argvp, const char *addparam)"
97 .br
98 .RI "\fIadd query parameter to array \fP"
99 .ti -1c
100 .RI "void \fBoauth_free_array\fP (int *argcp, char ***argvp)"
101 .br
102 .RI "\fIfree array args \fP"
103 .ti -1c
104 .RI "int \fBoauth_time_independent_equals_n\fP (const char *a, const char *b, size_t len_a, size_t len_b)"
105 .br
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"
107 .ti -1c
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"
109 .br
110 .ti -1c
111 .RI "int \fBoauth_time_independent_equals\fP (const char *a, const char *b)"
112 .br
113 .RI "\fIcompare two strings in constant-time\&. \fP"
114 .ti -1c
115 .RI "int \fBoauth_time_indepenent_equals\fP (const char *a, const char *b) attribute_deprecated"
116 .br
117 .ti -1c
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)"
119 .br
120 .RI "\fIcalculate OAuth-signature for a given HTTP request URL, parameters and oauth-tokens\&. \fP"
121 .ti -1c
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"
123 .br
124 .ti -1c
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)"
126 .br
127 .RI "\fIthe back-end behind by /ref oauth_sign_array2\&. \fP"
128 .ti -1c
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)"
130 .br
131 .RI "\fIsame as /ref oauth_sign_url with the url already split into parameter array \fP"
132 .ti -1c
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"
134 .br
135 .ti -1c
136 .RI "char * \fBoauth_body_hash_file\fP (char *filename)"
137 .br
138 .RI "\fIcalculate body hash (sha1sum) of given file and return a oauth_body_hash=xxxx parameter to be added to the request\&. \fP"
139 .ti -1c
140 .RI "char * \fBoauth_body_hash_data\fP (size_t length, const char *data)"
141 .br
142 .RI "\fIcalculate body hash (sha1sum) of given data and return a oauth_body_hash=xxxx parameter to be added to the request\&. \fP"
143 .ti -1c
144 .RI "char * \fBoauth_body_hash_encode\fP (size_t len, unsigned char *digest)"
145 .br
146 .RI "\fIbase64 encode digest, free it and return a URL parameter with the oauth_body_hash\&. \fP"
147 .ti -1c
148 .RI "char * \fBoauth_sign_xmpp\fP (const char *xml, \fBOAuthMethod\fP method, const char *c_secret, const char *t_secret)"
149 .br
150 .RI "\fIxep-0235 - TODO \fP"
151 .ti -1c
152 .RI "char * \fBoauth_http_get\fP (const char *u, const char *q) attribute_deprecated"
153 .br
154 .RI "\fIdo a HTTP GET request, wait for it to finish and return the content of the reply\&. \fP"
155 .ti -1c
156 .RI "char * \fBoauth_http_get2\fP (const char *u, const char *q, const char *customheader) attribute_deprecated"
157 .br
158 .RI "\fIdo a HTTP GET request, wait for it to finish and return the content of the reply\&. \fP"
159 .ti -1c
160 .RI "char * \fBoauth_http_post\fP (const char *u, const char *p) attribute_deprecated"
161 .br
162 .RI "\fIdo a HTTP POST request, wait for it to finish and return the content of the reply\&. \fP"
163 .ti -1c
164 .RI "char * \fBoauth_http_post2\fP (const char *u, const char *p, const char *customheader) attribute_deprecated"
165 .br
166 .RI "\fIdo a HTTP POST request, wait for it to finish and return the content of the reply\&. \fP"
167 .ti -1c
168 .RI "char * \fBoauth_post_file\fP (const char *u, const char *fn, const size_t len, const char *customheader) attribute_deprecated"
169 .br
170 .RI "\fIhttp post raw data from file\&. \fP"
171 .ti -1c
172 .RI "char * \fBoauth_post_data\fP (const char *u, const char *data, size_t len, const char *customheader) attribute_deprecated"
173 .br
174 .RI "\fIhttp post raw data the returned string needs to be freed by the caller (requires libcurl) \fP"
175 .ti -1c
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"
177 .br
178 .RI "\fIhttp post raw data, with callback\&. \fP"
179 .ti -1c
180 .RI "char * \fBoauth_send_data\fP (const char *u, const char *data, size_t len, const char *customheader, const char *httpMethod) attribute_deprecated"
181 .br
182 .RI "\fIhttp send raw data\&. \fP"
183 .ti -1c
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"
185 .br
186 .RI "\fIhttp post raw data, with callback\&. \fP"
187 .in -1c
188 .SH "Detailed Description"
189 .PP 
190 OAuth\&.net implementation in POSIX-C\&. 
191
192 \fBAuthor:\fP
193 .RS 4
194 Robin Gareus robin@gareus.org
195 .RE
196 .PP
197 Copyright 2007-2014 Robin Gareus robin@gareus.org
198 .PP
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:
200 .PP
201 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software\&.
202 .PP
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\&. 
204 .PP
205 Definition in file \fBoauth\&.h\fP\&.
206 .SH "Enumeration Type Documentation"
207 .PP 
208 .SS "enum \fBOAuthMethod\fP"
209
210 .PP
211 signature method to used for signing the request\&. 
212 .PP
213 \fBEnumerator: \fP
214 .in +1c
215 .TP
216 \fB\fIOA_HMAC \fP\fP
217 use HMAC-SHA1 request signing method 
218 .TP
219 \fB\fIOA_RSA \fP\fP
220 use RSA signature 
221 .TP
222 \fB\fIOA_PLAINTEXT \fP\fP
223 use plain text signature (for testing only) 
224 .PP
225 Definition at line 66 of file oauth\&.h\&.
226 .SH "Function Documentation"
227 .PP 
228 .SS "void oauth_add_param_to_array (int * argcp, char *** argvp, const char * addparam)"
229
230 .PP
231 add query parameter to array \fBParameters:\fP
232 .RS 4
233 \fIargcp\fP pointer to array length int 
234 .br
235 \fIargvp\fP pointer to array values 
236 .br
237 \fIaddparam\fP parameter to add (eg\&. 'foo=bar') 
238 .RE
239 .PP
240
241 .SS "char* oauth_body_hash_data (size_t length, const char * data)"
242
243 .PP
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\&.
245 .PP
246 see http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html
247 .PP
248 \fBParameters:\fP
249 .RS 4
250 \fIlength\fP length of the data parameter in bytes 
251 .br
252 \fIdata\fP to calculate the hash for
253 .RE
254 .PP
255 \fBReturns:\fP
256 .RS 4
257 URL oauth_body_hash parameter string 
258 .RE
259 .PP
260
261 .PP
262 \fBExamples: \fP
263 .in +1c
264 \fBtests/oauthbodyhash\&.c\fP\&.
265 .SS "char* oauth_body_hash_encode (size_t len, unsigned char * digest)"
266
267 .PP
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\&.
269 .PP
270 \fBParameters:\fP
271 .RS 4
272 \fIlen\fP length of the digest to encode 
273 .br
274 \fIdigest\fP hash value to encode
275 .RE
276 .PP
277 \fBReturns:\fP
278 .RS 4
279 URL oauth_body_hash parameter string 
280 .RE
281 .PP
282
283 .SS "char* oauth_body_hash_file (char * filename)"
284
285 .PP
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\&.
287 .PP
288 see http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html
289 .PP
290 \fBParameters:\fP
291 .RS 4
292 \fIfilename\fP the filename to calculate the hash for
293 .RE
294 .PP
295 \fBReturns:\fP
296 .RS 4
297 URL oauth_body_hash parameter string 
298 .RE
299 .PP
300
301 .PP
302 \fBExamples: \fP
303 .in +1c
304 \fBtests/oauthbodyhash\&.c\fP\&.
305 .SS "char* oauth_catenc (int len,  \&.\&.\&.)"
306
307 .PP
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 *)
309 .PP
310 \fBParameters:\fP
311 .RS 4
312 \fIlen\fP the number of arguments to follow this parameter
313 .RE
314 .PP
315 \fBReturns:\fP
316 .RS 4
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\&. 
318 .RE
319 .PP
320
321 .SS "int oauth_cmpstringp (const void * p1, const void * p2)"
322
323 .PP
324 string compare function for oauth parameters\&. used with qsort\&. needed to normalize request parameters\&. see http://oauth.net/core/1.0/#anchor14 
325 .PP
326 \fBExamples: \fP
327 .in +1c
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)"
330
331 .PP
332 Decode the base64 encoded string 'src' into the memory pointed to by 'dest'\&. \fBParameters:\fP
333 .RS 4
334 \fIdest\fP Pointer to memory for holding the decoded string\&. Must be large enough to receive the decoded string\&. 
335 .br
336 \fIsrc\fP A base64 encoded string\&. 
337 .RE
338 .PP
339 \fBReturns:\fP
340 .RS 4
341 the length of the decoded string if decode succeeded otherwise 0\&. 
342 .RE
343 .PP
344
345 .SS "char* oauth_encode_base64 (int size, const unsigned char * src)"
346
347 .PP
348 Base64 encode and return size data in 'src'\&. The caller must free the returned string\&.
349 .PP
350 \fBParameters:\fP
351 .RS 4
352 \fIsize\fP The size of the data in src 
353 .br
354 \fIsrc\fP The data to be base64 encode 
355 .RE
356 .PP
357 \fBReturns:\fP
358 .RS 4
359 encoded string otherwise NULL 
360 .RE
361 .PP
362
363 .SS "void oauth_free_array (int * argcp, char *** argvp)"
364
365 .PP
366 free array args \fBParameters:\fP
367 .RS 4
368 \fIargcp\fP pointer to array length int 
369 .br
370 \fIargvp\fP pointer to array values to be xfree()d 
371 .RE
372 .PP
373
374 .PP
375 \fBExamples: \fP
376 .in +1c
377 \fBtests/oauthtest2\&.c\fP\&.
378 .SS "char* oauth_gen_nonce ()"
379
380 .PP
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
382 .PP
383 \fBReturns:\fP
384 .RS 4
385 zero terminated random string\&. 
386 .RE
387 .PP
388
389 .SS "char* oauth_http_get (const char * u, const char * q)"
390
391 .PP
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)
393 .PP
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\&.
395 .PP
396 bash & wget example: \fCexport OAUTH_HTTP_CMD='wget \-q \-U 'liboauth-agent/0\&.1' '%u' '\fP
397 .PP
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\&.\&.
399 .PP
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\&.
401 .PP
402 \fBParameters:\fP
403 .RS 4
404 \fIu\fP base url to get 
405 .br
406 \fIq\fP query string to send along with the HTTP request or NULL\&. 
407 .RE
408 .PP
409 \fBReturns:\fP
410 .RS 4
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\&.
412 .RE
413 .PP
414 \fBDeprecated\fP
415 .RS 4
416 use libcurl - http://curl.haxx.se/libcurl/c/ 
417 .RE
418 .PP
419
420 .PP
421 \fBExamples: \fP
422 .in +1c
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)"
425
426 .PP
427 do a HTTP GET request, wait for it to finish and return the content of the reply\&. (requires libcurl)
428 .PP
429 This is equivalent to /ref oauth_http_get but allows one to specifiy a custom HTTP header andhas no support for commandline-curl\&.
430 .PP
431 If liboauth is compiled \fBwithout\fP libcurl this function always returns NULL\&.
432 .PP
433 \fBParameters:\fP
434 .RS 4
435 \fIu\fP base url to get 
436 .br
437 \fIq\fP query string to send along with the HTTP request or NULL\&. 
438 .br
439 \fIcustomheader\fP specify custom HTTP header (or NULL for none) Multiple header elements can be passed separating them with '\\r\\n' 
440 .RE
441 .PP
442 \fBReturns:\fP
443 .RS 4
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\&.
445 .RE
446 .PP
447 \fBDeprecated\fP
448 .RS 4
449 use libcurl - http://curl.haxx.se/libcurl/c/ 
450 .RE
451 .PP
452
453 .PP
454 \fBExamples: \fP
455 .in +1c
456 \fBtests/oauthtest2\&.c\fP\&.
457 .SS "char* oauth_http_post (const char * u, const char * p)"
458
459 .PP
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)
461 .PP
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\&.
463 .PP
464 bash & wget example: \fCexport OAUTH_HTTP_CMD='wget \-q \-U 'liboauth-agent/0\&.1' –post-data='%p' '%u' '\fP
465 .PP
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\&.
467 .PP
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\&.\&.
469 .PP
470 \fBParameters:\fP
471 .RS 4
472 \fIu\fP url to query 
473 .br
474 \fIp\fP postargs to send along with the HTTP request\&. 
475 .RE
476 .PP
477 \fBReturns:\fP
478 .RS 4
479 replied content from HTTP server\&. needs to be freed by caller\&.
480 .RE
481 .PP
482 \fBDeprecated\fP
483 .RS 4
484 use libcurl - http://curl.haxx.se/libcurl/c/ 
485 .RE
486 .PP
487
488 .PP
489 \fBExamples: \fP
490 .in +1c
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)"
493
494 .PP
495 do a HTTP POST request, wait for it to finish and return the content of the reply\&. (requires libcurl)
496 .PP
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\&.
498 .PP
499 If liboauth is compiled \fBwithout\fP libcurl this function always returns NULL\&.
500 .PP
501 \fBParameters:\fP
502 .RS 4
503 \fIu\fP url to query 
504 .br
505 \fIp\fP postargs to send along with the HTTP request\&. 
506 .br
507 \fIcustomheader\fP specify custom HTTP header (or NULL for none) Multiple header elements can be passed separating them with '\\r\\n' 
508 .RE
509 .PP
510 \fBReturns:\fP
511 .RS 4
512 replied content from HTTP server\&. needs to be freed by caller\&.
513 .RE
514 .PP
515 \fBDeprecated\fP
516 .RS 4
517 use libcurl - http://curl.haxx.se/libcurl/c/ 
518 .RE
519 .PP
520
521 .SS "int oauth_param_exists (char ** argv, int argc, char * key)"
522
523 .PP
524 search array for parameter key\&. \fBParameters:\fP
525 .RS 4
526 \fIargv\fP length of array to search 
527 .br
528 \fIargc\fP parameter array to search 
529 .br
530 \fIkey\fP key of parameter to check\&.
531 .RE
532 .PP
533 \fBReturns:\fP
534 .RS 4
535 FALSE (0) if array does not contain a parameter with given key, TRUE (1) otherwise\&. 
536 .RE
537 .PP
538
539 .SS "char* oauth_post_data (const char * u, const char * data, size_t len, const char * customheader)"
540
541 .PP
542 http post raw data the returned string needs to be freed by the caller (requires libcurl) see dislaimer: /ref oauth_http_post
543 .PP
544 \fBParameters:\fP
545 .RS 4
546 \fIu\fP url to retrieve 
547 .br
548 \fIdata\fP data to post 
549 .br
550 \fIlen\fP length of the data in bytes\&. 
551 .br
552 \fIcustomheader\fP specify custom HTTP header (or NULL for default) Multiple header elements can be passed separating them with '\\r\\n' 
553 .RE
554 .PP
555 \fBReturns:\fP
556 .RS 4
557 returned HTTP reply or NULL on error
558 .RE
559 .PP
560 \fBDeprecated\fP
561 .RS 4
562 use libcurl - http://curl.haxx.se/libcurl/c/ 
563 .RE
564 .PP
565
566 .PP
567 \fBExamples: \fP
568 .in +1c
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)"
571
572 .PP
573 http post raw data, with callback\&. the returned string needs to be freed by the caller (requires libcurl)
574 .PP
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
576 .PP
577 \fBParameters:\fP
578 .RS 4
579 \fIu\fP url to retrieve 
580 .br
581 \fIdata\fP data to post along 
582 .br
583 \fIlen\fP length of the file in bytes\&. set to '0' for autodetection 
584 .br
585 \fIcustomheader\fP specify custom HTTP header (or NULL for default) Multiple header elements can be passed separating them with '\\r\\n' 
586 .br
587 \fIcallback\fP specify the callback function 
588 .br
589 \fIcallback_data\fP specify data to pass to the callback function 
590 .RE
591 .PP
592 \fBReturns:\fP
593 .RS 4
594 returned HTTP reply or NULL on error
595 .RE
596 .PP
597 \fBDeprecated\fP
598 .RS 4
599 use libcurl - http://curl.haxx.se/libcurl/c/ 
600 .RE
601 .PP
602
603 .SS "char* oauth_post_file (const char * u, const char * fn, const size_t len, const char * customheader)"
604
605 .PP
606 http post raw data from file\&. the returned string needs to be freed by the caller (requires libcurl)
607 .PP
608 see dislaimer: /ref oauth_http_post
609 .PP
610 \fBParameters:\fP
611 .RS 4
612 \fIu\fP url to retrieve 
613 .br
614 \fIfn\fP filename of the file to post along 
615 .br
616 \fIlen\fP length of the file in bytes\&. set to '0' for autodetection 
617 .br
618 \fIcustomheader\fP specify custom HTTP header (or NULL for default)\&. Multiple header elements can be passed separating them with '\\r\\n' 
619 .RE
620 .PP
621 \fBReturns:\fP
622 .RS 4
623 returned HTTP reply or NULL on error
624 .RE
625 .PP
626 \fBDeprecated\fP
627 .RS 4
628 use libcurl - http://curl.haxx.se/libcurl/c/ 
629 .RE
630 .PP
631
632 .SS "char* oauth_send_data (const char * u, const char * data, size_t len, const char * customheader, const char * httpMethod)"
633
634 .PP
635 http send raw data\&. similar to /ref oauth_http_post but provides for specifying the HTTP request method\&.
636 .PP
637 the returned string needs to be freed by the caller (requires libcurl)
638 .PP
639 see dislaimer: /ref oauth_http_post
640 .PP
641 \fBParameters:\fP
642 .RS 4
643 \fIu\fP url to retrieve 
644 .br
645 \fIdata\fP data to post 
646 .br
647 \fIlen\fP length of the data in bytes\&. 
648 .br
649 \fIcustomheader\fP specify custom HTTP header (or NULL for default) Multiple header elements can be passed separating them with '\\r\\n' 
650 .br
651 \fIhttpMethod\fP specify http verb ('GET'/'POST'/'PUT'/'DELETE') to be used\&. if httpMethod is NULL, a POST is executed\&. 
652 .RE
653 .PP
654 \fBReturns:\fP
655 .RS 4
656 returned HTTP reply or NULL on error
657 .RE
658 .PP
659 \fBDeprecated\fP
660 .RS 4
661 use libcurl - http://curl.haxx.se/libcurl/c/ 
662 .RE
663 .PP
664
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)"
666
667 .PP
668 http post raw data, with callback\&. the returned string needs to be freed by the caller (requires libcurl)
669 .PP
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
671 .PP
672 \fBParameters:\fP
673 .RS 4
674 \fIu\fP url to retrieve 
675 .br
676 \fIdata\fP data to post along 
677 .br
678 \fIlen\fP length of the file in bytes\&. set to '0' for autodetection 
679 .br
680 \fIcustomheader\fP specify custom HTTP header (or NULL for default) Multiple header elements can be passed separating them with '\\r\\n' 
681 .br
682 \fIcallback\fP specify the callback function 
683 .br
684 \fIcallback_data\fP specify data to pass to the callback function 
685 .br
686 \fIhttpMethod\fP specify http verb ('GET'/'POST'/'PUT'/'DELETE') to be used\&. 
687 .RE
688 .PP
689 \fBReturns:\fP
690 .RS 4
691 returned HTTP reply or NULL on error
692 .RE
693 .PP
694 \fBDeprecated\fP
695 .RS 4
696 use libcurl - http://curl.haxx.se/libcurl/c/ 
697 .RE
698 .PP
699
700 .SS "char* oauth_serialize_url (int argc, int start, char ** argv)"
701
702 .PP
703 build a url query string from an array\&. \fBParameters:\fP
704 .RS 4
705 \fIargc\fP the total number of elements in the array 
706 .br
707 \fIstart\fP element in the array at which to start concatenating\&. 
708 .br
709 \fIargv\fP parameter-array to concatenate\&. 
710 .RE
711 .PP
712 \fBReturns:\fP
713 .RS 4
714 url string needs to be freed by the caller\&. 
715 .RE
716 .PP
717
718 .SS "char* oauth_serialize_url_parameters (int argc, char ** argv)"
719
720 .PP
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\&.
722 .PP
723 \fBParameters:\fP
724 .RS 4
725 \fIargc\fP the total number of elements in the array 
726 .br
727 \fIargv\fP parameter-array to concatenate\&. 
728 .RE
729 .PP
730 \fBReturns:\fP
731 .RS 4
732 url string needs to be freed by the caller\&. 
733 .RE
734 .PP
735
736 .SS "char* oauth_serialize_url_sep (int argc, int start, char ** argv, char * sep, int mod)"
737
738 .PP
739 encode query parameters from an array\&. \fBParameters:\fP
740 .RS 4
741 \fIargc\fP the total number of elements in the array 
742 .br
743 \fIstart\fP element in the array at which to start concatenating\&. 
744 .br
745 \fIargv\fP parameter-array to concatenate\&. 
746 .br
747 \fIsep\fP separator for parameters (usually '&') 
748 .br
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)\&. 
750 .RE
751 .PP
752 \fBReturns:\fP
753 .RS 4
754 url string needs to be freed by the caller\&. 
755 .RE
756 .PP
757
758 .PP
759 \fBExamples: \fP
760 .in +1c
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)"
763 \fBDeprecated\fP
764 .RS 4
765 Use \fBoauth_sign_array2()\fP instead\&. 
766 .RE
767 .PP
768
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)"
770
771 .PP
772 same as /ref oauth_sign_url with the url already split into parameter array \fBParameters:\fP
773 .RS 4
774 \fIargcp\fP pointer to array length int 
775 .br
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\&.
777 .br
778 \fIpostargs\fP This parameter points to an area where the return value is stored\&. If 'postargs' is NULL, no value is stored\&.
779 .br
780 \fImethod\fP specify the signature method to use\&. It is of type \fBOAuthMethod\fP and most likely \fBOA_HMAC\fP\&.
781 .br
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\&.
783 .br
784 \fIc_key\fP consumer key 
785 .br
786 \fIc_secret\fP consumer secret 
787 .br
788 \fIt_key\fP token key 
789 .br
790 \fIt_secret\fP token secret
791 .RE
792 .PP
793 \fBReturns:\fP
794 .RS 4
795 the signed url or NULL if an error occurred\&. 
796 .RE
797 .PP
798
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)"
800
801 .PP
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\&.
803 .PP
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\&.
805 .PP
806 \fBParameters:\fP
807 .RS 4
808 \fIargcp\fP pointer to array length int 
809 .br
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\&.
811 .br
812 \fIpostargs\fP This parameter points to an area where the return value is stored\&. If 'postargs' is NULL, no value is stored\&.
813 .br
814 \fImethod\fP specify the signature method to use\&. It is of type \fBOAuthMethod\fP and most likely \fBOA_HMAC\fP\&.
815 .br
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\&.
817 .br
818 \fIc_key\fP consumer key 
819 .br
820 \fIc_secret\fP consumer secret 
821 .br
822 \fIt_key\fP token key 
823 .br
824 \fIt_secret\fP token secret
825 .RE
826 .PP
827 \fBReturns:\fP
828 .RS 4
829 void 
830 .RE
831 .PP
832
833 .PP
834 \fBExamples: \fP
835 .in +1c
836 \fBtests/oauthtest2\&.c\fP\&.
837 .SS "char* oauth_sign_hmac_sha1 (const char * m, const char * k)"
838
839 .PP
840 returns base64 encoded HMAC-SHA1 signature for given message and key\&. both data and key need to be urlencoded\&.
841 .PP
842 the returned string needs to be freed by the caller
843 .PP
844 \fBParameters:\fP
845 .RS 4
846 \fIm\fP message to be signed 
847 .br
848 \fIk\fP key used for signing 
849 .RE
850 .PP
851 \fBReturns:\fP
852 .RS 4
853 signature string\&. 
854 .RE
855 .PP
856
857 .PP
858 \fBExamples: \fP
859 .in +1c
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)"
862
863 .PP
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
865 .RS 4
866 \fIm\fP message to be signed 
867 .br
868 \fIml\fP length of message 
869 .br
870 \fIk\fP key used for signing 
871 .br
872 \fIkl\fP length of key 
873 .RE
874 .PP
875 \fBReturns:\fP
876 .RS 4
877 signature string\&. 
878 .RE
879 .PP
880
881 .SS "char* oauth_sign_plaintext (const char * m, const char * k)"
882
883 .PP
884 returns plaintext signature for the given key\&. the returned string needs to be freed by the caller
885 .PP
886 \fBParameters:\fP
887 .RS 4
888 \fIm\fP message to be signed 
889 .br
890 \fIk\fP key used for signing 
891 .RE
892 .PP
893 \fBReturns:\fP
894 .RS 4
895 signature string 
896 .RE
897 .PP
898
899 .SS "char* oauth_sign_rsa_sha1 (const char * m, const char * k)"
900
901 .PP
902 returns RSA-SHA1 signature for given data\&. the returned signature needs to be freed by the caller\&.
903 .PP
904 \fBParameters:\fP
905 .RS 4
906 \fIm\fP message to be signed 
907 .br
908 \fIk\fP private-key PKCS and Base64-encoded 
909 .RE
910 .PP
911 \fBReturns:\fP
912 .RS 4
913 base64 encoded signature string\&. 
914 .RE
915 .PP
916
917 .PP
918 \fBExamples: \fP
919 .in +1c
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)"
922 \fBDeprecated\fP
923 .RS 4
924 Use \fBoauth_sign_url2()\fP instead\&. 
925 .RE
926 .PP
927
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)"
929
930 .PP
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\&.
932 .PP
933 both, the return value and (if given) 'postargs' need to be freed by the caller\&.
934 .PP
935 \fBParameters:\fP
936 .RS 4
937 \fIurl\fP The request URL to be signed\&. append all GET or POST query-parameters separated by either '?' or '&' to this parameter\&.
938 .br
939 \fIpostargs\fP This parameter points to an area where the return value is stored\&. If 'postargs' is NULL, no value is stored\&.
940 .br
941 \fImethod\fP specify the signature method to use\&. It is of type \fBOAuthMethod\fP and most likely \fBOA_HMAC\fP\&.
942 .br
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\&.
944 .br
945 \fIc_key\fP consumer key 
946 .br
947 \fIc_secret\fP consumer secret 
948 .br
949 \fIt_key\fP token key 
950 .br
951 \fIt_secret\fP token secret
952 .RE
953 .PP
954 \fBReturns:\fP
955 .RS 4
956 the signed url or NULL if an error occurred\&. 
957 .RE
958 .PP
959
960 .PP
961 \fBExamples: \fP
962 .in +1c
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)"
965
966 .PP
967 xep-0235 - TODO 
968 .SS "int oauth_split_post_paramters (const char * url, char *** argv, short qesc)"
969
970 .PP
971 splits the given url into a parameter array\&. (see \fBoauth_serialize_url\fP and \fBoauth_serialize_url_parameters\fP for the reverse)
972 .PP
973 \fBParameters:\fP
974 .RS 4
975 \fIurl\fP the url or query-string to parse\&. 
976 .br
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\&. 
978 .br
979 \fIqesc\fP use query parameter escape (vs post-param-escape) - if set to 1 all '+' are treated as spaces ' '
980 .RE
981 .PP
982 \fBReturns:\fP
983 .RS 4
984 number of parameter(s) in array\&. 
985 .RE
986 .PP
987
988 .SS "int oauth_split_url_parameters (const char * url, char *** argv)"
989
990 .PP
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)
992 .PP
993 \fBParameters:\fP
994 .RS 4
995 \fIurl\fP the url or query-string to parse; may be NULL 
996 .br
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\&.
998 .RE
999 .PP
1000 \fBReturns:\fP
1001 .RS 4
1002 number of parameter(s) in array\&. 
1003 .RE
1004 .PP
1005
1006 .PP
1007 \fBExamples: \fP
1008 .in +1c
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)"
1011
1012 .PP
1013 compare two strings in constant-time\&. wrapper to \fBoauth_time_independent_equals_n\fP which calls strlen() for each argument\&.
1014 .PP
1015 \fBParameters:\fP
1016 .RS 4
1017 \fIa\fP string to compare 
1018 .br
1019 \fIb\fP string to compare
1020 .RE
1021 .PP
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)"
1024
1025 .PP
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
1027 .RS 4
1028 \fIa\fP string to compare 
1029 .br
1030 \fIb\fP string to compare 
1031 .br
1032 \fIlen_a\fP length of string a 
1033 .br
1034 \fIlen_b\fP length of string b
1035 .RE
1036 .PP
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)"
1039 \fBDeprecated\fP
1040 .RS 4
1041 Use \fBoauth_time_independent_equals()\fP instead\&. 
1042 .RE
1043 .PP
1044
1045 .SS "int oauth_time_indepenent_equals_n (const char * a, const char * b, size_t len_a, size_t len_b)"
1046 \fBDeprecated\fP
1047 .RS 4
1048 Use \fBoauth_time_independent_equals_n()\fP instead\&. 
1049 .RE
1050 .PP
1051
1052 .SS "char* oauth_url_escape (const char * string)"
1053
1054 .PP
1055 Escape 'string' according to RFC3986 and http://oauth.net/core/1.0/#encoding_parameters\&. \fBParameters:\fP
1056 .RS 4
1057 \fIstring\fP The data to be encoded 
1058 .RE
1059 .PP
1060 \fBReturns:\fP
1061 .RS 4
1062 encoded string otherwise NULL The caller must free the returned string\&. 
1063 .RE
1064 .PP
1065
1066 .SS "char* oauth_url_unescape (const char * string, size_t * olen)"
1067
1068 .PP
1069 Parse RFC3986 encoded 'string' back to unescaped version\&. \fBParameters:\fP
1070 .RS 4
1071 \fIstring\fP The data to be unescaped 
1072 .br
1073 \fIolen\fP unless NULL the length of the returned string is stored there\&. 
1074 .RE
1075 .PP
1076 \fBReturns:\fP
1077 .RS 4
1078 decoded string or NULL The caller must free the returned string\&. 
1079 .RE
1080 .PP
1081
1082 .SS "int oauth_verify_rsa_sha1 (const char * m, const char * c, const char * s)"
1083
1084 .PP
1085 verify RSA-SHA1 signature\&. returns the output of EVP_VerifyFinal() for a given message, cert/pubkey and signature\&.
1086 .PP
1087 \fBParameters:\fP
1088 .RS 4
1089 \fIm\fP message to be verified 
1090 .br
1091 \fIc\fP public-key or x509 certificate 
1092 .br
1093 \fIs\fP base64 encoded signature 
1094 .RE
1095 .PP
1096 \fBReturns:\fP
1097 .RS 4
1098 1 for a correct signature, 0 for failure and \-1 if some other error occurred 
1099 .RE
1100 .PP
1101
1102 .PP
1103 \fBExamples: \fP
1104 .in +1c
1105 \fBtests/selftest_wiki\&.c\fP\&.
1106 .SH "Author"
1107 .PP 
1108 Generated automatically by Doxygen for OAuth library functions from the source code\&.