Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated crypto APIs #39

Merged
merged 6 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
otp_version: ['26.1', '25.3', '24.3']
otp_version: ['26.2', '25.3']

steps:
- uses: actions/checkout@v4
Expand All @@ -40,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
otp_version: ['26.1', '25.3', '24.3']
otp_version: ['26.2', '25.3']
weppos marked this conversation as resolved.
Show resolved Hide resolved

needs:
- build
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
erlang 24.1
erlang 26.2.5.2
4 changes: 2 additions & 2 deletions include/dnssec_tests.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ test_sample_key(dsa, PrivKey, PubKey) ->
crypto:verify(dss, sha, Sample, Sig, PubKey);
test_sample_key(rsa, PrivKey, PubKey) ->
Sample = <<"1234">>,
Cipher = crypto:private_encrypt(rsa, Sample, PrivKey, rsa_pkcs1_padding),
Sample =:= crypto:public_decrypt(rsa, Cipher, PubKey, 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
26 changes: 15 additions & 11 deletions src/dnssec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,12 @@ sign_rrset(
Alg =:= ?DNS_ALG_RSASHA256 orelse
Alg =:= ?DNS_ALG_RSASHA512
->
crypto:private_encrypt(
crypto:sign(
rsa,
none,
BaseSigInput,
Key,
rsa_pkcs1_padding
[{rsa_padding, rsa_pkcs1_padding}]
)
end,
Data = Data0#dns_rrdata_rrsig{signature = Signature},
Expand Down Expand Up @@ -502,15 +503,18 @@ verify_rrsig(
Alg =:= ?DNS_ALG_RSASHA256 orelse
Alg =:= ?DNS_ALG_RSASHA512
->
SigPayload =
try
crypto:public_decrypt(
rsa, Sig, Key, rsa_pkcs1_padding
)
catch
error:decrypt_failed -> undefined
end,
SigInput =:= SigPayload;
try
crypto:verify(
rsa,
none,
SigInput,
Sig,
Key,
[{rsa_padding, rsa_pkcs1_padding}]
)
catch
error:decrypt_failed -> undefined
end;
(_) ->
false
end,
Expand Down