You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2021/05/14 06:10:28 UTC

[couchdb] branch erlang-24-support updated (a7ed1dc -> 735ab65)

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a change to branch erlang-24-support
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


 discard a7ed1dc  [wip] erlang 24 support
     new 735ab65  Erlang 24 support

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (a7ed1dc)
            \
             N -- N -- N   refs/heads/erlang-24-support (735ab65)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:

[couchdb] 01/01: Erlang 24 support

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch erlang-24-support
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 735ab654ca13b1c3e8c0f8e24026cdda082a6a9b
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Thu May 13 02:21:36 2021 -0400

    Erlang 24 support
    
    The patch is mostly about switching crypto functions to use the
    new ones such as:
    
    ```
    crypto:hmac(Alg, Key, Message) -> crypto:mac(hmac, Alg, Key, Message)
    ```
    
    To simplfy Erlang 24 support, in which some crypto functions have
    been removed, bump the minimum version was bumped to 22.
    
    The other fixes in dependencies:
    
      * Bumped meck to 0.9.2. New meck from upstream supports Erlang
        24. Also required bumping folsom since it depends on meck
    
      * Example in passage module would not compile, so commented out
      the parse transform. Required bumping jaeger passage since it
      depends on passage
    
    There are some warnings emitted during compilation about
    re-binding the `_Persist` variable in config calls in testsb test
    seems to pass.
---
 rebar.config.script                | 10 +++++-----
 src/couch/src/couch_hotp.erl       |  2 +-
 src/couch/src/couch_httpd_auth.erl |  6 +++---
 src/couch/src/couch_passwords.erl  |  4 ++--
 src/jwtf/src/jwtf.erl              |  4 ++--
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/rebar.config.script b/rebar.config.script
index 2149182..4dc9882 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -149,16 +149,16 @@ DepDescs = [
 {fauxton,          {url, "https://github.com/apache/couchdb-fauxton"},
                    {tag, "v1.2.6"}, [raw]},
 %% Third party deps
-{folsom,           "folsom",           {tag, "CouchDB-0.8.3"}},
+{folsom,           "folsom",           {tag, "CouchDB-0.8.4"}},
 {hyper,            "hyper",            {tag, "CouchDB-2.2.0-6"}},
 {ibrowse,          "ibrowse",          {tag, "CouchDB-4.4.2-2"}},
-{jaeger_passage,   "jaeger-passage",   {tag, "CouchDB-0.1.14-2"}},
+{jaeger_passage,   "jaeger-passage",   {tag, "CouchDB-0.1.14-4"}},
 {jiffy,            "jiffy",            {tag, "CouchDB-1.0.5-1"}},
 {local,            "local",            {tag, "0.2.1"}},
 {mochiweb,         "mochiweb",         {tag, "v2.20.0"}},
-{meck,             "meck",             {tag, "0.8.8"}},
+{meck,             "meck",             {tag, "0.9.2"}},
 {recon,            "recon",            {tag, "2.5.0"}},
-{passage,          "passage",          {tag, "0.2.6"}},
+{passage,          "passage",          {tag, "CouchDB-0.2.6-1"}},
 {thrift_protocol,  "thrift-protocol",  {tag, "0.1.5"}}
 ].
 
@@ -192,7 +192,7 @@ ErlOpts = case os:getenv("ERL_OPTS") of
 end.
 
 AddConfig = [
-    {require_otp_vsn, "21|22|23"},
+    {require_otp_vsn, "22|23|24"},
     {deps_dir, "src"},
     {deps, lists:map(MakeDep, DepDescs ++ OptionalDeps)},
     {sub_dirs, SubDirs},
diff --git a/src/couch/src/couch_hotp.erl b/src/couch/src/couch_hotp.erl
index 9a620fa..2807599 100644
--- a/src/couch/src/couch_hotp.erl
+++ b/src/couch/src/couch_hotp.erl
@@ -16,7 +16,7 @@
 
 generate(Alg, Key, Counter, OutputLen)
   when is_atom(Alg), is_binary(Key), is_integer(Counter), is_integer(OutputLen) ->
-    Hmac = crypto:hmac(Alg, Key, <<Counter:64>>),
+    Hmac = crypto:mac(hmac, Alg, Key, <<Counter:64>>),
     Offset = binary:last(Hmac) band 16#f,
     Code =
         ((binary:at(Hmac, Offset) band 16#7f) bsl 24) +
diff --git a/src/couch/src/couch_httpd_auth.erl b/src/couch/src/couch_httpd_auth.erl
index b740220..511e0b3 100644
--- a/src/couch/src/couch_httpd_auth.erl
+++ b/src/couch/src/couch_httpd_auth.erl
@@ -176,7 +176,7 @@ proxy_auth_user(Req) ->
                         undefined ->
                             Req#httpd{user_ctx=#user_ctx{name=?l2b(UserName), roles=Roles}};
                         Secret ->
-                            ExpectedToken = couch_util:to_hex(crypto:hmac(sha, Secret, UserName)),
+                            ExpectedToken = couch_util:to_hex(crypto:mac(hmac, sha, Secret, UserName)),
                             case header_value(Req, XHeaderToken) of
                                 Token when Token == ExpectedToken ->
                                     Req#httpd{user_ctx=#user_ctx{name=?l2b(UserName),
@@ -263,7 +263,7 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req, AuthModule) ->
             {ok, UserProps, _AuthCtx} ->
                 UserSalt = couch_util:get_value(<<"salt">>, UserProps, <<"">>),
                 FullSecret = <<Secret/binary, UserSalt/binary>>,
-                ExpectedHash = crypto:hmac(sha, FullSecret, User ++ ":" ++ TimeStr),
+                ExpectedHash = crypto:mac(hmac, sha, FullSecret, User ++ ":" ++ TimeStr),
                 Hash = ?l2b(HashStr),
                 Timeout = list_to_integer(
                     config:get("couch_httpd_auth", "timeout", "600")),
@@ -315,7 +315,7 @@ cookie_auth_header(_Req, _Headers) -> [].
 
 cookie_auth_cookie(Req, User, Secret, TimeStamp) ->
     SessionData = User ++ ":" ++ erlang:integer_to_list(TimeStamp, 16),
-    Hash = crypto:hmac(sha, Secret, SessionData),
+    Hash = crypto:mac(hmac, sha, Secret, SessionData),
     mochiweb_cookies:cookie("AuthSession",
         couch_util:encodeBase64Url(SessionData ++ ":" ++ ?b2l(Hash)),
         [{path, "/"}] ++ cookie_scheme(Req) ++ max_age() ++ cookie_domain() ++ same_site()).
diff --git a/src/couch/src/couch_passwords.erl b/src/couch/src/couch_passwords.erl
index baf78f5..04a0d6d 100644
--- a/src/couch/src/couch_passwords.erl
+++ b/src/couch/src/couch_passwords.erl
@@ -114,12 +114,12 @@ pbkdf2(_Password, _Salt, Iterations, _BlockIndex, Iteration, _Prev, Acc)
     when Iteration > Iterations ->
     Acc;
 pbkdf2(Password, Salt, Iterations, BlockIndex, 1, _Prev, _Acc) ->
-    InitialBlock = crypto:hmac(sha, Password,
+    InitialBlock = crypto:mac(hmac, sha, Password,
         <<Salt/binary,BlockIndex:32/integer>>),
     pbkdf2(Password, Salt, Iterations, BlockIndex, 2,
         InitialBlock, InitialBlock);
 pbkdf2(Password, Salt, Iterations, BlockIndex, Iteration, Prev, Acc) ->
-    Next = crypto:hmac(sha, Password, Prev),
+    Next = crypto:mac(hmac, sha, Password, Prev),
     pbkdf2(Password, Salt, Iterations, BlockIndex, Iteration + 1,
                    Next, crypto:exor(Next, Acc)).
 
diff --git a/src/jwtf/src/jwtf.erl b/src/jwtf/src/jwtf.erl
index a0bbf1f..b42e08e 100644
--- a/src/jwtf/src/jwtf.erl
+++ b/src/jwtf/src/jwtf.erl
@@ -65,7 +65,7 @@ encode(Header = {HeaderProps}, Claims, Key) ->
             {public_key, Algorithm} ->
                 public_key:sign(Message, Algorithm, Key);
             {hmac, Algorithm} ->
-                crypto:hmac(Algorithm, Key, Message)
+                crypto:mac(hmac, Algorithm, Key, Message)
         end,
         EncodedSignatureOrMac = b64url:encode(SignatureOrMac),
         {ok, <<Message/binary, $., EncodedSignatureOrMac/binary>>}
@@ -290,7 +290,7 @@ public_key_verify(Algorithm, Message, Signature, PublicKey) ->
 
 
 hmac_verify(Algorithm, Message, HMAC, SecretKey) ->
-    case crypto:hmac(Algorithm, SecretKey, Message) of
+    case crypto:mac(hmac, Algorithm, SecretKey, Message) of
         HMAC ->
             ok;
         _ ->