fix support for R16
Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/2ab4a24c Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/2ab4a24c Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/2ab4a24c Branch: refs/heads/import Commit: 2ab4a24c3f7db95b9ab43099ba1fa876a072e955 Parents: 1093051 Author: benoitc <[email protected]> Authored: Fri Jun 21 23:15:17 2013 +0200 Committer: benoitc <[email protected]> Committed: Fri Jun 21 23:15:17 2013 +0200 ---------------------------------------------------------------------- Emakefile | 1 - Makefile | 5 ----- rebar.config | 3 +++ src/oauth.erl | 8 +++++++- 4 files changed, 10 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/2ab4a24c/Emakefile ---------------------------------------------------------------------- diff --git a/Emakefile b/Emakefile deleted file mode 100644 index a961122..0000000 --- a/Emakefile +++ /dev/null @@ -1 +0,0 @@ -{"src/*", [debug_info, warn_unused_vars, warn_unused_import, {outdir, "ebin"}]}. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/2ab4a24c/Makefile ---------------------------------------------------------------------- diff --git a/Makefile b/Makefile deleted file mode 100644 index 09880ea..0000000 --- a/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: - @erl -make - -clean: - @rm -rf ebin/*.beam erl_crash.dump http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/2ab4a24c/rebar.config ---------------------------------------------------------------------- diff --git a/rebar.config b/rebar.config new file mode 100644 index 0000000..c839359 --- /dev/null +++ b/rebar.config @@ -0,0 +1,3 @@ +{erl_opts, [ + {platform_define, "^R15", "no_sha_hmac"} +]}. http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/2ab4a24c/src/oauth.erl ---------------------------------------------------------------------- diff --git a/src/oauth.erl b/src/oauth.erl index 64d5888..e05196a 100644 --- a/src/oauth.erl +++ b/src/oauth.erl @@ -15,6 +15,12 @@ -include_lib("public_key/include/public_key.hrl"). +-ifndef(no_sha_hmac). +-define(SHA_HMAC(Key, Data), crypto:hmac(sha, Key, Data)). +-else. +-define(SHA_HMAC(Key, Data), crypto:sha_mac(Key, Data)). +-endif. + get(URL, ExtraParams, Consumer) -> get(URL, ExtraParams, Consumer, "", ""). @@ -121,7 +127,7 @@ hmac_sha1_signature(HttpMethod, URL, Params, Consumer, TokenSecret) -> hmac_sha1_signature(BaseString, Consumer, TokenSecret) -> Key = uri_join([consumer_secret(Consumer), TokenSecret]), - base64:encode_to_string(crypto:sha_mac(Key, BaseString)). + base64:encode_to_string(?SHA_HMAC(Key, BaseString)). hmac_sha1_verify(Signature, HttpMethod, URL, Params, Consumer, TokenSecret) -> verify_in_constant_time(Signature, hmac_sha1_signature(HttpMethod, URL, Params, Consumer, TokenSecret)).
