Skip to content

Commit

Permalink
Merge branch 'ingela/public_key/do_not_hide_badarg_reason/OTP-19238' …
Browse files Browse the repository at this point in the history
…into maint

* ingela/public_key/do_not_hide_badarg_reason/OTP-19238:
  public_key: Do not hide crypto runtime exceptions
  • Loading branch information
IngelaAndin committed Sep 23, 2024
2 parents 918294d + dea1e88 commit 0ef5dd5
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions lib/public_key/src/public_key.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1213,12 +1213,7 @@ sign(DigestOrPlainText, DigestType, Key, Options) ->
{extern, Fun} when is_function(Fun) ->
Fun(DigestOrPlainText, DigestType, Options);
{Algorithm, CryptoKey} ->
try crypto:sign(Algorithm, DigestType, DigestOrPlainText, CryptoKey, Options)
catch %% Compatible with old error schema
error:{notsup,_,_} -> error(notsup);
error:{error,_,_} -> error(error);
error:{badarg,_,_} -> error(badarg)
end
crypto:sign(Algorithm, DigestType, DigestOrPlainText, CryptoKey, Options)
end.

%%--------------------------------------------------------------------
Expand Down Expand Up @@ -1257,12 +1252,7 @@ verify(DigestOrPlainText, DigestType, Signature, Key, Options) when is_binary(Si
badarg ->
erlang:error(badarg, [DigestOrPlainText, DigestType, Signature, Key, Options]);
{Algorithm, CryptoKey} ->
try crypto:verify(Algorithm, DigestType, DigestOrPlainText, Signature, CryptoKey, Options)
catch %% Compatible with old error schema
error:{notsup,_,_} -> error(notsup);
error:{error,_,_} -> error(error);
error:{badarg,_,_} -> error(badarg)
end
crypto:verify(Algorithm, DigestType, DigestOrPlainText, Signature, CryptoKey, Options)
end;
verify(_,_,_,_,_) ->
%% If Signature is a bitstring and not a binary we know already at this
Expand Down

0 comments on commit 0ef5dd5

Please sign in to comment.