Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix support for R16

  • Loading branch information...
commit 2ab4a24c3f7db95b9ab43099ba1fa876a072e955 1 parent 1093051
@benoitc benoitc authored
Showing with 10 additions and 7 deletions.
  1. +0 −1  Emakefile
  2. +0 −5 Makefile
  3. +3 −0  rebar.config
  4. +7 −1 src/oauth.erl
View
1  Emakefile
@@ -1 +0,0 @@
-{"src/*", [debug_info, warn_unused_vars, warn_unused_import, {outdir, "ebin"}]}.
View
5 Makefile
@@ -1,5 +0,0 @@
-all:
- @erl -make
-
-clean:
- @rm -rf ebin/*.beam erl_crash.dump
View
3  rebar.config
@@ -0,0 +1,3 @@
+{erl_opts, [
+ {platform_define, "^R15", "no_sha_hmac"}
+]}.
View
8 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)).
Please sign in to comment.
Something went wrong with that request. Please try again.