summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLoïc Hoguin <essen@ninenines.eu>2016-09-29 16:49:15 +0200
committerLoïc Hoguin <essen@ninenines.eu>2016-09-29 16:49:15 +0200
commit7cb692ea9f4b4ae871e9eb31aa67367f30b976f1 (patch)
tree791a4dc216435be4964b9c1f680cc1f8eeda461d /test
parentd0359ac82ce8c3a8868800963c9163afe91456b6 (diff)
downloadrabbitmq-server-git-7cb692ea9f4b4ae871e9eb31aa67367f30b976f1.tar.gz
Add rabbit_pbe module for password based encryption
Diffstat (limited to 'test')
-rw-r--r--test/unit_SUITE.erl21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/unit_SUITE.erl b/test/unit_SUITE.erl
index 43e812fa3d..165f0d996b 100644
--- a/test/unit_SUITE.erl
+++ b/test/unit_SUITE.erl
@@ -41,6 +41,7 @@ groups() ->
]},
content_framing,
content_transcoding,
+ encrypt_decrypt,
pg_local,
pmerge,
plmerge,
@@ -233,6 +234,26 @@ prepend_check(HeaderKey, HeaderTable, Headers) ->
rabbit_misc:table_lookup(Invalid, HeaderKey),
Headers1.
+encrypt_decrypt(_Config) ->
+ %% Take all available block ciphers.
+ Hashes = proplists:get_value(hashs, crypto:supports())
+ -- [md4, ripemd160],
+ Ciphers = proplists:get_value(ciphers, crypto:supports())
+ -- [aes_ctr, aes_ecb, des_ecb, blowfish_ecb, rc4, aes_gcm],
+ %% For each cipher, try to encrypt and decrypt data sizes from 0 to 64 bytes
+ %% with a random passphrase.
+ _ = [begin
+ PassPhrase = crypto:strong_rand_bytes(16),
+ Iterations = rand_compat:uniform(100),
+ Data = crypto:strong_rand_bytes(64),
+ [begin
+ Expected = binary:part(Data, 0, Len),
+ Enc = rabbit_pbe:encrypt(C, H, Iterations, PassPhrase, Expected),
+ Expected = iolist_to_binary(rabbit_pbe:decrypt(C, H, Iterations, PassPhrase, Enc))
+ end || Len <- lists:seq(0, byte_size(Data))]
+ end || H <- Hashes, C <- Ciphers],
+ ok.
+
%% -------------------------------------------------------------------
%% pg_local.
%% -------------------------------------------------------------------