Skip to content

Commit 16209b5

Browse files
committed
Fix and extend AEAD ciphers test in crypto
1 parent d848fbc commit 16209b5

1 file changed

Lines changed: 46 additions & 32 deletions

File tree

lib/crypto/test/crypto_SUITE.erl

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,42 +1574,56 @@ cipher_info(Config) when is_list(Config) ->
15741574
cipher_info_prop_aead_attr() ->
15751575
[{doc, "crypto cipher_info prop_aead attribute testing"}].
15761576
cipher_info_prop_aead_attr(Config) when is_list(Config) ->
1577-
AeadCiphers = [aes_128_ccm, aes_192_ccm, aes_256_ccm, aes_128_gcm, aes_192_gcm, aes_256_gcm, chacha20_poly1305],
1578-
case lists:foldl(fun(C,Ok) ->
1579-
case crypto:cipher_info(C) of
1580-
#{prop_aead := true} ->
1581-
true and Ok;
1582-
_ ->
1583-
false
1584-
end
1577+
SupportedCiphers = sets:from_list(crypto:supports(ciphers)),
1578+
1579+
%% Taken from type crypto:cipher_aead()
1580+
AeadCiphers = sets:from_list([aes_128_ccm, aes_192_ccm, aes_256_ccm, aes_ccm,
1581+
aes_128_gcm, aes_192_gcm, aes_256_gcm, aes_gcm,
1582+
sm4_gcm, sm4_ccm, chacha20_poly1305]),
1583+
SupportedAeadCiphers = sets:intersection(AeadCiphers, SupportedCiphers),
1584+
ct:log("Checking ~b/~b AEAD Ciphers: ~p",
1585+
[sets:size(SupportedAeadCiphers),
1586+
sets:size(AeadCiphers),
1587+
sets:to_list(SupportedAeadCiphers)]),
1588+
true = sets:fold(fun(C, Ok) ->
1589+
case crypto:cipher_info(C) of
1590+
#{prop_aead := true} ->
1591+
Ok;
1592+
_ ->
1593+
ct:fail("AEAD Cipher attribute reported false: ~s", [C])
1594+
end
15851595
end,
15861596
true,
1587-
AeadCiphers
1588-
)
1589-
of
1590-
true ->
1591-
ok;
1592-
false ->
1593-
ct:fail('AEAD Cipher attribute reported false',[])
1594-
end,
1595-
NonAeadCiphers = [aes_ige256, blowfish_cbc, blowfish_cfb64],
1596-
case lists:foldl(fun(C,Ok) ->
1597-
case crypto:cipher_info(C) of
1598-
#{prop_aead := false} ->
1599-
true and Ok;
1600-
_ ->
1601-
false
1602-
end
1597+
SupportedAeadCiphers),
1598+
1599+
%% Taken from types crypto:cipher_iv() and crypto:cipher_no_iv()
1600+
NonAeadCiphers = sets:from_list([aes_128_cbc, aes_192_cbc, aes_256_cbc, aes_cbc,
1601+
aes_128_ofb, aes_192_ofb, aes_256_ofb, aes_128_cfb128,
1602+
aes_192_cfb128, aes_256_cfb128, aes_cfb128, aes_128_cfb8,
1603+
aes_192_cfb8, aes_256_cfb8, aes_cfb8, aes_128_ctr,
1604+
aes_192_ctr, aes_256_ctr, aes_ctr, sm4_cbc, sm4_ofb,
1605+
sm4_cfb, sm4_ctr, blowfish_cbc, blowfish_cfb64,
1606+
blowfish_ofb64, chacha20, des_ede3_cbc, des_ede3_cfb,
1607+
des_cbc, des_cfb, rc2_cbc, aes_128_ecb, aes_192_ecb,
1608+
aes_256_ecb, aes_ecb, blowfish_ecb, des_ecb, sm4_ecb,
1609+
rc4]),
1610+
SupportedNonAeadCiphers = sets:intersection(NonAeadCiphers, SupportedCiphers),
1611+
ct:log("Checking ~b/~b Non-AEAD Ciphers: ~p",
1612+
[sets:size(SupportedNonAeadCiphers),
1613+
sets:size(NonAeadCiphers),
1614+
sets:to_list(SupportedNonAeadCiphers)]),
1615+
true = sets:fold(fun(C, Ok) ->
1616+
case crypto:cipher_info(C) of
1617+
#{prop_aead := false} ->
1618+
Ok;
1619+
_ ->
1620+
ct:fail("Non-AEAD Cipher attribute reported true: ~s", [C])
1621+
end
16031622
end,
16041623
true,
1605-
NonAeadCiphers
1606-
)
1607-
of
1608-
true ->
1609-
ok;
1610-
false ->
1611-
ct:fail('Non-AEAD Cipher attribute reported true',[])
1612-
end.
1624+
SupportedNonAeadCiphers),
1625+
1626+
ok.
16131627

16141628
%%--------------------------------------------------------------------
16151629
hash_info() ->

0 commit comments

Comments
 (0)