diff options
author | Hans Nilsson <hans@erlang.org> | 2022-03-17 17:17:42 +0100 |
---|---|---|
committer | Hans Nilsson <hans@erlang.org> | 2022-03-21 06:54:30 +0100 |
commit | 0210f79b035d58d6dc798f9cded071fc6e8e7603 (patch) | |
tree | e907227c8d548b07fefeff98c6c0d338982fef60 /lib/public_key/src/public_key.erl | |
parent | b70d8ad394b85e453a263b4c0d4f267fd75629b3 (diff) | |
download | erlang-0210f79b035d58d6dc798f9cded071fc6e8e7603.tar.gz |
public_key: Fix compatibility with new error schema in crypto
Diffstat (limited to 'lib/public_key/src/public_key.erl')
-rw-r--r-- | lib/public_key/src/public_key.erl | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/public_key/src/public_key.erl b/lib/public_key/src/public_key.erl index d41d4ed7ba..14b6043286 100644 --- a/lib/public_key/src/public_key.erl +++ b/lib/public_key/src/public_key.erl @@ -829,7 +829,12 @@ sign(DigestOrPlainText, DigestType, Key, Options) -> badarg -> erlang:error(badarg, [DigestOrPlainText, DigestType, Key, Options]); {Algorithm, CryptoKey} -> - crypto:sign(Algorithm, DigestType, DigestOrPlainText, CryptoKey, Options) + 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 end. %%-------------------------------------------------------------------- @@ -859,7 +864,12 @@ verify(DigestOrPlainText, DigestType, Signature, Key, Options) when is_binary(Si badarg -> erlang:error(badarg, [DigestOrPlainText, DigestType, Signature, Key, Options]); {Algorithm, CryptoKey} -> - crypto:verify(Algorithm, DigestType, DigestOrPlainText, Signature, CryptoKey, Options) + 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 end; verify(_,_,_,_,_) -> %% If Signature is a bitstring and not a binary we know already at this |