summaryrefslogtreecommitdiff
path: root/lib/crypto/test/crypto_bench_SUITE.erl
diff options
context:
space:
mode:
authorHans Nilsson <hans@erlang.org>2021-01-22 10:35:58 +0100
committerHans Nilsson <hans@erlang.org>2021-01-22 10:39:19 +0100
commit424ab4b2ce25a2a30f081f23489c9e489500834b (patch)
treed34c20eae0059ef2160c62f50cb67971ccbc07cb /lib/crypto/test/crypto_bench_SUITE.erl
parentef6fd1337ce58b3efed3029684568b8893ebdbe0 (diff)
downloaderlang-424ab4b2ce25a2a30f081f23489c9e489500834b.tar.gz
ssh: Crypto benchmarks converted to new api
Diffstat (limited to 'lib/crypto/test/crypto_bench_SUITE.erl')
-rw-r--r--lib/crypto/test/crypto_bench_SUITE.erl46
1 files changed, 21 insertions, 25 deletions
diff --git a/lib/crypto/test/crypto_bench_SUITE.erl b/lib/crypto/test/crypto_bench_SUITE.erl
index 8aa9789598..ba1e830287 100644
--- a/lib/crypto/test/crypto_bench_SUITE.erl
+++ b/lib/crypto/test/crypto_bench_SUITE.erl
@@ -212,62 +212,58 @@ find_value(KeyPath, PropList) ->
%%%
funs({block, {Type, Key, IV, Block}}) ->
{fun() -> ok end,
- fun(_) -> crypto:block_encrypt(Type, Key, IV, Block) end,
+ fun(_) -> crypto:crypto_one_time(Type, Key, IV, Block, true) end,
fun(_) -> ok end};
-funs({stream, {Type, Key, IV, Block}}) ->
- {fun() -> {crypto:stream_init(Type, Key, IV),ok} end,
- fun({Ctx,_}) -> crypto:stream_encrypt(Ctx, Block) end,
+funs({aead, {Type, Key, IV, AAD, Block, TagSize}}) ->
+ {fun() -> ok end,
+ fun(_) -> crypto:crypto_one_time_aead(Type, Key, IV, Block, AAD, TagSize, true) end,
+ fun(_) -> ok end};
+
+funs({aead, {Type, Key, IV, AAD, Block}}) ->
+ {fun() -> ok end,
+ fun(_) -> crypto:crypto_one_time_aead(Type, Key, IV, Block, AAD, true) end,
fun(_) -> ok end}.
-data(aes_cbc, KeySize, BlockSize) ->
- Type = case KeySize of
- 128 -> aes_cbc128;
- 256 -> aes_cbc256
- end,
+data(aes_cbc=Type, KeySize, BlockSize) ->
Key = mk_bin(KeySize div 8),
IV = mk_bin(16),
Block = mk_bin(BlockSize),
{Type, funs({block, {Type, Key, IV, Block}})};
-data(aes_gcm, KeySize, BlockSize) ->
- Type = aes_gcm,
+data(aes_gcm=Type, KeySize, BlockSize) ->
Key = mk_bin(KeySize div 8),
IV = mk_bin(12),
Block = mk_bin(BlockSize),
AAD = <<01,02,03,04>>,
- {Type, funs({block, {Type, Key, IV, {AAD,Block,16}}})};
+ {Type, funs({aead, {Type, Key, IV, AAD, Block, 16}})};
-data(aes_ccm, KeySize, BlockSize) ->
- Type = aes_ccm,
+data(aes_ccm=Type, KeySize, BlockSize) ->
Key = mk_bin(KeySize div 8),
IV = mk_bin(12),
Block = mk_bin(BlockSize),
AAD = <<01,02,03,04>>,
- {Type, funs({block, {Type, Key, IV, {AAD,Block,12}}})};
+ {Type, funs({aead, {Type, Key, IV, AAD, Block, 12}})};
-data(aes_ctr, KeySize, BlockSize) ->
- Type = aes_ctr,
+data(aes_ctr=Type, KeySize, BlockSize) ->
Key = mk_bin(KeySize div 8),
IV = mk_bin(16),
Block = mk_bin(BlockSize),
- {Type, funs({stream, {Type, Key, IV, Block}})};
+ {Type, funs({block, {Type, Key, IV, Block}})};
-data(chacha20_poly1305, 256=KeySize, BlockSize) ->
- Type = chacha20_poly1305,
+data(chacha20_poly1305=Type, 256=KeySize, BlockSize) ->
Key = mk_bin(KeySize div 8),
- IV = mk_bin(16),
+ IV = mk_bin(12),
AAD = <<01,02,03,04>>,
Block = mk_bin(BlockSize),
- {Type, funs({block, {Type, Key, IV, {AAD,Block}}})};
+ {Type, funs({aead, {Type, Key, IV, AAD, Block, 16}})};
-data(chacha20, 256=KeySize, BlockSize) ->
- Type = chacha20,
+data(chacha20=Type, 256=KeySize, BlockSize) ->
Key = mk_bin(KeySize div 8),
IV = mk_bin(16),
Block = mk_bin(BlockSize),
- {Type, funs({stream, {Type, Key, IV, Block}})};
+ {Type, funs({block, {Type, Key, IV, Block}})};
data(empty, 0, 0) ->
{undefined,