dnsimple / dns_erlang

Erlang DNS library.
Apache License 2.0
95 stars 25 forks source link

Failing test #14

Closed coreyhaines closed 6 years ago

coreyhaines commented 6 years ago

It appears that OTP20 deprecated crypto:sha/1 in favor of crypto:hash/2

when running make test

I get one failing test

dnssec:54: zone_test_ (Build Zone nsec3rsasha1-example)...*failed*
in function crypto:sha/1
  called as sha([<<1,42,1,42,5,119,105,108,100,49,20,110,115,...>>,<<"salt">>])
in call from dnssec:ih/4 (src/dnssec.erl, line 170)
in call from dnssec:'-gen_nsec3/8-fun-0-'/8 (src/dnssec.erl, line 148)
in call from lists:foldl/3 (lists.erl, line 1263)
in call from dnssec:gen_nsec3/8 (src/dnssec.erl, line 145)
in call from dnssec:'-zone_test_/0-fun-6-'/9 (include/dnssec_tests.hrl, line 95)
**error:undef
  output:<<"">>

Test Data

Investigation

Oddly, it appears that crypto:sha/1 is undefined when it is trying to be accessed: ih(?DNSSEC_NSEC3_ALG_SHA1, Salt, X, I) -> ih(fun crypto:sha/1, Salt, X, I). This creates an anonymous function #Fun<crypto.sha.1>. Then, when we try to execute it

ih(H, Salt, X, 0) when is_function(H, 1) -> H([X, Salt]);
ih(H, Salt, X, I) when is_function(H, 1) -> ih(H, Salt, H([X, Salt]), I - 1);
ih(?DNSSEC_NSEC3_ALG_SHA1, Salt, X, I) -> ih(fun crypto:sha/1, Salt, X, I).

It triggers the undef.

It appears that OTP20 deprecated crypto:sha/1 in favor of crypto:hash/2