Skip to content

Commit

Permalink
No digest algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide committed Oct 6, 2024
1 parent 3384688 commit 092d717
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
5 changes: 2 additions & 3 deletions include/dnssec_tests.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,8 @@ test_sample_key(dsa, PrivKey, PubKey) ->
crypto:verify(dss, sha, Sample, Sig, PubKey);
test_sample_key(rsa, PrivKey, PubKey) ->
Sample = <<"1234">>,
Signature = crypto:sign(rsa, sha, Sample, PrivKey, [{rsa_padding, rsa_pkcs1_padding}]),
crypto:verify(rsa, sha, Sample, Signature, PubKey, [{rsa_padding, rsa_pkcs1_padding}]).

Cipher = crypto:sign(rsa, none, Sample, PrivKey, [{rsa_padding, rsa_pkcs1_padding}]),
true =:= crypto:verify(rsa, none, Sample, Cipher, PubKey, [{rsa_padding, rsa_pkcs1_padding}]).

dnskey_pubkey_gen_test_() ->
[
Expand Down
14 changes: 7 additions & 7 deletions src/dnssec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ sign_rrset(
->
crypto:sign(
rsa,
dns_algo_to_digest_type(Alg),
none,
BaseSigInput,
Key,
[{rsa_padding, rsa_pkcs1_padding}]
Expand Down Expand Up @@ -505,7 +505,12 @@ verify_rrsig(
->
try
crypto:verify(
rsa, dns_algo_to_digest_type(Alg), SigInput, Sig, Key, [{rsa_padding, rsa_pkcs1_padding}]
rsa,
none,
SigInput,
Sig,
Key,
[{rsa_padding, rsa_pkcs1_padding}]
)
catch
error:decrypt_failed -> undefined
Expand All @@ -517,11 +522,6 @@ verify_rrsig(
)
end.

dns_algo_to_digest_type(?DNS_ALG_NSEC3RSASHA1) -> sha;
dns_algo_to_digest_type(?DNS_ALG_RSASHA1) -> sha;
dns_algo_to_digest_type(?DNS_ALG_RSASHA256) -> sha256;
dns_algo_to_digest_type(?DNS_ALG_RSASHA512) -> sha512.

build_sig_input(
SignersName,
KeyTag,
Expand Down

0 comments on commit 092d717

Please sign in to comment.