aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorandreaP <[email protected]>2014-12-23 15:25:59 +0100
committerMarcus Arendt <[email protected]>2015-01-09 10:31:35 +0100
commitbd65ff0b39f3bfb23cef865dd03044a99d97d2fd (patch)
treefd51a8d3ac2b01e558b7b2413b8ac2e7819caef5 /lib
parentc7d371256a1f6f0a60d62f70d1bca2a45867e22e (diff)
downloadotp-bd65ff0b39f3bfb23cef865dd03044a99d97d2fd.tar.gz
otp-bd65ff0b39f3bfb23cef865dd03044a99d97d2fd.tar.bz2
otp-bd65ff0b39f3bfb23cef865dd03044a99d97d2fd.zip
fixes and tests
Diffstat (limited to 'lib')
-rw-r--r--lib/crypto/src/crypto.erl20
-rw-r--r--lib/crypto/test/crypto_SUITE.erl102
2 files changed, 115 insertions, 7 deletions
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index ed8953fa62..c59c9077c2 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -154,9 +154,10 @@
-deprecated({aes_ctr_decrypt, 3, next_major_release}).
-deprecated({rc4_encrypt, 2, next_major_release}).
-%aes enc/dec
--export([aes_ecb_crypt/3,aes_ecb_encrypt/2,aes_ecb_decrypt/2]).
--deprecated({aes_ecb_crypt, 3}).
+%aes ecb enc/dec
+-export([aes_ecb_encrypt/2,aes_ecb_decrypt/2]).
+-deprecated({aes_ecb_encrypt, 2, next_major_release}).
+-deprecated({aes_ecb_decrypt, 2, next_major_release}).
%% Replace by public/private_encrypt/decrypt
-export([rsa_public_encrypt/3, rsa_private_decrypt/3]).
@@ -372,19 +373,24 @@ block_decrypt(chacha20_poly1305, Key, Ivec, {AAD, Data, Tag}) ->
end;
block_decrypt(rc2_cbc, Key, Ivec, Data) ->
rc2_cbc_decrypt(Key, Ivec, Data).
--spec block_encrypt(des_ecb | blowfish_ecb, Key::iodata(), Data::iodata()) -> binary().
+
+-spec block_encrypt(des_ecb | blowfish_ecb | aes_ecb, Key::iodata(), Data::iodata()) -> binary().
block_encrypt(des_ecb, Key, Data) ->
des_ecb_encrypt(Key, Data);
block_encrypt(blowfish_ecb, Key, Data) ->
- blowfish_ecb_encrypt(Key, Data).
+ blowfish_ecb_encrypt(Key, Data);
+block_encrypt(aes_ecb, Key, Data) ->
+ aes_ecb_encrypt(Key, Data).
-spec block_decrypt(des_ecb | blowfish_ecb, Key::iodata(), Data::iodata()) -> binary().
block_decrypt(des_ecb, Key, Data) ->
des_ecb_decrypt(Key, Data);
block_decrypt(blowfish_ecb, Key, Data) ->
- blowfish_ecb_decrypt(Key, Data).
+ blowfish_ecb_decrypt(Key, Data);
+block_decrypt(aes_ecb, Key, Data) ->
+ aes_ecb_decrypt(Key, Data).
-spec next_iv(des_cbc | des3_cbc | aes_cbc | aes_ige, Data::iodata()) -> binary().
@@ -1869,7 +1875,7 @@ mod_exp_nif(_Base,_Exp,_Mod,_bin_hdr) -> ?nif_stub.
aes_ctr_encrypt, aes_ctr_decrypt,
aes_ctr_stream_init, aes_ctr_stream_encrypt, aes_ctr_stream_decrypt,
%%
- aes_ecb_encrypt, aes_decrypt,
+ aes_ecb_encrypt, aes_ecb_decrypt,
next_iv,
%% deprecated
aes_cbc_ivec,
diff --git a/lib/crypto/test/crypto_SUITE.erl b/lib/crypto/test/crypto_SUITE.erl
index 1031e6403f..1206ba2ca2 100644
--- a/lib/crypto/test/crypto_SUITE.erl
+++ b/lib/crypto/test/crypto_SUITE.erl
@@ -58,6 +58,7 @@ all() ->
{group, aes_cfb8},
{group, aes_cfb128},
{group, aes_cbc256},
+ {group, aes_ecb},
{group, aes_ige256},
{group, rc2_cbc},
{group, rc4},
@@ -96,6 +97,7 @@ groups() ->
{aes_cfb8,[], [block]},
{aes_cfb128,[], [block]},
{aes_cbc256,[], [block]},
+ {aes_ecb,[], [block]},
{aes_ige256,[], [block]},
{blowfish_cbc, [], [block]},
{blowfish_ecb, [], [block]},
@@ -749,6 +751,9 @@ group_config(aes_cbc128, Config) ->
group_config(aes_cbc256, Config) ->
Block = aes_cbc256(),
[{block, Block} | Config];
+group_config(aes_ecb, Config) ->
+ Block = aes_ecb(),
+ [{block, Block} | Config];
group_config(aes_ige256, Config) ->
Block = aes_ige256(),
[{block, Block} | Config];
@@ -1183,6 +1188,103 @@ aes_cbc256() ->
hexstr2bin("f69f2445df4f9b17ad2b417be66c3710")}
].
+aes_ecb() ->
+ [
+ {aes_ecb,
+ hexstr2bin("0000000000000000"),
+ hexstr2bin("0000000000000000")},
+ {aes_ecb,
+ hexstr2bin("FFFFFFFFFFFFFFFF"),
+ hexstr2bin("FFFFFFFFFFFFFFFF")},
+ {aes_ecb,
+ hexstr2bin("3000000000000000"),
+ hexstr2bin("1000000000000001")},
+ {aes_ecb,
+ hexstr2bin("1111111111111111"),
+ hexstr2bin("1111111111111111")},
+ {aes_ecb,
+ hexstr2bin("0123456789ABCDEF"),
+ hexstr2bin("1111111111111111")},
+ {aes_ecb,
+ hexstr2bin("0000000000000000"),
+ hexstr2bin("0000000000000000")},
+ {aes_ecb,
+ hexstr2bin("FEDCBA9876543210"),
+ hexstr2bin("0123456789ABCDEF")},
+ {aes_ecb,
+ hexstr2bin("7CA110454A1A6E57"),
+ hexstr2bin("01A1D6D039776742")},
+ {aes_ecb,
+ hexstr2bin("0131D9619DC1376E"),
+ hexstr2bin("5CD54CA83DEF57DA")},
+ {aes_ecb,
+ hexstr2bin("07A1133E4A0B2686"),
+ hexstr2bin("0248D43806F67172")},
+ {aes_ecb,
+ hexstr2bin("3849674C2602319E"),
+ hexstr2bin("51454B582DDF440A")},
+ {aes_ecb,
+ hexstr2bin("04B915BA43FEB5B6"),
+ hexstr2bin("42FD443059577FA2")},
+ {aes_ecb,
+ hexstr2bin("0113B970FD34F2CE"),
+ hexstr2bin("059B5E0851CF143A")},
+ {aes_ecb,
+ hexstr2bin("0170F175468FB5E6"),
+ hexstr2bin("0756D8E0774761D2")},
+ {aes_ecb,
+ hexstr2bin("43297FAD38E373FE"),
+ hexstr2bin("762514B829BF486A")},
+ {aes_ecb,
+ hexstr2bin("07A7137045DA2A16"),
+ hexstr2bin("3BDD119049372802")},
+ {aes_ecb,
+ hexstr2bin("04689104C2FD3B2F"),
+ hexstr2bin("26955F6835AF609A")},
+ {aes_ecb,
+ hexstr2bin("37D06BB516CB7546"),
+ hexstr2bin("164D5E404F275232")},
+ {aes_ecb,
+ hexstr2bin("1F08260D1AC2465E"),
+ hexstr2bin("6B056E18759F5CCA")},
+ {aes_ecb,
+ hexstr2bin("584023641ABA6176"),
+ hexstr2bin("004BD6EF09176062")},
+ {aes_ecb,
+ hexstr2bin("025816164629B007"),
+ hexstr2bin("480D39006EE762F2")},
+ {aes_ecb,
+ hexstr2bin("49793EBC79B3258F"),
+ hexstr2bin("437540C8698F3CFA")},
+ {aes_ecb,
+ hexstr2bin("018310DC409B26D6"),
+ hexstr2bin("1D9D5C5018F728C2")},
+ {aes_ecb,
+ hexstr2bin("1C587F1C13924FEF"),
+ hexstr2bin("305532286D6F295A")},
+ {aes_ecb,
+ hexstr2bin("0101010101010101"),
+ hexstr2bin("0123456789ABCDEF")},
+ {aes_ecb,
+ hexstr2bin("1F1F1F1F0E0E0E0E"),
+ hexstr2bin("0123456789ABCDEF")},
+ {aes_ecb,
+ hexstr2bin("E0FEE0FEF1FEF1FE"),
+ hexstr2bin("0123456789ABCDEF")},
+ {aes_ecb,
+ hexstr2bin("0000000000000000"),
+ hexstr2bin("FFFFFFFFFFFFFFFF")},
+ {aes_ecb,
+ hexstr2bin("FFFFFFFFFFFFFFFF"),
+ hexstr2bin("0000000000000000")},
+ {aes_ecb,
+ hexstr2bin("0123456789ABCDEF"),
+ hexstr2bin("0000000000000000")},
+ {aes_ecb,
+ hexstr2bin("FEDCBA9876543210"),
+ hexstr2bin("FFFFFFFFFFFFFFFF")}
+ ].
+
aes_ige256() ->
[{aes_ige256,
hexstr2bin("603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"),