summaryrefslogtreecommitdiff
path: root/protocols/Twitter/oauth/doc/oauth.3
blob: 3e8dbcf630e03b422506497ba1a93e1d3cc3f58f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
.TH "src/oauth.h" 3 "Tue Dec 13 2011" "Version 0.9.6" "OAuth library functions" \" -*- nroff -*-
.ad l
.nh
.SH NAME
src/oauth.h \- 
.PP
OAuth.net implementation in POSIX-C.  

.SH SYNOPSIS
.br
.PP
.SS "Defines"

.in +1c
.ti -1c
.RI "#define \fBOA_GCC_VERSION_AT_LEAST\fP(x, y)   0"
.br
.ti -1c
.RI "#define \fBattribute_deprecated\fP"
.br
.in -1c
.SS "Enumerations"

.in +1c
.ti -1c
.RI "enum \fBOAuthMethod\fP { \fBOA_HMAC\fP = 0, \fBOA_RSA\fP, \fBOA_PLAINTEXT\fP }"
.br
.RI "\fIsignature method to used for signing the request. \fP"
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "char * \fBoauth_encode_base64\fP (int size, const unsigned char *src)"
.br
.RI "\fIBase64 encode and return size data in 'src'. \fP"
.ti -1c
.RI "int \fBoauth_decode_base64\fP (unsigned char *dest, const char *src)"
.br
.RI "\fIDecode the base64 encoded string 'src' into the memory pointed to by 'dest'. \fP"
.ti -1c
.RI "char * \fBoauth_url_escape\fP (const char *string)"
.br
.RI "\fIEscape 'string' according to RFC3986 and http://oauth.net/core/1.0/#encoding_parameters. \fP"
.ti -1c
.RI "char * \fBoauth_url_unescape\fP (const char *string, size_t *olen)"
.br
.RI "\fIParse RFC3986 encoded 'string' back to unescaped version. \fP"
.ti -1c
.RI "char * \fBoauth_sign_hmac_sha1\fP (const char *m, const char *k)"
.br
.RI "\fIreturns base64 encoded HMAC-SHA1 signature for given message and key. \fP"
.ti -1c
.RI "char * \fBoauth_sign_hmac_sha1_raw\fP (const char *m, const size_t ml, const char *k, const size_t kl)"
.br
.RI "\fIsame as \fBoauth_sign_hmac_sha1\fP but allows to specify length of message and key (in case they contain null chars). \fP"
.ti -1c
.RI "char * \fBoauth_sign_plaintext\fP (const char *m, const char *k)"
.br
.RI "\fIreturns plaintext signature for the given key. \fP"
.ti -1c
.RI "char * \fBoauth_sign_rsa_sha1\fP (const char *m, const char *k)"
.br
.RI "\fIreturns RSA-SHA1 signature for given data. \fP"
.ti -1c
.RI "int \fBoauth_verify_rsa_sha1\fP (const char *m, const char *c, const char *s)"
.br
.RI "\fIverify RSA-SHA1 signature. \fP"
.ti -1c
.RI "char * \fBoauth_catenc\fP (int len,...)"
.br
.RI "\fIurl-escape strings and concatenate with '&' separator. \fP"
.ti -1c
.RI "int \fBoauth_split_url_parameters\fP (const char *url, char ***argv)"
.br
.RI "\fIsplits the given url into a parameter array. \fP"
.ti -1c
.RI "int \fBoauth_split_post_paramters\fP (const char *url, char ***argv, short qesc)"
.br
.RI "\fIsplits the given url into a parameter array. \fP"
.ti -1c
.RI "char * \fBoauth_serialize_url\fP (int argc, int start, char **argv)"
.br
.RI "\fIbuild a url query string from an array. \fP"
.ti -1c
.RI "char * \fBoauth_serialize_url_sep\fP (int argc, int start, char **argv, char *sep, int mod)"
.br
.RI "\fIencode query parameters from an array. \fP"
.ti -1c
.RI "char * \fBoauth_serialize_url_parameters\fP (int argc, char **argv)"
.br
.RI "\fIbuild a query parameter string from an array. \fP"
.ti -1c
.RI "char * \fBoauth_gen_nonce\fP ()"
.br
.RI "\fIgenerate a random string between 15 and 32 chars length and return a pointer to it. \fP"
.ti -1c
.RI "int \fBoauth_cmpstringp\fP (const void *p1, const void *p2)"
.br
.RI "\fIstring compare function for oauth parameters. \fP"
.ti -1c
.RI "int \fBoauth_param_exists\fP (char **argv, int argc, char *key)"
.br
.RI "\fIsearch array for parameter key. \fP"
.ti -1c
.RI "void \fBoauth_add_param_to_array\fP (int *argcp, char ***argvp, const char *addparam)"
.br
.RI "\fIadd query parameter to array \fP"
.ti -1c
.RI "void \fBoauth_free_array\fP (int *argcp, char ***argvp)"
.br
.RI "\fIfree array args \fP"
.ti -1c
.RI "int \fBoauth_time_independent_equals_n\fP (const char *a, const char *b, size_t len_a, size_t len_b)"
.br
.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"
.ti -1c
.RI "int \fBoauth_time_indepenent_equals_n\fP (const char *a, const char *b, size_t len_a, size_t len_b) attribute_deprecated"
.br
.ti -1c
.RI "int \fBoauth_time_independent_equals\fP (const char *a, const char *b)"
.br
.RI "\fIcompare two strings in constant-time. \fP"
.ti -1c
.RI "int \fBoauth_time_indepenent_equals\fP (const char *a, const char *b) attribute_deprecated"
.br
.ti -1c
.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)"
.br
.RI "\fIcalculate OAuth-signature for a given HTTP request URL, parameters and oauth-tokens. \fP"
.ti -1c
.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"
.br
.ti -1c
.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)"
.br
.RI "\fIthe back-end behind by /ref oauth_sign_array2. \fP"
.ti -1c
.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)"
.br
.RI "\fIsame as /ref oauth_sign_url with the url already split into parameter array \fP"
.ti -1c
.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"
.br
.ti -1c
.RI "char * \fBoauth_body_hash_file\fP (char *filename)"
.br
.RI "\fIcalculate body hash (sha1sum) of given file and return a oauth_body_hash=xxxx parameter to be added to the request. \fP"
.ti -1c
.RI "char * \fBoauth_body_hash_data\fP (size_t length, const char *data)"
.br
.RI "\fIcalculate body hash (sha1sum) of given data and return a oauth_body_hash=xxxx parameter to be added to the request. \fP"
.ti -1c
.RI "char * \fBoauth_body_hash_encode\fP (size_t len, unsigned char *digest)"
.br
.RI "\fIbase64 encode digest, free it and return a URL parameter with the oauth_body_hash. \fP"
.ti -1c
.RI "char * \fBoauth_sign_xmpp\fP (const char *xml, \fBOAuthMethod\fP method, const char *c_secret, const char *t_secret)"
.br
.RI "\fIxep-0235 - TODO \fP"
.ti -1c
.RI "char * \fBoauth_http_get\fP (const char *u, const char *q)"
.br
.RI "\fIdo a HTTP GET request, wait for it to finish and return the content of the reply. \fP"
.ti -1c
.RI "char * \fBoauth_http_get2\fP (const char *u, const char *q, const char *customheader)"
.br
.RI "\fIdo a HTTP GET request, wait for it to finish and return the content of the reply. \fP"
.ti -1c
.RI "char * \fBoauth_http_post\fP (const char *u, const char *p)"
.br
.RI "\fIdo a HTTP POST request, wait for it to finish and return the content of the reply. \fP"
.ti -1c
.RI "char * \fBoauth_http_post2\fP (const char *u, const char *p, const char *customheader)"
.br
.RI "\fIdo a HTTP POST request, wait for it to finish and return the content of the reply. \fP"
.ti -1c
.RI "char * \fBoauth_post_file\fP (const char *u, const char *fn, const size_t len, const char *customheader)"
.br
.RI "\fIhttp post raw data from file. \fP"
.ti -1c
.RI "char * \fBoauth_post_data\fP (const char *u, const char *data, size_t len, const char *customheader)"
.br
.RI "\fIhttp post raw data the returned string needs to be freed by the caller (requires libcurl) \fP"
.ti -1c
.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)"
.br
.RI "\fIhttp post raw data, with callback. \fP"
.ti -1c
.RI "char * \fBoauth_send_data\fP (const char *u, const char *data, size_t len, const char *customheader, const char *httpMethod)"
.br
.RI "\fIhttp send raw data. \fP"
.ti -1c
.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)"
.br
.RI "\fIhttp post raw data, with callback. \fP"
.in -1c
.SH "Detailed Description"
.PP 
OAuth.net implementation in POSIX-C. 

\fBAuthor:\fP
.RS 4
Robin Gareus <robin@gareus.org>
.RE
.PP
Copyright 2007-2011 Robin Gareus <robin@gareus.org>
.PP
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:
.PP
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
.PP
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. 
.PP
Definition in file \fBoauth.h\fP.
.SH "Define Documentation"
.PP 
.SS "#define attribute_deprecated"
.PP
Definition at line 54 of file oauth.h.
.SS "#define OA_GCC_VERSION_AT_LEAST(x, y)   0"
.PP
Definition at line 47 of file oauth.h.
.SH "Enumeration Type Documentation"
.PP 
.SS "enum \fBOAuthMethod\fP"
.PP
signature method to used for signing the request. 
.PP
\fBEnumerator: \fP
.in +1c
.TP
\fB\fIOA_HMAC \fP\fP
use HMAC-SHA1 request signing method 
.TP
\fB\fIOA_RSA \fP\fP
use RSA signature 
.TP
\fB\fIOA_PLAINTEXT \fP\fP
use plain text signature (for testing only) 
.PP
Definition at line 65 of file oauth.h.
.SH "Function Documentation"
.PP 
.SS "void oauth_add_param_to_array (int * argcp, char *** argvp, const char * addparam)"
.PP
add query parameter to array \fBParameters:\fP
.RS 4
\fIargcp\fP pointer to array length int 
.br
\fIargvp\fP pointer to array values 
.br
\fIaddparam\fP parameter to add (eg. 'foo=bar') 
.RE
.PP

.SS "char* oauth_body_hash_data (size_t length, const char * data)"
.PP
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.
.PP
see http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html
.PP
\fBParameters:\fP
.RS 4
\fIlength\fP length of the data parameter in bytes 
.br
\fIdata\fP to calculate the hash for
.RE
.PP
\fBReturns:\fP
.RS 4
URL oauth_body_hash parameter string 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/oauthbodyhash.c\fP.
.SS "char* oauth_body_hash_encode (size_t len, unsigned char * digest)"
.PP
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.
.PP
\fBParameters:\fP
.RS 4
\fIlen\fP length of the digest to encode 
.br
\fIdigest\fP hash value to encode
.RE
.PP
\fBReturns:\fP
.RS 4
URL oauth_body_hash parameter string 
.RE
.PP

.SS "char* oauth_body_hash_file (char * filename)"
.PP
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.
.PP
see http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html
.PP
\fBParameters:\fP
.RS 4
\fIfilename\fP the filename to calculate the hash for
.RE
.PP
\fBReturns:\fP
.RS 4
URL oauth_body_hash parameter string 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/oauthbodyhash.c\fP.
.SS "char* oauth_catenc (int len,  ...)"
.PP
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 *)
.PP
\fBParameters:\fP
.RS 4
\fIlen\fP the number of arguments to follow this parameter
.RE
.PP
\fBReturns:\fP
.RS 4
pointer to memory holding the concatenated strings - needs to be free(d) by the caller. or NULL in case we ran out of memory. 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/oauthbodyhash.c\fP.
.SS "int oauth_cmpstringp (const void * p1, const void * p2)"
.PP
string compare function for oauth parameters. used with qsort. needed to normalize request parameters. see http://oauth.net/core/1.0/#anchor14 
.PP
\fBExamples: \fP
.in +1c
\fBtests/oauthexample.c\fP, \fBtests/oauthtest.c\fP, and \fBtests/oauthtest2.c\fP.
.SS "int oauth_decode_base64 (unsigned char * dest, const char * src)"
.PP
Decode the base64 encoded string 'src' into the memory pointed to by 'dest'. \fBParameters:\fP
.RS 4
\fIdest\fP Pointer to memory for holding the decoded string. Must be large enough to receive the decoded string. 
.br
\fIsrc\fP A base64 encoded string. 
.RE
.PP
\fBReturns:\fP
.RS 4
the length of the decoded string if decode succeeded otherwise 0. 
.RE
.PP

.SS "char* oauth_encode_base64 (int size, const unsigned char * src)"
.PP
Base64 encode and return size data in 'src'. The caller must free the returned string.
.PP
\fBParameters:\fP
.RS 4
\fIsize\fP The size of the data in src 
.br
\fIsrc\fP The data to be base64 encode 
.RE
.PP
\fBReturns:\fP
.RS 4
encoded string otherwise NULL 
.RE
.PP

.SS "void oauth_free_array (int * argcp, char *** argvp)"
.PP
free array args \fBParameters:\fP
.RS 4
\fIargcp\fP pointer to array length int 
.br
\fIargvp\fP pointer to array values to be free()d 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/oauthtest2.c\fP.
.SS "char* oauth_gen_nonce ()"
.PP
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
.PP
\fBReturns:\fP
.RS 4
zero terminated random string. 
.RE
.PP

.SS "char* oauth_http_get (const char * u, const char * q)"
.PP
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)
.PP
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.
.PP
bash & wget example: \fCexport OAUTH_HTTP_CMD='wget \-q \-U 'liboauth-agent/0.1' '%u' '\fP
.PP
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..
.PP
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.
.PP
\fBParameters:\fP
.RS 4
\fIu\fP base url to get 
.br
\fIq\fP query string to send along with the HTTP request or NULL. 
.RE
.PP
\fBReturns:\fP
.RS 4
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. 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/oauthexample.c\fP, and \fBtests/oauthtest.c\fP.
.SS "char* oauth_http_get2 (const char * u, const char * q, const char * customheader)"
.PP
do a HTTP GET request, wait for it to finish and return the content of the reply. (requires libcurl)
.PP
This is equivalent to /ref oauth_http_get but allows to specifiy a custom HTTP header and has has no support for commandline-curl.
.PP
If liboauth is compiled \fBwithout\fP libcurl this function always returns NULL.
.PP
\fBParameters:\fP
.RS 4
\fIu\fP base url to get 
.br
\fIq\fP query string to send along with the HTTP request or NULL. 
.br
\fIcustomheader\fP specify custom HTTP header (or NULL for none) Multiple header elements can be passed separating them with '\\r\\n' 
.RE
.PP
\fBReturns:\fP
.RS 4
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. 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/oauthtest2.c\fP.
.SS "char* oauth_http_post (const char * u, const char * p)"
.PP
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)
.PP
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.
.PP
bash & wget example: \fCexport OAUTH_HTTP_CMD='wget \-q \-U 'liboauth-agent/0.1' \-\-post-data='%p' '%u' '\fP
.PP
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.
.PP
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..
.PP
\fBParameters:\fP
.RS 4
\fIu\fP url to query 
.br
\fIp\fP postargs to send along with the HTTP request. 
.RE
.PP
\fBReturns:\fP
.RS 4
replied content from HTTP server. needs to be freed by caller. 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/oauthexample.c\fP, and \fBtests/oauthtest.c\fP.
.SS "char* oauth_http_post2 (const char * u, const char * p, const char * customheader)"
.PP
do a HTTP POST request, wait for it to finish and return the content of the reply. (requires libcurl)
.PP
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.
.PP
If liboauth is compiled \fBwithout\fP libcurl this function always returns NULL.
.PP
\fBParameters:\fP
.RS 4
\fIu\fP url to query 
.br
\fIp\fP postargs to send along with the HTTP request. 
.br
\fIcustomheader\fP specify custom HTTP header (or NULL for none) Multiple header elements can be passed separating them with '\\r\\n' 
.RE
.PP
\fBReturns:\fP
.RS 4
replied content from HTTP server. needs to be freed by caller. 
.RE
.PP

.SS "int oauth_param_exists (char ** argv, int argc, char * key)"
.PP
search array for parameter key. \fBParameters:\fP
.RS 4
\fIargv\fP length of array to search 
.br
\fIargc\fP parameter array to search 
.br
\fIkey\fP key of parameter to check.
.RE
.PP
\fBReturns:\fP
.RS 4
FALSE (0) if array does not contain a parameter with given key, TRUE (1) otherwise. 
.RE
.PP

.SS "char* oauth_post_data (const char * u, const char * data, size_t len, const char * customheader)"
.PP
http post raw data the returned string needs to be freed by the caller (requires libcurl) see dislaimer: /ref oauth_http_post
.PP
\fBParameters:\fP
.RS 4
\fIu\fP url to retrieve 
.br
\fIdata\fP data to post 
.br
\fIlen\fP length of the data in bytes. 
.br
\fIcustomheader\fP specify custom HTTP header (or NULL for default) Multiple header elements can be passed separating them with '\\r\\n' 
.RE
.PP
\fBReturns:\fP
.RS 4
returned HTTP reply or NULL on error 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/oauthbodyhash.c\fP.
.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)"
.PP
http post raw data, with callback. the returned string needs to be freed by the caller (requires libcurl)
.PP
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
.PP
\fBParameters:\fP
.RS 4
\fIu\fP url to retrieve 
.br
\fIdata\fP data to post along 
.br
\fIlen\fP length of the file in bytes. set to '0' for autodetection 
.br
\fIcustomheader\fP specify custom HTTP header (or NULL for default) Multiple header elements can be passed separating them with '\\r\\n' 
.br
\fIcallback\fP specify the callback function 
.br
\fIcallback_data\fP specify data to pass to the callback function 
.RE
.PP
\fBReturns:\fP
.RS 4
returned HTTP reply or NULL on error 
.RE
.PP

.SS "char* oauth_post_file (const char * u, const char * fn, const size_t len, const char * customheader)"
.PP
http post raw data from file. the returned string needs to be freed by the caller (requires libcurl)
.PP
see dislaimer: /ref oauth_http_post
.PP
\fBParameters:\fP
.RS 4
\fIu\fP url to retrieve 
.br
\fIfn\fP filename of the file to post along 
.br
\fIlen\fP length of the file in bytes. set to '0' for autodetection 
.br
\fIcustomheader\fP specify custom HTTP header (or NULL for default). Multiple header elements can be passed separating them with '\\r\\n' 
.RE
.PP
\fBReturns:\fP
.RS 4
returned HTTP reply or NULL on error 
.RE
.PP

.SS "char* oauth_send_data (const char * u, const char * data, size_t len, const char * customheader, const char * httpMethod)"
.PP
http send raw data. similar to /ref oauth_http_post but provides for specifying the HTTP request method.
.PP
the returned string needs to be freed by the caller (requires libcurl)
.PP
see dislaimer: /ref oauth_http_post
.PP
\fBParameters:\fP
.RS 4
\fIu\fP url to retrieve 
.br
\fIdata\fP data to post 
.br
\fIlen\fP length of the data in bytes. 
.br
\fIcustomheader\fP specify custom HTTP header (or NULL for default) Multiple header elements can be passed separating them with '\\r\\n' 
.br
\fIhttpMethod\fP specify http verb ('GET'/'POST'/'PUT'/'DELETE') to be used. if httpMethod is NULL, a POST is executed. 
.RE
.PP
\fBReturns:\fP
.RS 4
returned HTTP reply or NULL on error 
.RE
.PP

.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)"
.PP
http post raw data, with callback. the returned string needs to be freed by the caller (requires libcurl)
.PP
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
.PP
\fBParameters:\fP
.RS 4
\fIu\fP url to retrieve 
.br
\fIdata\fP data to post along 
.br
\fIlen\fP length of the file in bytes. set to '0' for autodetection 
.br
\fIcustomheader\fP specify custom HTTP header (or NULL for default) Multiple header elements can be passed separating them with '\\r\\n' 
.br
\fIcallback\fP specify the callback function 
.br
\fIcallback_data\fP specify data to pass to the callback function 
.br
\fIhttpMethod\fP specify http verb ('GET'/'POST'/'PUT'/'DELETE') to be used. 
.RE
.PP
\fBReturns:\fP
.RS 4
returned HTTP reply or NULL on error 
.RE
.PP

.SS "char* oauth_serialize_url (int argc, int start, char ** argv)"
.PP
build a url query string from an array. \fBParameters:\fP
.RS 4
\fIargc\fP the total number of elements in the array 
.br
\fIstart\fP element in the array at which to start concatenating. 
.br
\fIargv\fP parameter-array to concatenate. 
.RE
.PP
\fBReturns:\fP
.RS 4
url string needs to be freed by the caller. 
.RE
.PP

.SS "char* oauth_serialize_url_parameters (int argc, char ** argv)"
.PP
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.
.PP
\fBParameters:\fP
.RS 4
\fIargc\fP the total number of elements in the array 
.br
\fIargv\fP parameter-array to concatenate. 
.RE
.PP
\fBReturns:\fP
.RS 4
url string needs to be freed by the caller. 
.RE
.PP

.SS "char* oauth_serialize_url_sep (int argc, int start, char ** argv, char * sep, int mod)"
.PP
encode query parameters from an array. \fBParameters:\fP
.RS 4
\fIargc\fP the total number of elements in the array 
.br
\fIstart\fP element in the array at which to start concatenating. 
.br
\fIargv\fP parameter-array to concatenate. 
.br
\fIsep\fP separator for parameters (usually '&') 
.br
\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). 
.RE
.PP
\fBReturns:\fP
.RS 4
url string needs to be freed by the caller. 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/oauthtest2.c\fP.
.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)"\fBDeprecated\fP
.RS 4
Use \fBoauth_sign_array2()\fP instead.
.RE
.PP

.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)"
.PP
same as /ref oauth_sign_url with the url already split into parameter array \fBParameters:\fP
.RS 4
\fIargcp\fP pointer to array length int 
.br
\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.
.br
\fIpostargs\fP This parameter points to an area where the return value is stored. If 'postargs' is NULL, no value is stored.
.br
\fImethod\fP specify the signature method to use. It is of type \fBOAuthMethod\fP and most likely \fBOA_HMAC\fP.
.br
\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.
.br
\fIc_key\fP consumer key 
.br
\fIc_secret\fP consumer secret 
.br
\fIt_key\fP token key 
.br
\fIt_secret\fP token secret
.RE
.PP
\fBReturns:\fP
.RS 4
the signed url or NULL if an error occurred. 
.RE
.PP

.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)"
.PP
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.
.PP
This allows 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.
.PP
\fBParameters:\fP
.RS 4
\fIargcp\fP pointer to array length int 
.br
\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.
.br
\fIpostargs\fP This parameter points to an area where the return value is stored. If 'postargs' is NULL, no value is stored.
.br
\fImethod\fP specify the signature method to use. It is of type \fBOAuthMethod\fP and most likely \fBOA_HMAC\fP.
.br
\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.
.br
\fIc_key\fP consumer key 
.br
\fIc_secret\fP consumer secret 
.br
\fIt_key\fP token key 
.br
\fIt_secret\fP token secret
.RE
.PP
\fBReturns:\fP
.RS 4
void 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/oauthtest2.c\fP.
.SS "char* oauth_sign_hmac_sha1 (const char * m, const char * k)"
.PP
returns base64 encoded HMAC-SHA1 signature for given message and key. both data and key need to be urlencoded.
.PP
the returned string needs to be freed by the caller
.PP
\fBParameters:\fP
.RS 4
\fIm\fP message to be signed 
.br
\fIk\fP key used for signing 
.RE
.PP
\fBReturns:\fP
.RS 4
signature string. 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/selftest_wiki.c\fP.
.SS "char* oauth_sign_hmac_sha1_raw (const char * m, const size_t ml, const char * k, const size_t kl)"
.PP
same as \fBoauth_sign_hmac_sha1\fP but allows to specify length of message and key (in case they contain null chars). \fBParameters:\fP
.RS 4
\fIm\fP message to be signed 
.br
\fIml\fP length of message 
.br
\fIk\fP key used for signing 
.br
\fIkl\fP length of key 
.RE
.PP
\fBReturns:\fP
.RS 4
signature string. 
.RE
.PP

.SS "char* oauth_sign_plaintext (const char * m, const char * k)"
.PP
returns plaintext signature for the given key. the returned string needs to be freed by the caller
.PP
\fBParameters:\fP
.RS 4
\fIm\fP message to be signed 
.br
\fIk\fP key used for signing 
.RE
.PP
\fBReturns:\fP
.RS 4
signature string 
.RE
.PP

.SS "char* oauth_sign_rsa_sha1 (const char * m, const char * k)"
.PP
returns RSA-SHA1 signature for given data. the returned signature needs to be freed by the caller.
.PP
\fBParameters:\fP
.RS 4
\fIm\fP message to be signed 
.br
\fIk\fP private-key PKCS and Base64-encoded 
.RE
.PP
\fBReturns:\fP
.RS 4
base64 encoded signature string. 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/selftest_wiki.c\fP.
.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)"\fBDeprecated\fP
.RS 4
Use \fBoauth_sign_url2()\fP instead.
.RE
.PP

.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)"
.PP
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.
.PP
both, the return value and (if given) 'postargs' need to be freed by the caller.
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP The request URL to be signed. append all GET or POST query-parameters separated by either '?' or '&' to this parameter.
.br
\fIpostargs\fP This parameter points to an area where the return value is stored. If 'postargs' is NULL, no value is stored.
.br
\fImethod\fP specify the signature method to use. It is of type \fBOAuthMethod\fP and most likely \fBOA_HMAC\fP.
.br
\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.
.br
\fIc_key\fP consumer key 
.br
\fIc_secret\fP consumer secret 
.br
\fIt_key\fP token key 
.br
\fIt_secret\fP token secret
.RE
.PP
\fBReturns:\fP
.RS 4
the signed url or NULL if an error occurred. 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/oauthbodyhash.c\fP, \fBtests/oauthexample.c\fP, and \fBtests/oauthtest.c\fP.
.SS "char* oauth_sign_xmpp (const char * xml, \fBOAuthMethod\fP method, const char * c_secret, const char * t_secret)"
.PP
xep-0235 - TODO 
.SS "int oauth_split_post_paramters (const char * url, char *** argv, short qesc)"
.PP
splits the given url into a parameter array. (see \fBoauth_serialize_url\fP and \fBoauth_serialize_url_parameters\fP for the reverse)
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP the url or query-string to parse. 
.br
\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. 
.br
\fIqesc\fP use query parameter escape (vs post-param-escape) - if set to 1 all '+' are treated as spaces ' '
.RE
.PP
\fBReturns:\fP
.RS 4
number of parameter(s) in array. 
.RE
.PP

.SS "int oauth_split_url_parameters (const char * url, char *** argv)"
.PP
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)
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP the url or query-string to parse; may be NULL 
.br
\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.
.RE
.PP
\fBReturns:\fP
.RS 4
number of parameter(s) in array. 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/oauthexample.c\fP, \fBtests/oauthtest.c\fP, and \fBtests/oauthtest2.c\fP.
.SS "int oauth_time_independent_equals (const char * a, const char * b)"
.PP
compare two strings in constant-time. wrapper to \fBoauth_time_independent_equals_n\fP which calls strlen() for each argument.
.PP
\fBParameters:\fP
.RS 4
\fIa\fP string to compare 
.br
\fIb\fP string to compare
.RE
.PP
returns 0 (false) if strings are not equal, and 1 (true) if strings are equal. 
.SS "int oauth_time_independent_equals_n (const char * a, const char * b, size_t len_a, size_t len_b)"
.PP
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
.RS 4
\fIa\fP string to compare 
.br
\fIb\fP string to compare 
.br
\fIlen_a\fP length of string a 
.br
\fIlen_b\fP length of string b
.RE
.PP
returns 0 (false) if strings are not equal, and 1 (true) if strings are equal. 
.SS "int oauth_time_indepenent_equals (const char * a, const char * b)"\fBDeprecated\fP
.RS 4
Use \fBoauth_time_independent_equals()\fP instead.
.RE
.PP

.SS "int oauth_time_indepenent_equals_n (const char * a, const char * b, size_t len_a, size_t len_b)"\fBDeprecated\fP
.RS 4
Use \fBoauth_time_independent_equals_n()\fP instead.
.RE
.PP

.SS "char* oauth_url_escape (const char * string)"
.PP
Escape 'string' according to RFC3986 and http://oauth.net/core/1.0/#encoding_parameters. \fBParameters:\fP
.RS 4
\fIstring\fP The data to be encoded 
.RE
.PP
\fBReturns:\fP
.RS 4
encoded string otherwise NULL The caller must free the returned string. 
.RE
.PP

.SS "char* oauth_url_unescape (const char * string, size_t * olen)"
.PP
Parse RFC3986 encoded 'string' back to unescaped version. \fBParameters:\fP
.RS 4
\fIstring\fP The data to be unescaped 
.br
\fIolen\fP unless NULL the length of the returned string is stored there. 
.RE
.PP
\fBReturns:\fP
.RS 4
decoded string or NULL The caller must free the returned string. 
.RE
.PP

.SS "int oauth_verify_rsa_sha1 (const char * m, const char * c, const char * s)"
.PP
verify RSA-SHA1 signature. returns the output of EVP_VerifyFinal() for a given message, cert/pubkey and signature.
.PP
\fBParameters:\fP
.RS 4
\fIm\fP message to be verified 
.br
\fIc\fP public-key or x509 certificate 
.br
\fIs\fP base64 encoded signature 
.RE
.PP
\fBReturns:\fP
.RS 4
1 for a correct signature, 0 for failure and \-1 if some other error occurred 
.RE
.PP

.PP
\fBExamples: \fP
.in +1c
\fBtests/selftest_wiki.c\fP.
.SH "Author"
.PP 
Generated automatically by Doxygen for OAuth library functions from the source code.