oauth.h(3)

๐Ÿ“ฆ
version 1.0.3 ยท 2 versions
, in alpine 3.24, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0

๐ŸŽ€ oauth.h(3) ๐ŸŽ€

okay bestie, this is the OAuth library functions header โ€” oauth.h(3), no cap. Itโ€™s giving OAuth.net implementation in POSIX-C, and it has a lot of function signatures. Buckle up, weโ€™re reading the whole thing. ๐Ÿ’…


๐Ÿ’– NAME ๐Ÿ’–

oauth.h โ€” OAuth.net implementation in POSIX-C.


โœจ SYNOPSIS โœจ

๐ŸŒธ Enumerations ๐ŸŒธ

enum OAuthMethod { OA_HMAC =0, OA_RSA, OA_PLAINTEXT }

signature method to used for signing the request. (yes, โ€œto usedโ€ โ€” exact wording, bestie, we donโ€™t fix the headerโ€™s grammar)

๐Ÿฆ‹ Functions ๐Ÿฆ‹

  • char * oauth_encode_base64 (int size, const unsigned char *src) โ€” Base64 encode and return size data in 'src'.
  • int oauth_decode_base64 (unsigned char *dest, const char *src) โ€” Decode the base64 encoded string 'src' into the memory pointed to by 'dest'.
  • char * oauth_url_escape (const char *string) โ€” Escape 'string' according to RFC3986 and http://oauth.net/core/1.0/#encoding_parameters.
  • char * oauth_url_unescape (const char *string, size_t *olen) โ€” Parse RFC3986 encoded 'string' back to unescaped version.
  • char * oauth_sign_hmac_sha1 (const char *m, const char *k) โ€” returns base64 encoded HMAC-SHA1 signature for given message and key.
  • char * oauth_sign_hmac_sha1_raw (const char *m, const size_t ml, const char *k, const size_t kl) โ€” same as oauth_sign_hmac_sha1 but allows one to specify length of message and key (in case they contain null chars).
  • char * oauth_sign_plaintext (const char *m, const char *k) โ€” returns plaintext signature for the given key.
  • char * oauth_sign_rsa_sha1 (const char *m, const char *k) โ€” returns RSA-SHA1 signature for given data.
  • int oauth_verify_rsa_sha1 (const char *m, const char *c, const char *s) โ€” verify RSA-SHA1 signature.
  • char * oauth_catenc (int len,...) โ€” url-escape strings and concatenate with '&' separator.
  • int oauth_split_url_parameters (const char *url, char ***argv) โ€” splits the given url into a parameter array.
  • int oauth_split_post_paramters (const char *url, char ***argv, short qesc) โ€” splits the given url into a parameter array. (yes, paramters โ€” typo is canon, keep it ๐Ÿซถ)
  • char * oauth_serialize_url (int argc, int start, char **argv) โ€” build a url query string from an array.
  • char * oauth_serialize_url_sep (int argc, int start, char **argv, char *sep, int mod) โ€” encode query parameters from an array.
  • char * oauth_serialize_url_parameters (int argc, char **argv) โ€” build a query parameter string from an array.
  • char * oauth_gen_nonce () โ€” generate a random string between 15 and 32 chars length and return a pointer to it.
  • int oauth_cmpstringp (const void *p1, const void *p2) โ€” string compare function for oauth parameters.
  • int oauth_param_exists (char **argv, int argc, char *key) โ€” search array for parameter key.
  • void oauth_add_param_to_array (int *argcp, char ***argvp, const char *addparam) โ€” add query parameter to array
  • void oauth_free_array (int *argcp, char ***argvp) โ€” free array args
  • int oauth_time_independent_equals_n (const char *a, const char *b, size_t len_a, size_t len_b) โ€” 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/ )
  • int oauth_time_indepenent_equals_n (const char *a, const char *b, size_t len_a, size_t len_b) attribute_deprecated โ€” deprecated, and yes it really says indepenent โ€” exact spelling, bestie.
  • int oauth_time_independent_equals (const char *a, const char *b) โ€” compare two strings in constant-time.
  • int oauth_time_indepenent_equals (const char *a, const char *b) attribute_deprecated โ€” deprecated version, typo included, no extra description in the original.
  • char * oauth_sign_url2 (const char *url, char **postargs, OAuthMethod method, const char *http_method, const char *c_key, const char *c_secret, const char *t_key, const char *t_secret) โ€” calculate OAuth-signature for a given HTTP request URL, parameters and oauth-tokens.
  • char * oauth_sign_url (const char *url, char **postargs, OAuthMethod method, const char *c_key, const char *c_secret, const char *t_key, const char *t_secret) attribute_deprecated โ€” deprecated, no extra description given.
  • void oauth_sign_array2_process (int *argcp, char ***argvp, char **postargs, OAuthMethod method, const char *http_method, const char *c_key, const char *c_secret, const char *t_key, const char *t_secret) โ€” the back-end behind by /ref oauth_sign_array2.
  • char * oauth_sign_array2 (int *argcp, char ***argvp, char **postargs, OAuthMethod method, const char *http_method, const char *c_key, const char *c_secret, const char *t_key, const char *t_secret) โ€” same as /ref oauth_sign_url with the url already split into parameter array
  • char * oauth_sign_array (int *argcp, char ***argvp, char **postargs, OAuthMethod method, const char *c_key, const char *c_secret, const char *t_key, const char *t_secret) attribute_deprecated โ€” deprecated, no extra description given.
  • char * oauth_body_hash_file (char *filename) โ€” calculate body hash (sha1sum) of given file and return a oauth_body_hash=xxxx parameter to be added to the request.
  • char * oauth_body_hash_data (size_t length, const char *data) โ€” calculate body hash (sha1sum) of given data and return a oauth_body_hash=xxxx parameter to be added to the request.
  • char * oauth_body_hash_encode (size_t len, unsigned char *digest) โ€” base64 encode digest, free it and return a URL parameter with the oauth_body_hash.
  • char * oauth_sign_xmpp (const char *xml, OAuthMethod method, const char *c_secret, const char *t_secret) โ€” xep-0235 - TODO
  • char * oauth_http_get (const char *u, const char *q) attribute_deprecated โ€” do a HTTP GET request, wait for it to finish and return the content of the reply.
  • char * oauth_http_get2 (const char *u, const char *q, const char *customheader) attribute_deprecated โ€” do a HTTP GET request, wait for it to finish and return the content of the reply.
  • char * oauth_http_post (const char *u, const char *p) attribute_deprecated โ€” do a HTTP POST request, wait for it to finish and return the content of the reply.
  • char * oauth_http_post2 (const char *u, const char *p, const char *customheader) attribute_deprecated โ€” do a HTTP POST request, wait for it to finish and return the content of the reply.
  • char * oauth_post_file (const char *u, const char *fn, const size_t len, const char *customheader) attribute_deprecated โ€” http post raw data from file.
  • char * oauth_post_data (const char *u, const char *data, size_t len, const char *customheader) attribute_deprecated โ€” http post raw data the returned string needs to be freed by the caller (requires libcurl)
  • char * oauth_post_data_with_callback (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 โ€” http post raw data, with callback.
  • char * oauth_send_data (const char *u, const char *data, size_t len, const char *customheader, const char *httpMethod) attribute_deprecated โ€” http send raw data.
  • char * oauth_send_data_with_callback (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 โ€” http post raw data, with callback.

๐Ÿ’– Detailed Description ๐Ÿ’–

OAuth.net implementation in POSIX-C.

Author: Robin Gareus robin@gareus.org

Copyright 2007-2014 Robin Gareus robin@gareus.org

okay, legal bit โ€” bestie, do not edit licenses. Here it is, verbatim, because thatโ€™s the vibe and also the law:

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: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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.

Definition in file oauth.h.


๐Ÿฆ‹ Enumeration Type Documentation ๐Ÿฆ‹

enum OAuthMethod

signature method to used for signing the request.

Enumerator:

  • OA_HMAC โ€” use HMAC-SHA1 request signing method
  • OA_RSA โ€” use RSA signature
  • OA_PLAINTEXT โ€” use plain text signature (for testing only)

Definition at line 66 of file oauth.h.


๐Ÿ’œ Function Documentation ๐Ÿ’œ

โญ void oauth_add_param_to_array (int * argcp, char *** argvp, const char * addparam)

add query parameter to array

Parameters:

  • argcp โ€” pointer to array length int
  • argvp โ€” pointer to array values
  • addparam โ€” parameter to add (eg. 'foo=bar')

โญ char* oauth_body_hash_data (size_t length, const char * data)

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 oauth_catenc.

see http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html

Parameters:

  • length โ€” length of the data parameter in bytes
  • data โ€” to calculate the hash for

Returns: URL oauth_body_hash parameter string

Examples: tests/oauthbodyhash.c.


โญ char* oauth_body_hash_encode (size_t len, unsigned char * digest)

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 oauth_catenc.

Parameters:

  • len โ€” length of the digest to encode
  • digest โ€” hash value to encode

Returns: URL oauth_body_hash parameter string


โญ char* oauth_body_hash_file (char * filename)

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.

see http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html

Parameters:

  • filename โ€” the filename to calculate the hash for

Returns: URL oauth_body_hash parameter string

Examples: tests/oauthbodyhash.c.


โญ char* oauth_catenc (int len, ...)

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 *)

Parameters:

  • len โ€” the number of arguments to follow this parameter

Returns: pointer to memory holding the concatenated strings โ€” needs to be xfree(d) by the caller. or NULL in case we ran out of memory. ๐Ÿ’œ


int oauth_cmpstringp (const void * p1, const void * p2)

okay so this is the string-compare function for oauth parameters ๐ŸŽ€ โ€” you use it with qsort, and you literally need it to normalize request parameters. it's giving "sorting my life out" energy. see http://oauth.net/core/1.0/#anchor14 for the whole vibe.

Examples: tests/oauthexample.c, tests/oauthtest.c, and tests/oauthtest2.c.


int oauth_decode_base64 (unsigned char * dest, const char * src)

Decode the base64 encoded string src into the memory pointed to by dest. ๐Ÿงš

Parameters:

  • dest โ€” Pointer to memory for holding the decoded string. Must be large enough to receive the decoded string. (yes bestie, large enough โ€” it's not gonna grow for you ๐Ÿ’€)
  • src โ€” A base64 encoded string.

Returns: the length of the decoded string if decode succeeded, otherwise 0. ๐Ÿ˜ญ


char* oauth_encode_base64 (int size, const unsigned char * src)

Base64 encode and return size data in src. The caller must free the returned string. ๐Ÿซถ

Parameters:

  • size โ€” The size of the data in src
  • src โ€” The data to be base64 encode

Returns: encoded string otherwise NULL โœจ


void oauth_free_array (int * argcp, char *** argvp)

free array args ๐Ÿ’…

Parameters:

  • argcp โ€” pointer to array length int
  • argvp โ€” pointer to array values to be xfree()d

Examples: tests/oauthtest2.c.


char* oauth_gen_nonce ()

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. ๐ŸŽฒ nonce nonce nonce, iconic behavior.

Returns: zero terminated random string. ๐Ÿ”ฅ


char* oauth_http_get (const char * u, const char * q)

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) ๐ŸŒˆ

If compiled without libcurl this function calls a command-line executable defined in the environment variable OAUTH_HTTP_GET_CMD โ€” it defaults to curl -sA 'liboauth-agent/0.1' '%u' where %u is replaced with the URL and query parameters.

bash & wget example:

export OAUTH_HTTP_CMD='wget -q -U 'liboauth-agent/0.1' '%u' '
โš ๏ธ 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.. ๐Ÿ’€ (the double period is theirs, not mine)
๐Ÿ“ NOTE: u and q are just concatenated with a '?' in between, unless q is NULL. in which case only u will be used.

Parameters:

  • u โ€” base url to get
  • q โ€” query string to send along with the HTTP request or NULL.

Returns: 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. ๐ŸŒธ

Deprecated: use libcurl โ€” http://curl.haxx.se/libcurl/c/

Examples: tests/oauthexample.c, and tests/oauthtest.c.


char* oauth_http_get2 (const char * u, const char * q, const char * customheader)

do a HTTP GET request, wait for it to finish and return the content of the reply. (requires libcurl) โญ

This is equivalent to oauth_http_get but allows one to specify a custom HTTP header and has no support for commandline-curl. no wget bestie, it's curl only now ๐Ÿ’…

If liboauth is compiled without libcurl this function always returns NULL. ๐Ÿ˜ญ

Parameters:

  • u โ€” base url to get
  • q โ€” query string to send along with the HTTP request or NULL.
  • customheader โ€” specify custom HTTP header (or NULL for none). Multiple header elements can be passed separating them with '\r\n'

Returns: 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. ๐Ÿฆ‹

Deprecated: use libcurl โ€” http://curl.haxx.se/libcurl/c/

Examples: tests/oauthtest2.c.


char* oauth_http_post (const char * u, const char * p)

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) ๐Ÿ“ฎ

If compiled without libcurl this function calls a command-line executable defined in the environment variable OAUTH_HTTP_CMD โ€” it defaults to curl -sA 'liboauth-agent/0.1' -d '%p' '%u' where %p is replaced with the postargs and %u is replaced with the URL.

bash & wget example:

export OAUTH_HTTP_CMD='wget -q -U 'liboauth-agent/0.1' –post-data='%p' '%u' '
๐Ÿ“ 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. ๐Ÿงช
โš ๏ธ 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..

Parameters:

  • u โ€” url to query
  • p โ€” postargs to send along with the HTTP request.

Returns: replied content from HTTP server. needs to be freed by caller. ๐Ÿซถ

Deprecated: use libcurl โ€” http://curl.haxx.se/libcurl/c/

Examples: tests/oauthexample.c, and tests/oauthtest.c.


char* oauth_http_post2 (const char * u, const char * p, const char * customheader)

do a HTTP POST request, wait for it to finish and return the content of the reply. (requires libcurl) ๐ŸŽ€

It's equivalent to oauth_http_post, but offers the possibility to specify a custom HTTP header and has no support for commandline-curl. again: no wget, only curl, iykyk ๐Ÿ’…

If liboauth is compiled without libcurl this function always returns NULL.

Parameters:

  • u โ€” url to query
  • p โ€” postargs to send along with the HTTP request.
  • customheader โ€” specify custom HTTP header (or NULL for none). Multiple header elements can be passed separating them with '\r\n'

Returns: replied content from HTTP server. needs to be freed by caller. ๐Ÿ’–

Deprecated: use libcurl โ€” http://curl.haxx.se/libcurl/c/


int oauth_param_exists (char ** argv, int argc, char * key)

search array for parameter key. ๐Ÿ”

Parameters:

  • argv โ€” length of array to search
  • argc โ€” parameter array to search
  • key โ€” key of parameter to check.

(yes bestie, argv is the length and argc is the array here โ€” that's literally how it's documented, not me being chaotic ๐Ÿ™ˆ)

Returns: FALSE (0) if array does not contain a parameter with given key, TRUE (1) otherwise. โœ…


char* oauth_post_data (const char * u, const char * data, size_t len, const char * customheader)

http post raw data. the returned string needs to be freed by the caller (requires libcurl) ๐Ÿงš see dislaimer: oauth_http_post (their spelling, i'm just the messenger ๐Ÿ˜ญ)

Parameters:

  • u โ€” url to retrieve
  • data โ€” data to post
  • len โ€” length of the data in bytes.
  • customheader โ€” specify custom HTTP header (or NULL for default). Multiple header elements can be passed separating them with '\r\n'

Returns: returned HTTP reply or NULL on error ๐Ÿ’€

Deprecated: use libcurl โ€” http://curl.haxx.se/libcurl/c/

Examples: tests/oauthbodyhash.c.


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)

http post raw data, with callback. the returned string needs to be freed by the caller (requires libcurl) ๐Ÿ”ฅ

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. ๐Ÿ‘‘

Parameters:

  • u โ€” url to retrieve
  • data โ€” data to post along
  • len โ€” length of the file in bytes. set to '0' for autodetection
  • customheader โ€” specify custom HTTP header (or NULL for default). Multiple header elements can be passed separating them with '\r\n'
  • callback โ€” specify the callback function
  • callback_data โ€” specify data to pass to the callback function

Returns: returned HTTP reply or NULL on error ๐ŸŒˆ

Deprecated: use libcurl โ€” http://curl.haxx.se/libcurl/c/


char* oauth_post_file (const char * u, const char * fn, const size_t len, const char * customheader)

http post raw data from file. the returned string needs to be freed by the caller (requires libcurl) ๐Ÿ“

see dislaimer: oauth_http_post

Parameters:

  • u โ€” url to retrieve
  • fn โ€” filename of the file to post along
  • len โ€” length of the file in bytes. set to '0' for autodetection
  • customheader โ€” specify custom HTTP header (or NULL for default). Multiple header elements can be passed separating them with '\r\n'

Returns: returned HTTP reply or NULL on error ๐Ÿ’œ

Deprecated: use libcurl โ€” http://curl.haxx.se/libcurl/c/


char* oauth_send_data (const char * u, const char * data, size_t len, const char * customheader, const char * httpMethod)

http send raw data. similar to oauth_http_post but provides for specifying the HTTP request method. ๐Ÿš€ main character energy fr

the returned string needs to be freed by the caller (requires libcurl)

see dislaimer: oauth_http_post

Parameters:

  • u โ€” url to retrieve
  • data โ€” data to post
  • len โ€” length of the data in bytes.
  • customheader โ€” specify custom HTTP header (or NULL for default). Multiple header elements can be passed separating them with '\r\n'
  • httpMethod โ€” specify http verb ('GET'/'POST'/'PUT'/'DELETE') to be used. if httpMethod is NULL, a POST is executed.

Returns: returned HTTP reply or NULL on error โญ

Deprecated: use libcurl โ€” http://curl.haxx.se/libcurl/c/


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)

http post raw data, with callback. the returned string needs to be freed by the caller (requires libcurl) ๐ŸŽ€

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. ๐Ÿฆ‹

Parameters:

  • u โ€” url to retrieve
  • data โ€” data to post along
  • len โ€” length of the file in bytes. set to '0' for autodetection
  • customheader โ€” specify custom HTTP header (or NULL for default). Multiple header elements can be passed separating them with '\r\n'
  • callback โ€” specify the callback function
  • callback_data โ€” specify data to pass to the callback function
  • httpMethod โ€” specify http verb ('GET'/'POST'/'PUT'/'DELETE') to be used.

Returns: returned HTTP reply or NULL on error ๐ŸŒธ

Deprecated: use libcurl โ€” http://curl.haxx.se/libcurl/c/

๐ŸŒธ oauth_serialize_url ๐ŸŒธ

char* oauth_serialize_url (int argc, int start, char ** argv)

okay so this one builds a URL query string from an array. itโ€™s giving โ€œarray goes in, query string comes outโ€ energy, and honestly? slay.

Parameters:

  • argc โ€” the total number of elements in the array.
  • start โ€” element in the array at which to start concatenating.
  • argv โ€” parameter-array to concatenate.

Returns: the url string. It needs to be freed by the caller, bestie โ€” no memory leaks on our watch. ๐Ÿ’…


๐ŸŽ€ oauth_serialize_url_parameters ๐ŸŽ€

char* oauth_serialize_url_parameters (int argc, char ** argv)

build a query parameter string from an array. This function is a shortcut for oauth_serialize_url (argc, 1, argv). It strips the leading host/path, which is usually the first element when using oauth_split_url_parameters on an URL.

Parameters:

  • argc โ€” the total number of elements in the array.
  • argv โ€” parameter-array to concatenate.

Returns: the url string. It needs to be freed by the caller. ๐Ÿซถ


โœจ oauth_serialize_url_sep โœจ

char* oauth_serialize_url_sep (int argc, int start, char ** argv, char * sep, int mod)

encode query parameters from an array. this is the customizable-separator girlie.

Parameters:

  • argc โ€” the total number of elements in the array.
  • start โ€” element in the array at which to start concatenating.
  • argv โ€” parameter-array to concatenate.
  • sep โ€” separator for parameters (usually '&').
  • mod โ€” 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).

Returns: the url string. It needs to be freed by the caller. ๐Ÿ’–

Examples: tests/oauthtest2.c.


๐Ÿ’€ oauth_sign_array ๐Ÿ’€

char* oauth_sign_array (int * argcp, char *** argvp, char ** postargs, OAuthMethod method, const char * c_key, const char * c_secret, const char * t_key, const char * t_secret)
Deprecated โ€” use oauth_sign_array2() instead.

๐Ÿ‘‘ oauth_sign_array2 ๐Ÿ‘‘

char* oauth_sign_array2 (int * argcp, char *** argvp, char ** postargs, OAuthMethod method, const char * http_method, const char * c_key, const char * c_secret, const char * t_key, const char * t_secret)

same as /ref oauth_sign_url with the url already split into parameter array.

Parameters:

  • argcp โ€” pointer to array length int.
  • argvp โ€” 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.
  • postargs โ€” This parameter points to an area where the return value is stored. If postargs is NULL, no value is stored.
  • method โ€” specify the signature method to use. It is of type OAuthMethod and most likely OA_HMAC.
  • http_method โ€” 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.
  • c_key โ€” consumer key.
  • c_secret โ€” consumer secret.
  • t_key โ€” token key.
  • t_secret โ€” token secret.

Returns: the signed url or NULL if an error occurred.


๐Ÿฆ‹ oauth_sign_array2_process ๐Ÿฆ‹

void oauth_sign_array2_process (int * argcp, char *** argvp, char ** postargs, OAuthMethod method, const char * http_method, const char * c_key, const char * c_secret, const char * t_key, const char * t_secret)

this is the back-end behind /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.

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.

Parameters:

  • argcp โ€” pointer to array length int.
  • argvp โ€” 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.
  • postargs โ€” This parameter points to an area where the return value is stored. If postargs is NULL, no value is stored.
  • method โ€” specify the signature method to use. It is of type OAuthMethod and most likely OA_HMAC.
  • http_method โ€” 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.
  • c_key โ€” consumer key.
  • c_secret โ€” consumer secret.
  • t_key โ€” token key.
  • t_secret โ€” token secret.

Returns: void.

Examples: tests/oauthtest2.c.


๐Ÿ“ oauth_sign_hmac_sha1 ๐Ÿ“

char* oauth_sign_hmac_sha1 (const char * m, const char * k)

returns base64 encoded HMAC-SHA1 signature for given message and key. both data and key need to be urlencoded.

the returned string needs to be freed by the caller.

Parameters:

  • m โ€” message to be signed.
  • k โ€” key used for signing.

Returns: signature string.

Examples: tests/selftest_wiki.c.


๐ŸŒˆ oauth_sign_hmac_sha1_raw ๐ŸŒˆ

char* oauth_sign_hmac_sha1_raw (const char * m, const size_t ml, const char * k, const size_t kl)

same as oauth_sign_hmac_sha1 but allows one to specify length of message and key (in case they contain null chars).

Parameters:

  • m โ€” message to be signed.
  • ml โ€” length of message.
  • k โ€” key used for signing.
  • kl โ€” length of key.

Returns: signature string.


๐Ÿ’œ oauth_sign_plaintext ๐Ÿ’œ

char* oauth_sign_plaintext (const char * m, const char * k)

returns plaintext signature for the given key. the returned string needs to be freed by the caller.

Parameters:

  • m โ€” message to be signed.
  • k โ€” key used for signing.

Returns: signature string.


๐Ÿ”ฅ oauth_sign_rsa_sha1 ๐Ÿ”ฅ

char* oauth_sign_rsa_sha1 (const char * m, const char * k)

returns RSA-SHA1 signature for given data. the returned signature needs to be freed by the caller.

Parameters:

  • m โ€” message to be signed.
  • k โ€” private-key PKCS and Base64-encoded.

Returns: base64 encoded signature string.

Examples: tests/selftest_wiki.c.


๐Ÿ™ˆ oauth_sign_url ๐Ÿ™ˆ

char* oauth_sign_url (const char * url, char ** postargs, OAuthMethod method, const char * c_key, const char * c_secret, const char * t_key, const char * t_secret)
Deprecated โ€” use oauth_sign_url2() instead.

โญ oauth_sign_url2 โญ

char* oauth_sign_url2 (const char * url, char ** postargs, OAuthMethod method, const char * http_method, const char * c_key, const char * c_secret, const char * t_key, const char * t_secret)

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.

both, the return value and (if given) postargs need to be freed by the caller.

Parameters:

  • url โ€” The request URL to be signed. append all GET or POST query-parameters separated by either '?' or '&' to this parameter.
  • postargs โ€” This parameter points to an area where the return value is stored. If postargs is NULL, no value is stored.
  • method โ€” specify the signature method to use. It is of type OAuthMethod and most likely OA_HMAC.
  • http_method โ€” 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.
  • c_key โ€” consumer key.
  • c_secret โ€” consumer secret.
  • t_key โ€” token key.
  • t_secret โ€” token secret.

Returns: the signed url or NULL if an error occurred.

Examples: tests/oauthbodyhash.c, tests/oauthexample.c, and tests/oauthtest.c.


๐Ÿงš oauth_sign_xmpp ๐Ÿงš

char* oauth_sign_xmpp (const char * xml, OAuthMethod method, const char * c_secret, const char * t_secret)

xep-0235 - TODO. thatโ€™s literally it, bestie. ๐Ÿ’€


๐ŸŽ€ oauth_split_post_paramters ๐ŸŽ€

int oauth_split_post_paramters (const char * url, char *** argv, short qesc)

splits the given url into a parameter array. (see oauth_serialize_url and oauth_serialize_url_parameters for the reverse)

Parameters:

  • url โ€” the url or query-string to parse.
  • argv โ€” 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.
  • qesc โ€” use query parameter escape (vs post-param-escape) - if set to 1 all '+' are treated as spaces ' '.

Returns: number of parameter(s) in array.


๐Ÿ’– oauth_split_url_parameters ๐Ÿ’–

int oauth_split_url_parameters (const char * url, char *** argv)

splits the given url into a parameter array. (see oauth_serialize_url and oauth_serialize_url_parameters for the reverse) (see oauth_split_post_paramters for a more generic version)

Parameters:

  • url โ€” the url or query-string to parse; may be NULL.
  • argv โ€” 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.

Returns: number of parameter(s) in array.

Examples: tests/oauthexample.c, tests/oauthtest.c, and tests/oauthtest2.c.


๐Ÿ›ก๏ธ oauth_time_independent_equals ๐Ÿ›ก๏ธ

int oauth_time_independent_equals (const char * a, const char * b)

compare two strings in constant-time. wrapper to oauth_time_independent_equals_n which calls strlen() for each argument.

Parameters:

  • a โ€” string to compare.
  • b โ€” string to compare.

returns 0 (false) if strings are not equal, and 1 (true) if strings are equal.


๐Ÿ›ก๏ธ oauth_time_independent_equals_n ๐Ÿ›ก๏ธ

int oauth_time_independent_equals_n (const char * a, const char * b, size_t len_a, size_t len_b)

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/ )

Parameters:

  • a โ€” string to compare.
  • b โ€” string to compare.
  • len_a โ€” length of string a.
  • len_b โ€” length of string b.

returns 0 (false) if strings are not equal, and 1 (true) if strings are equal.


๐Ÿ’€ oauth_time_indepenent_equals ๐Ÿ’€

int oauth_time_indepenent_equals (const char * a, const char * b)
Deprecated โ€” use oauth_time_independent_equals() instead.

๐Ÿ’€ oauth_time_indepenent_equals_n ๐Ÿ’€

int oauth_time_indepenent_equals_n (const char * a, const char * b, size_t len_a, size_t len_b)
Deprecated โ€” use oauth_time_independent_equals_n() instead.

๐ŸŒธ oauth_url_escape ๐ŸŒธ

char* oauth_url_escape (const char * string)

Escape 'string' according to RFC3986 and http://oauth.net/core/1.0/#encoding_parameters.

Parameters:

  • string โ€” The data to be encoded.

Returns: encoded string otherwise NULL. The caller must free the returned string. ๐Ÿซถ


๐ŸŒˆ oauth_url_unescape ๐ŸŒˆ

char* oauth_url_unescape (const char * string, size_t * olen)

Parse RFC3986 encoded 'string' back to unescaped version.

Parameters:

  • string โ€” The data to be unescaped.
  • olen โ€” unless NULL the length of the returned string is stored there.

Returns: decoded string or NULL. The caller must free the returned string. โœจ

๐ŸŒˆ oauth_verify_rsa_sha1

int oauth_verify_rsa_sha1 (const char * m, const char * c, const char * s)

Okay bestie, this one is literally the RSA-SHA1 signature vibe check โœจ โ€” it verifies an RSA-SHA1 signature and returns the output of EVP_VerifyFinal() for a given message, cert/pubkey and signature. No cap.

Parameters:

  • m โ€” message to be verified ๐Ÿ’Œ
  • c โ€” public-key or x509 certificate ๐Ÿ”‘
  • s โ€” base64 encoded signature ๐ŸŽ€

Returns:

  • 1 โ€” correct signature, slay โœ…
  • 0 โ€” failure, iconic flop energy ๐Ÿ˜ญ
  • -1 โ€” some other error occurred, not the vibe ๐Ÿ’€

Examples:

  • tests/selftest_wiki.c โ€” go look, iykyk ๐Ÿซถ

๐Ÿ“ Author

This page was Generated automatically by Doxygen for OAuth library functions from the source code.


๐Ÿ’– Thatโ€™s the whole page, bestie โ€” brought to you by OAuth library functions, version 1.0.3, dated Thu Apr 17 2014, and filed under oauth.h(3). Periodt. ๐ŸŽ€