summaryrefslogtreecommitdiff
path: root/lib/crypto/test/crypto_bench_SUITE.erl
diff options
context:
space:
mode:
authorHans Nilsson <hans@erlang.org>2021-02-18 18:05:40 +0100
committerHans Nilsson <hans@erlang.org>2021-02-18 18:05:40 +0100
commit4c3e95d7db09e859b204c06d724e69ce008da421 (patch)
treef345c10c693ebbee11716f3f1d6cd25a323368f2 /lib/crypto/test/crypto_bench_SUITE.erl
parent2698f5d3aa6d1e5d612f820460b1192789f028dc (diff)
downloaderlang-4c3e95d7db09e859b204c06d724e69ce008da421.tar.gz
crypto: Fix crypto_bench_SUITE for OTP-23
Diffstat (limited to 'lib/crypto/test/crypto_bench_SUITE.erl')
-rw-r--r--lib/crypto/test/crypto_bench_SUITE.erl44
1 files changed, 38 insertions, 6 deletions
diff --git a/lib/crypto/test/crypto_bench_SUITE.erl b/lib/crypto/test/crypto_bench_SUITE.erl
index ba1e830287..a54dae1ee4 100644
--- a/lib/crypto/test/crypto_bench_SUITE.erl
+++ b/lib/crypto/test/crypto_bench_SUITE.erl
@@ -186,8 +186,8 @@ run_cryptos(Cryptos, Config) ->
)
end
catch
- _:_ ->
- ct:pal("~p unsupported",[{Crypto,KeySize,BlockSize}])
+ _C:_E ->
+ ct:pal("~p unsupported ~p ~p",[{Crypto,KeySize,BlockSize},_C,_E])
end
|| Crypto <- Cryptos,
supported(Crypto)
@@ -226,30 +226,62 @@ funs({aead, {Type, Key, IV, AAD, Block}}) ->
fun(_) -> ok end}.
-data(aes_cbc=Type, KeySize, BlockSize) ->
+type(Type, Size) ->
+ Ciphers = ciphers(),
+ case lists:member(Type, Ciphers) of
+ true ->
+ Type;
+ false ->
+ case string:tokens(atom_to_list(Type), "_") of
+ [Family,Mode] ->
+ NewType = list_to_atom(lists:concat([Family,"_",Size,"_",Mode])),
+ case lists:member(NewType, Ciphers) of
+ true ->
+ NewType;
+ false ->
+ false
+ end;
+ _X ->
+ false
+ end
+ end.
+
+
+ciphers() ->
+ try crypto:supports(ciphers)
+ catch
+ _:_ -> proplists:get_value(ciphers, crypto:supports())
+ end.
+
+
+data(aes_cbc=Type0, KeySize, BlockSize) ->
Key = mk_bin(KeySize div 8),
IV = mk_bin(16),
Block = mk_bin(BlockSize),
+ Type = type(Type0, KeySize),
{Type, funs({block, {Type, Key, IV, Block}})};
-data(aes_gcm=Type, KeySize, BlockSize) ->
+data(aes_gcm=Type0, KeySize, BlockSize) ->
Key = mk_bin(KeySize div 8),
IV = mk_bin(12),
Block = mk_bin(BlockSize),
AAD = <<01,02,03,04>>,
+ Type = type(Type0, KeySize),
{Type, funs({aead, {Type, Key, IV, AAD, Block, 16}})};
-data(aes_ccm=Type, KeySize, BlockSize) ->
+data(aes_ccm=Type0, KeySize, BlockSize) ->
Key = mk_bin(KeySize div 8),
IV = mk_bin(12),
Block = mk_bin(BlockSize),
AAD = <<01,02,03,04>>,
+ Type = type(Type0, KeySize),
{Type, funs({aead, {Type, Key, IV, AAD, Block, 12}})};
-data(aes_ctr=Type, KeySize, BlockSize) ->
+data(aes_ctr=Type0, KeySize, BlockSize) ->
Key = mk_bin(KeySize div 8),
IV = mk_bin(16),
Block = mk_bin(BlockSize),
+ Type = type(Type0, KeySize),
{Type, funs({block, {Type, Key, IV, Block}})};
data(chacha20_poly1305=Type, 256=KeySize, BlockSize) ->